promql - what is promql for calcuate percetile

138 views
Skip to first unread message

Prashant Singh

unread,
Mar 20, 2023, 4:47:46 AM3/20/23
to Prometheus Users
Hi , 

Need to be know what is promql for calculate p50th ,p90th , and p99th latency or perctile for bleow metrics

Note - I have no bucket metrics for histogram. 


# HELP prometheus_rule_evaluation_duration_seconds The duration for a rule to execute.
# TYPE prometheus_rule_evaluation_duration_seconds summary
prometheus_rule_evaluation_duration_seconds{quantile="0.5"} 6.4853e-05
prometheus_rule_evaluation_duration_seconds{quantile="0.9"} 0.00010102
prometheus_rule_evaluation_duration_seconds{quantile="0.99"} 0.000177367
prometheus_rule_evaluation_duration_seconds_sum 1.623860968846092e+06
prometheus_rule_evaluation_duration_seconds_count 1.112293682e+09

Thanks
Prashant
Thanks,
Prashant

Brian Candler

unread,
Mar 20, 2023, 6:28:50 AM3/20/23
to Prometheus Users
> Note - I have no bucket metrics for histogram. 

What you say doesn't make sense to me.  What you showed *is* a histogram, and the metrics prometheus_rule_evaluation_duration_seconds *are* the buckets.

Therefore, if those are the metrics you have, then the 50th percentile is simply
prometheus_rule_evaluation_duration_seconds{quantile="0.5"}
and the 90th percentile is simply
prometheus_rule_evaluation_duration_seconds{quantile="0.9"}

There is no need to "calculate" the p50/p90/p99 latencies because you already have them.

Bjoern Rabenstein

unread,
Mar 27, 2023, 8:59:52 AM3/27/23
to Brian Candler, Prometheus Users
On 20.03.23 03:28, Brian Candler wrote:
> > Note - I have no bucket metrics for histogram.
>
> What you say doesn't make sense to me. What you showed *is* a histogram,
> and the metrics *prometheus_rule_evaluation_duration_seconds* *are* the
> buckets.

Strictly speaking, it's a summary, and the metrics labeled with
"quantile" are precalculated
quantiles. Cf. https://prometheus.io/docs/practices/histograms/

> Therefore, if those are the metrics you have, then the 50th percentile is
> simply
> prometheus_rule_evaluation_duration_seconds{quantile="0.5"}
> and the 90th percentile is simply
> prometheus_rule_evaluation_duration_seconds{quantile="0.9"}
>
> There is no need to "calculate" the p50/p90/p99 latencies because you
> already have them.

That's correct. Note that there is no way to further aggregate the
pre-calculated quantile (or change them for example to a different
quantile or to a different time interval).

If you need aggregatability or more flexibility for add-hoc queries,
you have to use an actual histogram in your instrumentation of the
monitored target (either the classic histograms or the new
experimental native histograms).

--
Björn Rabenstein
[PGP-ID] 0x851C3DA17D748D03
[email] bjo...@rabenste.in
Reply all
Reply to author
Forward
0 new messages