Dynamic variables

You can use dynamic variables to include timestamps in folder paths, names, and log filenames in DataStream 2.

Other variables you can use are the stream ID and stream version, which allow you to group logs depending on the stream.

This helps you sort logs in object-based destinations where your stream sends and stores logs, such as Amazon S3, Azure Storage, Google Cloud Storage, Oracle Cloud, and S3-compatible destinations.

When sending logs to Elasticsearch, you can use dynamic time variables in index names. See Stream logs to Elasticsearch for details.

Dynamic variables

Use {}to enter a dynamic variable in folder paths and upload file prefixes. You can use these variables:

  • %Y for a year. For example, 2025.

  • %m for a month (01-12). For example, 03.

  • %d for a day (01-31). For example, 13.

  • %H for an hour (00-23). For example, 15.

  • %M for a minute (00-59). For example, 32.

  • %S for a second (00-59). For example, 48.

  • %streamId for the ID of the stream. For example, 65938 (supported only in the v2 API).

  • %streamVersion for the version of the stream. For example, 2 (supported only in the v2 API).

Folder path variables

You can combine static values and dynamic variables in a string of up to 255 characters in the Folder path fields to point to the folder path where you want to store logs. On sending a log file to this path, the system resolves dynamic variables into the current date, time, and hour in the UTC standard, and the stream ID and version into integers.

📘

The timestamp in the folder name or filename prefix may differ from the actual time the file uploads to the destination. DataStream creates folders and log files a few seconds before uploading.

Multiple dynamic variables separated by / within one {}create separate folders. For example, {%Y/%m/%d/} creates this path consisting of three folders: 2020/10/05. Multiple variables joined without a separator create one folder. For example, {%Y}{%m}{%d} creates the 20201005 folder.

Here are the path examples:

Path in configurationPath in destination
logs/{%Y/%m/%d} logs/2022/10/27
datastream/{%m/%d}/{%H}-{%M}-{%S} datastream/03/06/21-02-13
{%m}-logs/diagnostics 05-logs/diagnostics
diagnostics/{%Y}/{%m}/{%d}{%H} diagnostics/2022/11/0516
logs/{%Y}-{%m}-{%d}/stream-{%streamId}/{%streamVersion) logs/2022-11-05/stream-65938/2

Log file variables

Log files that the system uploads to your destination follow this naming pattern:
<uploadFilePrefix>-{random-string}-{epoch-timestamp}-{random-string}-<uploadFileSuffix>

Depending on the destination, you can customize the <uploadFilePrefix> and <uploadFileSuffix> values for these files.

You can use static values and dynamic variables in a string of up to 200 characters in <uploadFilePrefix> names of log files that you upload to destinations. On sending a log file, the system resolves dynamic variables into the current date, time, and hour, and the stream ID and version into integers.

You can use multiple dynamic values separated by -, _, or no separator. Filename prefixes don't allow . characters, as using them may result in errors and data loss. If unspecified, the <uploadFilePrefix> value defaults to ak.

You can use static values in a string of up to 10 characters in <uploadFileSuffix> names of log files that you upload to destinations of your choice. Filename suffixes don't allow dynamic values, the ., /,%, and ?characters, as using them may result in errors and data loss. If unspecified, the <uploadFileSuffix> value defaults to ds.

Here are the file name examples:

PrefixSuffixFile name
{%Y}-{%m}-{%d} akam 2022-10-27-rps79rkvx-1666884947-dkmzsi6z8-akam
ak-{%streamId}-{%H_%M_%S} datastream ak-15324-21_02_13-datastream
diagnostics{%Y-%m-%d} logs diagnostics2022-12-01-8ds3lufkh-1669908947-m1onxoa16-logs
{%m}-{%streamId}-{%streamVersion}-diagnostics akam 12-65938-2-diagnostics-dk4j0sh3m-1669856400-9kv08v9oy-akam
upload-{%m_%d_%H}-{%streamId}-filedata upload-04_23_18-65938-file-gao0pip6y-1650736800-981bz2ipd-data
Unspecified (ak by default)Unspecified (ds by default)ak-ae47rr5a8-1650736800-ae47rg6hu-ds