I am looking at this article. It mentions below query with below description.
It is even more interesting monitoring the error rate vs the total amount of requests, this way you get the magnitude of the errors for the Kubernetes API server requests.
sum(rate(apiserver_request_total{job="kubernetes-apiservers",code=~"[45].."}[5m]))*100/sum(rate(apiserver_request_total{job="kubernetes-apiservers"}[5m]))
What I don't understand is why can we just compute below? Moreover, what is the purpose of applying sum function after rate? My understanding is rate is the average change per second, why sums the changes up? Can I get help on understanding the above query, it would be great to have an concrete example. Thanks in advance!
count(apiserver_request_total{job="kubernetes-apiservers",code=~"[45].."})/count(apiserver_request_total{job="kubernetes-apiservers"})