Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate the number of requests per second using Spring Boot Actuator

I want to calculate the number of requests per second for a particular URL from a Spring Boot 2 application, also the time taken for each request (latency) in milliseconds. We can see the following metrics from Actuator/Prometheus:

http_server_request_config_seconds_count  
http_server_request_config_seconds_sum  

I'm confused how to plot this in Prometheus to get my result. Do I need to add a histogram or quantiles?

like image 971
Anson Francis Avatar asked Dec 23 '22 00:12

Anson Francis


1 Answers

If you only care about the request per seconds, you don't need anything related to the quantiles.

irate(http_server_requests_seconds_count{uri="/your-uri"}[5m])

And if your are interested in the response time overall:

irate(http_server_request_duration_seconds_sum{exception="None", uri = "/your-url"}[5m]) / irate(http_server_requests_duration_seconds_count{exception="None", uri = "/your-url"}[5m])

If you want more precised metrics (quantiles) you can refer to the Prometheus documentation.
e.g:

histogram_quantile(0.99, sum(rate(http_server_requests_seconds_bucket{exception="None", uri = "/your-uri"}[5m])) by (le))
like image 176
Gabriel Dinant Avatar answered Dec 28 '22 08:12

Gabriel Dinant