使用直方图度量计算平均值

5
我正在使用Prometheus客户端生成直方图。指标名称为retrieve_stripe_subscription_latency_ms。由于Histogram会生成带有后缀_sum_count的附加指标,我是否可以使用以下Grafana查询计算平均值?sum(retrieve_stripe_subscription_latency_ms_sum)/sum(retrieve_stripe_subscription_latency_ms_count)
1个回答

9

我认为官方Prometheus文档已经涉及了这个问题。有了你的指标名称:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接