C.S.
C.S.

Reputation: 87

Get percentage rate between two metrics in a define interval [Prometheus]

I have a question about Prometheus. In my service I have 2 Counters, metric_1 is the total number of requests and metric_2 is the number of failed requests. I need to derive a further metric from these to determine the error rate of requests in terms of percentage in a defined interval (e.g. 2 hours). How can I achieve this through, for example, PromQL?

Upvotes: 2

Views: 3972

Answers (1)

valyala
valyala

Reputation: 17794

Try something like the following:

increase(metric_2[2h]) / increase(metric_1[2h])

See increase() function documention.

It is assumed that metric_1 and metric_2 are counters. If these metrics are gauges, then increase() must be substituted by sum_over_time().

Upvotes: 3

Related Questions