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?
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().