How can i use vmrange label for calculate Percentage of requests less equal 500ms

88 Views Asked by At

I'm testing switching from prometheus to using victoria metrics. In prometheus, my promQL: (sum(rate(demo_service_request_duration_seconds_bucket{le=\"0.5\"}[5m])) by (exported_job) / sum(rate(demo_service_request_duration_seconds_count[5m])) by (exported_job))

And display like this:

enter image description here

But in victoria metrics not have "le" label to use.

How can i convert from old promQL for new promQL use vmrange label.

Tksssssss so much !!!!!

1

There are 1 best solutions below

0
On

Try the following MetricsQL query:

histogram_share(0.5,
  sum(
    rate(demo_service_request_duration_seconds_bucket[5m])
  ) by (vmrange, exported_job)
)

It uses histogram_share function for returning the share of requests with the duration smaller or equal to 0.5 seconds during the last 5 minutes (see 5m in square brackets). The share is returned individually per each exported_job. Every share is returned in the range [0...1], where 0 means 0% of requests and 1 means 100% of requests.