Skip to main content

Rollups

A rollup groups log events into time buckets and saves the totals in a separate dataset. For example, it can count requests and sum their durations for each service every five minutes.

Definition fields​

FieldRequiredMeaning
targetYesName of the output log dataset. Choose a new name unique within the organization, distinct from the source and all existing log datasets.
bucket_secondsYesLength of each time bucket in whole seconds. Must be positive. Use 300 for five minutes.
keysYesOne or more source columns to group by. For example, ["service", "region"] gives a separate total for each service and region pair.
measuresYesNumeric columns to sum. For ["duration_ms"], the target stores the sum and the count of non-null durations. Use [] for a row count alone.
min_maxNoColumns whose minimum and maximum non-null values to store. These can share a target with measures.
percentilesNoNumeric columns to summarize for queries such as median or p95 latency.
distinct_setsNoString or integer columns to summarize for unique counts, such as ["user_id"].
lag_secondsNoWhole seconds to wait after a bucket closes. Minimum and default are 0.
start_atNoStarting Unix timestamp in microseconds, aligned to a bucket boundary. If omitted, processing starts with the bucket current at the worker's first check.

Each column list accepts up to 64 names. Use simple identifiers such as duration_ms and avoid duplicate output names. Percentiles and distinct sets each require their own target with "measures": [] and an empty or omitted min_max.

Create a rollup​

PUT /api/{org}/streams/{source}/settings?type=logs

Send the definition in rollups.add on an existing source log dataset. Set ENGINE_URL to the Engine endpoint that accepts stream settings requests. Set API_KEY to an Engine credential with permission to edit those settings. Replace default and application_logs with your organization and source.

SETTINGS="$ENGINE_URL/api/default/streams/application_logs/settings?type=logs"

curl -fsS -X PUT "$SETTINGS" \
-H "Authorization: Basic $API_KEY" -H 'Content-Type: application/json' \
-d '{"rollups":{"add":[{
"target":"requests_5m",
"bucket_seconds":300,
"keys":["service"],
"measures":["duration_ms"]
}]}}'

Edit the lag​

After creation, only lag_seconds can change. Send the complete definition in rollups.add with the same target name. This request changes the wait from the default of zero to 60 seconds. To change any other field, create a new target.

curl -fsS -X PUT "$SETTINGS" \
-H "Authorization: Basic $API_KEY" -H 'Content-Type: application/json' \
-d '{"rollups":{"add":[{
"target":"requests_5m",
"bucket_seconds":300,
"keys":["service"],
"measures":["duration_ms"],
"lag_seconds":60
}]}}'

Delete a rollup​

Use the same settings PUT with the target name in rollups.remove. Deleting the definition permanently retires that name in the organization. Deletion leaves existing target data in place.

curl -fsS -X PUT "$SETTINGS" \
-H "Authorization: Basic $API_KEY" -H 'Content-Type: application/json' \
-d '{"rollups":{"remove":["requests_5m"]}}'