eng007
eng007

Reputation: 123

Can you apply a limit on promQL query?

For example:

Avg by (server) (HttpStatusCodes{category = 'Api.ResponseStatus'}) limit 10

Is this valid in promQl? I can not find anything about it in the documentation. Thanks

Upvotes: 5

Views: 12565

Answers (1)

valyala
valyala

Reputation: 17800

The provided query is valid MetricsQL query for VictoriaMetrics, but unfortunately it doesn't work in the original PromQL.

Prometheus provides topk and bottomk operators, which can be used for limiting the number of returned time series. Unfortunately, these operators limit the number of returned time series on a per-point basis (considering points on the graph). This means that the total number of returned time series may exceed the requested limit. MetricsQL solve this issue with a family of topk_* and bottomk_* functions. See MetricsQL docs for details.

Upvotes: 5

Related Questions