What is Splunk Timechart?
The Splunk timechart command generates a table of summary statistics. This table can then be formatted as a chart visualization, where your data is plotted against an x-axis that is always a time field. Use the timechart command to display statistical trends over time You can split the data with another field as a separate series in the chart. Time chart visualizations are usually line, area, or column charts.
timechart command, the x-axis represents time. The y-axis can be any other field value, count of values, or statistical calculation of a field value.
Syntax: timechart [sep=<string>] [partial=<bool>] [cont=<t|f>] [limit=<int>] [agg=<stats-agg-term>] [<bucketing-option> ]* (<single-agg> [by <split-by-clause>] ) | ( (<eval-expression>) by <split-by-clause> )
When specifying timechart arguments, either <single-agg> or <eval-expression> BY <split-by-clause> is required.
Syntax: <field> (<tc-option>)* [<where-clause>]
Description: Specifies a field to split by. If field is numerical, default discretization is applied; discretization is defined with tc-option.
Description: A single aggregation applied to a single field (can be evaled field). No wildcards are allowed. The field must be specified, except when using the special 'count' aggregator that applies to events as a whole.
Syntax: <math-exp> | <concat-exp> | <compare-exp> | bool-exp> | <function-call>
Description: A combination of literals, fields, operators, and functions that represent the value of your destination field. The following are the basic operations you can perform with eval. For these evaluations to work, your values need to be valid for the type of operation. For example, with the exception of addition, arithmetic operations may not produce valid results if the values are not numerical. Additionally, Splunk can concatenate the two operands if they are both strings. When concatenating values with '.', Splunk treats both values as strings regardless of their actual type.
Description: See the Stats functions section below. For a list of stats functions with descriptions and examples, see"Functions for stats, chart, and timechart".
Accelerate Your Career With Splunk Training and become expertise Splunk Developer.
Syntax: bins | minspan | span | <start-end>
Description: Discretization options. If a bucketing option is not supplied,
timechart defaults to
bins=100. bins sets the maximum number of bins, not the target number of bins.
Description: See the Stats functions section below. For a list of stats functions with descriptions and examples, seeStatistical and charting functions in this manual.
Syntax: bins | minspan | span | <start-end>
Description: Options that you can use to specify discreet bins, or groups, to organize the information. The
bin-optionsset the maximum number of bins, not the target number of bins. See the Bin options section in this topic.Default: bins=100
Description: (Not valid for 4.2) Specify whether or not to enforce the earliest and latest times of the search. Setting fixedrange=false allows the timechart command to constrict to just the time range with valid data.Default: true
Description: Used to construct output field names when multiple data series are used in conjunction with a split-by-field.
format takes precedence over
sep and allows you to specify a parameterized expression with the stats aggregator and function ($AGG$) and the value of the split-by-field ($VALUE$).
Description: Specifies a limit for the number of distinct values of the split-by field to return. If set to limit=0, all distinct values are used. Setting limit=N keeps the N highest scoring distinct values of the
split-by field. All other values are grouped into 'OTHER', as long as
useother is not set to false.
-The scoring is determined as follows:
- If a single aggregation is specified, the score is based on the sum of the values in the aggregation for that split-by value. For example, for
timechart avg(foo) BY <field>the
avg(foo)values are added up for each value of <field> to determine the scores.
- If multiple aggregations are specified, the score is based on the frequency of each value of <field>. For example, for
timechart avg(foo) max(bar) BY <field>, the top scoring values for <field> are the most common values of <field>.
- Ties in scoring are broken lexicographically, based on the value of the
- field. For example, 'BAR' take precedence over 'bar', which takes precedence over 'foo'.
Description: Controls if partial time bins should be retained or not. Only the first and last bin can be partial.
Default: True. Partial time bins are retained.
Description: Used to construct output field names when multiple data series are used in conjunctions with a split-by field. This is equivalent to setting
Syntax: <stats-func> ( <evaled-field> | <wc-field> ) [AS <wc-field>]
Description: A statistical aggregation function. Use the AS clause to place the result into a new field with a name that you specify. The function can be applied to an eval expression, or to a field or set of fields. You can use wild card characters in field names.
Syntax: avg() | c() | count() | dc() | distinct_count() | earliest() | estdc() | estdc_error() | exactperc<int>() | first() | last() | latest() | list() | max() | median() | min() | mode() | p<in>() | perc<int>() | per_day() | per_hour() | per_minute() | per_second() |range() | stdev() | stdevp() | sum() | sumsq() | upperperc<int>() | values() | var() | varp()
Description: Functions you can use with the
timechart command. Each time you invoke the
timechart command, you can specify more than one function.
- Syntax: bins=<int>
- Description: Sets the maximum number of bins to discretize into. This does not set the target number of bins. It finds the smallest bin size that results in no more than N distinct bins. Even though you specify a number such as 300, the resulting number of bins might be much lower.
- Default: 100
- Syntax: minspan=<span-length>
- Description: Specifies the smallest span granularity to use automatically inferring span from the data time range.
- Syntax: span=<log-span> | span=<span-length>
- Description: Sets the size of each bin, using a span length based on time or log-based span.
Syntax: end=<num> | start=<num>
Description:Sets the minimum and maximum extents for numerical bins. Data outside of the [start, end] range is discarded.
Description: Sets to log-based span. The first number is a coefficient. The second number is the base. If the first number is supplied, it must be a real number >= 1.0 and < base. Base, if supplied, must be real number > 1.0 (strictly greater than 1).
Description: A span of each bin, based on time. If the timescale is provided, this is used as a time range. If not, this is an absolute bin length.
Syntax: <sec> | <min> | <hr> | <day> | <week> | <month> | <subseconds>
Description: Time scale units.
|<sec>||s | sec | secs | second | seconds||Time scale in seconds.|
|<min>||m | min | mins | minute | minutes||Time scale in minutes.|
|<hr>||h | hr | hrs | hour | hours||Time scale in hours.|
|<day>||d | day | days||Time scale in days.|
|<month>||mon | month | months||Time scale in months.|
|<subseconds>||us | ms | cs | ds||Time scale in microseconds (us), milliseconds (ms), centiseconds (cs), or deciseconds (ds)|
The <tc-option> is part of the <split-by-clause>.
- Syntax: <bin-options> | usenull=<bool> | useother=<bool> | nullstr=<string> | otherstr=<string>
- Description: Options for controlling the behavior of splitting by a field.
- See the Bin options section in this topic.
- Syntax: nullstr=<string>
- Description: If usenull is true, this series is labeled by the value of the nullstr option.
- Default: NULL
- Syntax: otherstr=<string>
- Description: If useother is True, this series is labeled by the value of the otherstr option.
- Default: OTHER
Description: Controls whether or not a series is created for events that do not contain the split-by field.
Description: Specifies if a series should be added for data series not included in the graph because they did not meet the criteria of the <where-clause>.
The <where-clause> is part of the <split-by-clause>.
- where clause
- Syntax: <single-agg> <where-comp>
- Description: Specifies the criteria for including particular data series when a field is given in the tc-by-clause. The most common use of this option is to select for spikes rather than overall mass of distribution in series selection. The default value finds the top ten series by area under the curve. Alternately one could replace sum with max to find the series with the ten highest spikes.This has no relation to the where command.
- Syntax: <wherein-comp> | <wherethresh-comp>
- Description: A criteria for the where clause.
- Syntax: (in | notin) (top | bottom)<int>
- Description: A where-clause criteria that requires the aggregated series value be in or not in some top or bottom grouping.
- Syntax: (< | >)( )?<num>
- Description: A where-clause criteria that requires the aggregated series value be greater than or less than some numeric threshold.
bins and span arguments
The timechart command accepts either the
bins argument OR the
span argument. If you do not specify either
timechart command uses the default
Default time spans
It you use the predefined time ranges in the time range picker, and do not specify the
span argument, the following table shows the default span that is used.
|Time range||Default 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|
|Previous year||1 month|
For an Indepth knowledge on Splunk, click on below