I have a Spring boot app throwing out open metric stats using micrometer.
For each of my HTTP endpoints, I can see the following metric which I believe tracks the number of requests for the given endpoint:
http_server_requests_seconds_count
My question is how do I use this in a Grafana query to present the number number of requests calling my endpoint say every minute?
I tried
http_client_requests_seconds_count{}
and
sum(rate(http_client_requests_seconds_count{}[1m]))
but neither work.
Thanks in advance.
rate(http_client_requests_seconds_count{}[1m])
will provide you the number of request your service received at a per-second rate.
However by using [1m]
it will only look at the last minute to calculate that number, and requires that you collect samples at a rate quicker than a minute. Meaning, you need to have collected 2 scrapes in that timeframe.
increase(http_client_requests_seconds_count{}[1m])
would return how much that count increased in that timeframe, which is probably what you would want, though you still need to have 2 data points in that window to get a result.
Other way you could accomplish your result:
increase(http_client_requests_seconds_count{}[2m]) / 2
By looking over 2 minutes then dividing it, you will have more data and it will flatten spikes, so you'll get a smoother chart.
rate(http_client_requests_seconds_count{}[1m]) * 60
By multiplying the rate
by 60 you can change the per-second rate to a per-minute value.
Here is a writeup you can dig into to learn more about how they are calculated and why increases might not exactly align with integer values: https://promlabs.com/blog/2021/01/29/how-exactly-does-promql-calculate-rates
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With