admin管理员组

文章数量:1296246

I have nginx ingress controller installed in Kubernetes cluster along with Prometheus and Grafana, I was exploring the Nginx Ingress controller dashboard that comes with the controller which has some very useful charts.

One chart that caught my attention is the service success rate which counts the percentage of requests that were successful (non 4xx or 5xx status codes returned). They count this metric as (simplified):

 sum(rate(nginx_ingress_controller_requests{cluster=~"$cluster", status!~"[4-5].*"}[2m])) by (ingress) 
/
sum(rate(nginx_ingress_controller_requests{cluster=~"$cluster"}[2m])) by (ingress)

I am confused why they would take the sum of the rate in this case instead of just summing over the counter nginx_ingress_controller_requests, since by definition:

success rate = sum of successful requests/sum of total requests

It sounds more intutitive to drop the rate and sum over the counter. I would appreciate anyone who can help me understand this.

本文标签: Calculating the success rate of nginx requests in Prometheus sum of rate vs sum of counterStack Overflow