简体   繁体   中英

Calculating average using a Histogram metric

I am generating a Histogram using a prometheus client. The metric name is retrieve_stripe_subscription_latency_ms . Since Histogram generates additional metrics with suffixes _sum and _count , can I calculate the average using the below query in Grafana?

sum(retrieve_stripe_subscription_latency_ms_sum)/sum(retrieve_stripe_subscription_latency_ms_count)

I think official Prometheus documentation address this. Having your metric name:

To calculate the average [...put here a metric meaning...] during the last 5 minutes from a histogram or summary called retrieve_stripe_subscription_latency_ms , use the following expression:

 rate(retrieve_stripe_subscription_latency_ms_sum[5m]) / rate(retrieve_stripe_subscription_latency_ms_count[5m])

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