Skip to content

bottomk

Input Stack:
k: Int
stat: String
expr: TimeSeriesExpr
Output Stack:
TimeSeriesExpr
 
 

Select the bottom K time series based on a summary statistic. This operation keeps only the K time series with the smallest values for the specified statistic, effectively filtering out all but the lowest-performing series according to the chosen criteria.

Parameters

  • expr: The grouped time series expression to select from
  • stat: The summary statistic to rank by (max, min, avg, count, total, last)
  • k: Number of lowest-ranking series to keep (positive integer)

Behavior

  1. Statistical evaluation: Computes the specified statistic for each time series over the query window
  2. Ranking: Sorts all series by the statistic values in ascending order (smallest first)
  3. Selection: Keeps only the first K series (those with the smallest statistic values)
  4. Output: Returns the selected time series with their original data, not the statistic values

Examples

Selecting the 2 clusters with the lowest maximum values:

BeforeAfter
name,sps,:eq,
(,nf.cluster,),:by
name,sps,:eq,
(,nf.cluster,),:by,
max,2,:bottomk

Others Aggregation

For including aggregate summaries of the excluded series, use the :bottomk-others-* operators:

  • :topk - Select top K time series (largest values)
  • :limit - Limit results after sorting (different ranking criteria)
  • :sort - Sort time series by statistics
  • :filter - Filter based on statistical criteria
  • :stat - Compute statistics used for ranking

Since: 1.7