Skip to main content
Version: 5.1

timechart

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:

ParameterSyntaxDescription
countcount | count(<field>)Computes the count of events containing a field. If no field is specified, calculates the total number of events.
avgavg(<field>)Computes the average value for a given field.
dcdc(<field>)Computes the number of unique values in a given field.
maxmax(<field>)Computes the maximum value for a given field.
minmin(<field>)Computes the minimum value for a given field.
sumsum(<field>)Computes the sum of the values in a given field.
percperc(<field>, <percent>)Calculates the percentile for a specified field and percentage.
medianmedian(<field>)Calculates the median for a specified field.

Optional Arguments

ParameterSyntaxDefaultDescription
spanspan=<span>see predefined span valuesDefines the interval for segment distribution.
timefieldtimefield=<field>@timestampThe field name where the timestamp is stored.
binsbins=<int>100The maximum number of segments for computation.
limitlimit=<int>10The maximum number of unique by_field values that can be used in the column names of the result. Remaining values will be merged into the OTHER field.
useotheruseother=<boolean>trueIf set to false, the limit parameter is ignored.
by_expressionby <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 values

If the span parameter is not specified for the time field, predefined parameters will apply.

Here's the list of predefined parameters:

Time Intervalspan
last 15 minutes10 seconds
last 60 minutes1 minute
last 4 hours5 minutes
last 24 hours30 minutes
last 7 days1 day
last 30 days1 day
last year1 month

Query Examples

Example 1

Calculating the average number of messages per user by hourly intervals:

Example №1
... | timechart limit=5 span=1h avg(msgNums) by user

Example 2

In this example, for each unique value of the event.outcome field, data is aggregated over a 15-minute time interval, counting the number of events. The query's time range is divided into 15 intervals.

Example №2
... | timechart bins=15 span=15m count by event.outcome

For the example input data below, a grouped series bar chart is constructed:

usernamerequestpathstatusevent.outcome
IvanovGET/veil200success
PetrovGET/cherry200success
IvanovPOST/fuel403failure
AndreevGET/quilt200success

Bar Chart


Example 3

Calculating the total number of events and the maximum log offset by 3-hour intervals:

Example №3
... | timechart span=3h count(log.offset), max(log.offset) by event

Example 4

In this example, for each hourly interval, the system will return the value of the msgNums field that occurs in 95 percent of cases:

Example №4
... | timechart span=1h perc(msgNums, 95)

Example 5

Dynamics of network traffic response volume for each operating system by 30-minute intervals with a limit on the number of unique hosts:

Example №5
| timechart span=30m sum(http.response.body.bytes) as 'Объем, КБ' by user_agent.os.full
| eval 'Объем, КБ'=round('Объем, КБ'/1024)

In this example, a new field Volume, KB is created, which converts the values of the http.response.body.bytes field to kilobytes. The round command rounds the kilobytes to 2 significant digits and saves the result into the new Volume, KB field.

For each unique host value user_agent.os.full, the dynamics of the network traffic response volume Volume, KB is calculated for a 30-minute interval.

Example input data:

user.namehttp.response.body.bytesuser_agent.os.full@timestamp
Ivanov50988Mac OS X2025-05-26T15:25:39.697685Z
Petrov10772Windows 82025-05-26T15:25:33.003472Z
Borisov51954Windows 102025-05-26T15:25:24.338701Z
Ermolov10541iPhone OS 4.2.62025-05-26T15:25:24.290198Z
Andreev10646Android 2.3.32025-05-26T15:25:25.223198Z

The query execution result could be the following table:

Android 2.3.3Mac OS XWindows 10Windows 8iPhone OS 4.2.6@timestamp
1813001332571362025-05-26T16:00:00.000Z
2303502332372832025-05-26T16:30:00.000Z
5685033882883782025-05-26T17:00:00.000Z

Line Chart