本文介绍了Prometheus Query 一个时间间隔内的整体平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到时间间隔内指标的总体平均值?

How can I find the overall average of metrics over time interval ?

avg(metric) = 总体平均值但是

avg_over_time(metrics[interval]) = 每个标签的平均值

avg(avg_over_time(metric[scrape interval])) 不会与相同(当数据不连续且分母值不同时)平均(公制) !!!!!!

avg( avg_over_time(metric[scrape interval]) ) won't be same as(when the data is not continuous and denominator value is different) avg(metric) !!!!

给定一个场景,找出一段时间内整体平均值的可能方法是什么.

Given a scenario, what will be the possible way to find the overall average over a time period.

例如:求现在的平均响应时间和过去一小时内触发的所有请求的平均响应时间(总的).

Eg: Find the average response time now and Find the average response time(over all) of all the request triggered in last one hour.

数字将有助于通知最新升级的性能问题.

The number will be helpful to notify a performance issue with latest upgrades.

推荐答案

你需要手动计算更多的平均值:

You need to calculate the average a bit more manually:

    sum(sum_over_time(metric[interval]))
/
    sum(count_over_time(metric[interval]))

请注意,这是针对仪表中的数据,您需要对计数器或摘要中的数据采用不同的方法.

Note that this is for data in a gauge, you'd need a different approach for data from a counter or summary.

这篇关于Prometheus Query 一个时间间隔内的整体平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:25