PromQL Grafana percentage

I ran into a small problem and can’t find a solution.

Grafana has a dashboard that is built on demand


You need to make an Alert. Now the first part of the request is the creation time in seconds, the second part is the number of requests themselves.

Alert should be of the form, if the number of create lasting more than 3 seconds exceeds 5% of the total number of create in 15 minutes - then Alert. Tell me, please, where to dig, where to look?

I tried many options, but it’s not the same.

Hello! I think the following topic on SO is relevant prometheus - PromQL Grafana percentage - Stack Overflow

Have you tried MetricsQL function histogram_share?

histogram_share(3, increase(http_request_duration_seconds_bucket[15m])) < 0.95

Please try suggested query above in your alerting rule. It should trigger when more than 5% of requests took more than 3 seconds during the last 15 minutes.

1 Like

Thanks, all worked well!