http_request_duration_seconds_sum / http_request_duration_seconds_count shows 2 graphs

自古美人都是妖i 提交于 2020-01-25 06:51:16

问题


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).


回答1:


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



来源:https://stackoverflow.com/questions/58725189/http-request-duration-seconds-sum-http-request-duration-seconds-count-shows-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!