Skip to content

head

Input Stack:
n: Int
expr: TimeSeriesExpr
Output Stack:
TimeSeriesExpr
 

Limit the number of time series to the first N series. This is an alias for the :limit operator that exists primarily for historical reasons and backwards compatibility. It's useful for focusing on the top results when dealing with large result sets.

Parameters

  • expr: A time series expression that may contain multiple series
  • n: The maximum number of time series to keep (integer)

Examples

Limit grouped results to show only the first 2 clusters:

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

This takes all the series grouped by cluster and keeps only the first 2 series in the result.

  • :limit - Equivalent operation (:head is an alias for :limit)
  • :sort - Order series before limiting (often used together)
  • :by - Group series (commonly used before limiting)
  • :topk - Select top N based on values rather than position