timechart
Use the timechart operator to perform aggregations over timespans.
Syntax
|timechart <aggr_func> [as new_field] by [<field_to_split_aggregate>] [span=<interval_with_time_unit>] [limit=<number_of_columns>] [makecontinuous=<create_empty_buckets>] [addtotals=<aggregate_totals>]
<aggr_func>
|
Required. Specify a function to calculate statistics. For example, avg, count, count(distinct <field>), max, min, sum. |
<field_to_split_aggregate>
|
Optional. Specify the field you want to aggregate. Each distinct value of the split-by field becomes a series in the chart. For example, you can split and aggregate on sourcetype to understand event trends for a particular data source over a specific interval. |
|
|
Optional. Specify the time interval for the split. Multiple units are not allowed for week, month, or year. In other words, specify Possible values:
For example, |
|
|
Optional. Specify how many columns will be displayed in the results table. When using Default: |
<create_empty_buckets>
|
Optional. Specify whether to create empty buckets for the time range and span that contains no data. Possible values:
Default: |
<aggregate_totals>
|
Optional. When using When set to true, it automatically appends a new
For example, setting |
Usage
The timechart operator can be used to aggregate data for a field to produce a chart, with time used as the x-axis. You can specify a split-by field, where each distinct value of the split-by field becomes a series in the chart.
Note: After you issue a search with timechart, the value for span may be recalculated and rationalized to create meaningful buckets given the configured time range. Specify makecontinuous=true to create empty buckets for time periods with no data, for time units in s (seconds), m (minutes), h (hours), or d (days).
Examples
Example 1: Counts events over time, grouped by sourcetype.
| timechart count as cnt by sourcetype
Example 2: Counts events per hour, grouped by sourcetype.
| timechart count by sourcetype span=1h
Example 3: Counts events over time, showing only the top five sourcetypes, with others grouped.
| timechart count by sourcetype limit=5
Example 4: Filter AWS CloudTrail logs and chart hourly event counts with continuous time buckets.
| where sourcetype contains_ci 'aws_cloudtrail' | timechart count by sourcetype span=1h makecontinuous=true
Example 5: Count hosts per source type in hourly buckets, creating the total row and column to summarize across all source types and time periods.
| timechart count(host) as devicecount by sourcetype span=1h addtotals=true
Example 6: Create a time chart showing OCSF network activity trends.
ocsf | where class_name = "Network Activity" | timechart count by connection_info.protocol_name span=1h
Example 7: Generates an hourly time series chart of OCSF event counts for the top 5 products.
ocsf | timechart count by metadata.product.name span=1h limit=5