【问题标题】:Prometheus tumbling window aggrgeates普罗米修斯翻滚窗口聚合
【发布时间】:2019-06-21 08:19:09
【问题描述】:

我想获得特定时间范围内的聚合数据。例如。每小时,每天,但每小时从例如09:00-10:00(翻转窗口),而不是 1 小时前(跳跃窗口)。

如果我们可以减去由可变时间偏移的计数器,那将是可能的,例如:

x_count offset (minutes()m) - x_count offset ((minutes()+60)m) 但 offset 似乎没有评估函数。

关于如何做到这一点的建议?

【问题讨论】:

  • 否决票是否意味着这在普罗米修斯中不可行?

标签: prometheus promql


【解决方案1】:

您可以将timestamp() 函数与hour()day_of_month() 结合使用,以过滤落在给定小时/天内的样本;或与time() 结合使用以过滤当前小时/天内的样本。

这是一个让您入门的脑筋急转弯:

up{job="prometheus"} + ignoring(year, month, day_of_month) group_right
  count_values without() ("year", year(timestamp(
    count_values without() ("month", month(timestamp(
      count_values without() ("day_of_month", day_of_month(
        timestamp(up{job="prometheus"}
      )))
    )))
  ))) * 0

这将为每个yearmonthday_of_month 标签组合创建单独的指标。然后,您可以通过这些指标avg_over_time(或任何_over_time);或按年、月、日汇总。 rate() 之类的东西会比较棘手,因为您可能需要在短距离(例如 1 分钟)内计算 rate(),然后随着时间的推移对其进行平均,因此您需要记录规则或 subqueries

【讨论】:

  • 天哪,我会试试的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-22
  • 1970-01-01
  • 2017-09-03
  • 2022-10-17
相关资源
最近更新 更多