Skip to content

Commit

Permalink
chore: Document approx_topk keyword. (backport release-3.3.x) (#15347)
Browse files Browse the repository at this point in the history
Co-authored-by: Karsten Jeschkies <[email protected]>
  • Loading branch information
loki-gh-app[bot] and jeschkies authored Dec 10, 2024
1 parent e016f92 commit 98fa930
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/sources/query/metric_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, <vector expression>)
```

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.

0 comments on commit 98fa930

Please sign in to comment.