stat
Input Stack:
|
⇨ | Output Stack:
|
Compute a summary statistic for each time series, producing a constant horizontal line showing the statistical value calculated across all datapoints in the time window. This reduces each time series to a single representative value based on the specified statistic.
Parameters¶
- expr: The time series expression to compute statistics for
- statistic: The type of statistic to compute (see supported values below)
Supported Statistics¶
avg
: Average (mean) of all non-NaN valuesmax
: Maximum value across all datapointsmin
: Minimum value across all datapointscount
: Number of non-NaN datapointstotal
: Sum of all non-NaN valueslast
: Most recent non-NaN value in the time window
Visual Example¶
The graph below shows avg
, max
, min
, and last
statistics for a sample time series:
Examples¶
Computing average statistic for grouped data:
Before | After |
name,sps,:eq, (,nf.cluster,),:by | name,sps,:eq, (,nf.cluster,),:by, avg,:stat |
Filter Helpers¶
The most common usage is with :filter to restrict results based on statistical
criteria. Helper operators :stat-$(name)
provide a convenient shorthand:
- :stat-avg - Filter by average values
- :stat-max - Filter by maximum values
- :stat-min - Filter by minimum values
- :stat-count - Filter by datapoint count
- :stat-total - Filter by sum of values
- :stat-last - Filter by most recent values
These helpers automatically substitute the input expression when used with :filter
, eliminating
the need to repeat complex queries.