Calculate Response time from micrometer prometheus

Viewed 41

I want to calculate response time for my micrometer application which uses prometheus . We are displaying it on new relic dashboard. Have written this new relic query is it correct to calculate response time.

SELECT rate(sum(http_server_requests_seconds_sum), 1 second)/rate(sum(http_server_requests_seconds_count), 1 second) as 'Response time'

FROM Metric

1 Answers

I think you've potentially got it the wrong way around

SELECT (rate(sum(http_server_requests_seconds_count), 1 second)/rate(sum(http_server_requests_seconds_sum), 1 second)) as 'Response time' FROM Metric

If I have 100 requests that take a sum total of 1000 seconds. It would appear I have a response time of 0.1 by your original formula. But that's not right. 100 x 0.1 = 10.

However, 1000/100 = 10 seconds per call on average. 100 calls x 10 seconds a call is 1000. So inverting your logic may be all you need to get a more accurate result.

Related