timechart
Description
Performs search and generates an array of data distributed along a timeline.
Syntax
timechart [<timefield>] [<limit>] [<span>] [<bins>] [<useother>] <functions-expression> ["," <functions-expression>] [<by_expression>]
Required Arguments
functions-expression You must use at least one of the following functions:
| Parameter | Syntax | Description | 
|---|---|---|
| count | count | count(<field>) | Computes the count of events containing a field. If no field is specified, calculates the total number of events. | 
| avg | avg(<field>) | Computes the average value for a given field. | 
| dc | dc(<field>) | Computes the number of unique values in a given field. | 
| max | max(<field>) | Computes the maximum value for a given field. | 
| min | min(<field>) | Computes the minimum value for a given field. | 
| sum | sum(<field>) | Computes the sum of the values in a given field. | 
Optional Arguments
| Parameter | Syntax | Default | Description | 
|---|---|---|---|
| span | span=<span> | see predefined spanvalues | Defines the interval for segment distribution. | 
| timefield | timefield=<field> | @timestamp | The field name where the timestamp is stored. | 
| bins | bins=<int> | 100 | The maximum number of segments for computation. | 
| limit | limit=<int> | 10 | The maximum number of unique by_fieldvalues that can be used in the column names of the result. Remaining values will be merged into theOTHERfield. | 
| useother | useother=<boolean> | true | If set to false, thelimitparameter is ignored. | 
| by_expression | by <field> | The field name for grouping values. | 
The following time formats are allowed: (+|-)<int>(s|m|h|d|w|month):
- s/sec/secs/second/seconds - seconds
- m/min/mins/minute/minutes - minutes
- h/hr/hrs/hour/hours - hours
- d/day/days - days
- w/week/weeks - weeks
- mon/month/months - months
Predefined 
span valuesIf the span parameter is not specified for the time field, predefined parameters will apply.
Here's the list of predefined parameters:
| Time Interval | span | 
|---|---|
| last 15 minutes | 10 seconds | 
| last 60 minutes | 1 minute | 
| last 4 hours | 5 minutes | 
| last 24 hours | 30 minutes | 
| last 7 days | 1 day | 
| last 30 days | 1 day | 
| last year | 1 month | 
Query Examples
Example 1:
Example #1
... | timechart limit=5 span=1h avg(msgNums) by user
Example 2:
Example #2
... | timechart limit=5 span=1d avg(log.offset) by 'source'
Example 3:
Example #3
... | timechart span=1d count(log.offset), max(log.offset) by event