简体   繁体   中英

Average response time on Grafana from Prometheus

I am trying to find the average response time of all the URLs in Grafana,

The below query not returning any data, what am I doing wrong here?

    avg by (uri) (rate(http_server_requests_seconds_sum{app_name="$app",
                  namespace="$namespace", uri!~".*actuator.*|/health|root"}[1m]) 
   /rate(http_server_requests_seconds_count{app_name="$app",
                  namespace="$namespace", uri!~".*actuator.*|/health|root"}[1m]))

The data is collected via a micrometer.

If you want to get the average then you should divide the _sum by the _count counter. If your labels are ok, then you will get data(if there any) by below PromQL.

sum by (uri) (rate(http_server_requests_seconds_sum{app_name="$app", 
            namespace="$namespace", uri!~".*actuator.*|/health|root"}[1m])) 
/ sum by (uri) (rate(http_server_requests_seconds_count{app_name="$app",
            namespace="$namespace", uri!~".*actuator.*|/health|root"}[1m]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM