timechart
Aggregate events into fixed time buckets, optionally split into one series per field value.
Use timechart to summarize your events in fixed time buckets. You can split the results into a series for each value of a field.
Syntax
... | timechart [span=<duration>] [limit=<N>] [cont=<bool>] [useother=<bool>] <agg> [as <name>] [, <agg> ...] [by <field>]| Option | Default | Description |
|---|---|---|
span | 1h | Bucket size: a number plus s, m, h or d (30s, 5m, 1h, 1d). |
agg | Any stats aggregation, such as count, dc(f), sum(f). | |
by | Split field. Each value becomes its own series. | |
limit | all series | Keep only the top N series, ranked by the first aggregation over the whole range. |
useother | true | With limit, add the remaining series together as an OTHER series. useother=false drops them. |
cont | false | cont=true adds zero-valued rows for empty buckets so lines don't skip gaps. |
span, limit, cont and useother can come before the aggregations; limit, cont and useother can also follow the by field. You can start a query with timechart and no pipe.
How it works
- Buckets align to the clock: a
5mspan starts at :00, :05, :10. The bucket start is in thetime_bucketcolumn. - Without
by, each aggregation is one column per bucket. - With
by, each split value becomes a series column in the result. - Buckets with no events are left out unless you set
cont=true.
Examples
Event volume per hour:
* | timechart countFailed logons every 15 minutes, per user, top 5 users only:
class_uid=3002 status_id=2 | timechart span=15m count by user.name limit=5 useother=falseHTTP status codes over time, with the rest grouped as OTHER:
class_uid=4002 | timechart span=15m count by http_response.code limit=5Server errors and total requests side by side:
class_uid=4002 | timechart span=5m count as total, count(eval(http_response.code>=500)) as errorsOutbound bytes per hour, with empty hours as zero:
class_uid=4002 | timechart span=1h cont=true sum(traffic.bytes_out) as sent_bytesDistinct hosts reporting per day, by log source:
timechart span=1d dc(device.hostname) as hosts by metadata.log_sourceNotes
spanunits ares,m,handdonly. For a week, usespan=7d.- For buckets you then aggregate yourself (for example to feed
anomaly), use bin andstats. timechartruns after alookup,prevalence,inputlookup,resolve_identity, oraistage too.