Catalin M
Catalin M

Reputation: 31

How to calculate prometheus procentage from the sums of 2 rates

I'm using Grafana with prometheus datasource and I'm unable to calculate a success ration from 2 sums of rates. For example I have sum by (application) (rate(http_request_path_endpoint_responses{application="service1",request_path="/otp"}[5m])) / sum by (application) (rate(http_request_path_endpoint_responses{application="service1",request_path="/session"}[5m]))

it doesn't return anything

Each of them works just fine and it produces the expected values but I can't divide them in order to get the ratio. Any idea? Thanks

Upvotes: 0

Views: 213

Answers (1)

Catalin M
Catalin M

Reputation: 31

Yes, as suggested by Saf using ignoring() or on() does the trick. so sum by (application) (rate(http_request_path_endpoint_responses{application="service1",request_path="/otp"}[5m])) / ignoring(request_path) sum by (application) (rate(http_request_path_endpoint_responses{application="service1",request_path="/session"}[5m])) worked

Upvotes: 1

Related Questions