Skip to content

stat

Input Stack:
statistic: String
expr: TimeSeriesExpr
Output Stack:
TimeSeriesExpr
 

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 values
  • max: Maximum value across all datapoints
  • min: Minimum value across all datapoints
  • count: Number of non-NaN datapoints
  • total: Sum of all non-NaN values
  • last: 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:

BeforeAfter
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:

These helpers automatically substitute the input expression when used with :filter, eliminating the need to repeat complex queries.

  • :filter - Use stat results for filtering time series
  • :by - Group data before computing statistics