I have a Grafana dashboard, where I try to plot some of the prometheus metrics.
I am trying to calculate the average response time for 2 endpoints using the formula:
http_request_duration_seconds_sum / http_request_duration_seconds_count
but when plotting the query into the Grafana graph panel, I get 4 graphs (2 for each) instead of only 2, which I don't understand.
Can anyone tell me, why there are 4 curves instead of 2? The two on the top are from the same query and likewise for the two in the buttom.
UPDATE
Is adding
sum(rate(http_request_duration_sum))[24h] / sum(rate(http_request_duration_count))[24h]
the answer? That gives me 2 curves instead of 4, but not sure if the result is what I am looking for (being the average response time for the endpoint).
I found out that the following query:
sum(rate(http_request_duration_sum))[24h] / sum(rate(http_request_duration_count))[24h]
is the answer, I am looking for, giving me the average response time in seconds and only 1 curve pr query.
Of course the scrape_interval should not be 24h, so I've set it to [1m] instead. <- this according to this SO-answer