Kibana 如何计算上周同一时间的平均值?

tuwxkamq  于 2023-04-10  发布在  Kibana
关注(0)|答案(1)|浏览(92)

我想看看是否有流量下降比较的平均值为给定的时间.例如,如果在下午6时的当前负载是10000 RPS,我想比较当前负载与平均6PM数据点在过去7天.平均在过去7天将是不正确的,因为我们有高峰时间和低时间.
在prometheus中有没有办法计算前7天相同数据点的平均值?
到目前为止,我尝试的是查询当前RPS:

sum(rate(kong_http_requests_total{}[5m]))

查询最近三天的RPS平均值

(sum(rate(kong_http_requests_total{}[5m] offset 1d))  + sum(rate(kong_http_requests_total{}[5m] offset 2d))  + sum(rate(kong_http_requests_total{}[5m] offset 3d)) /3

有什么函数可以计算这个吗?理想情况下,我想计算过去7天的这个。

hrirmatl

hrirmatl1#

您的查询对于所需的输出是正确的。
唯一的不足是,你可以将总和应用于加起来的费率,而不是单独的。

sum(
  rate(kong_http_requests_total{}[5m] offset 1d) +
  rate(kong_http_requests_total{}[5m] offset 2d) +
  rate(kong_http_requests_total{}[5m] offset 3d) +
  rate(kong_http_requests_total{}[5m] offset 4d) +
  rate(kong_http_requests_total{}[5m] offset 5d) +
  rate(kong_http_requests_total{}[5m] offset 6d) +
  rate(kong_http_requests_total{}[5m] offset 7d)
) / 7

未提供用于此类计算的内置功能。

相关问题