Skip to main content

topk

Function topk 

Source
pub fn topk(
    k: f64,
    top: bool,
    grouping: &Grouping,
    schema: &SeriesSchema,
    series: &[Series],
) -> Result<Vec<Series>>
Expand description

topk(k, ...) (top) or bottomk(k, ...) with a constant k.

At every point each group keeps the k largest (or smallest) values, NaN ranking last for both; the selected samples keep their series’ labels and values. Histogram samples are not ranked, as Prometheus ignores them here. Prometheus breaks ties by the order its storage returns series in, which is not a property of the series; here ties go to the series whose label set sorts first.