diff --git a/docs/sources/query/metric_queries.md b/docs/sources/query/metric_queries.md index d3d2efb2714d7..153986c2768e4 100644 --- a/docs/sources/query/metric_queries.md +++ b/docs/sources/query/metric_queries.md @@ -153,3 +153,14 @@ Examples: or vector(0) # will return 0 ``` + +## Probabilistic aggregation + +The `topk` keyword lets you find the largest 1,000 elements in a data stream by sample size. When `topk` hits the maximum series limit, LogQL also supports using a probable approximation; `approx_topk` is a drop-in replacement when `topk` hits the maximum series limit. + +```logql +approx_topk(k, ) +``` + +It is only supported for instant queries and does not support grouping. It is useful when the cardinality of the inner +vector is too high, for example, when it uses an aggregation by a structured metadata label.