gpt4 book ai didi

prometheus - 如何使用 PromQL 的 hour() 函数?

转载 作者:行者123 更新时间:2023-12-04 13:18:59 25 4
gpt4 key购买 nike

我试图在 Prometheus 的 alert.rules 文件中设置一个仅在特定时间段内触发的警报。
我已经测试了下面的代码块,在 expr-tag 中没有时间限制,它工作得非常好。
PromQL Documentation: hour()州, hour()返回 0 到 23 之间的值,具体取决于当前的 UTC。

- alert: test_down 
expr: absent(container_memory_usage_bytes{name="test_ap"}) and hour() > 5 and hour() < 22
for: 30s
labels:
severity: critical
annotations:
summary: "test_ap down"
description: "test_ap is down for more than 30 seconds."
但在这里,不会触发警报通知。有谁知道,为什么没有被解雇,我该如何解决?
编辑:我已经解决了。我不明白为什么我必须像我这样做的方式那样做,但以下方法有效:
替换 and hour() > 5 and hour() < 22and ON() hour() > 5 < 22

最佳答案

在这种情况下, ON() 它是连接操作,它忽略来自左侧部分的匹配标签。否则,Prometheus 会期望左侧和右侧的标签集相同。您可以阅读更多 in this blogpost .

关于prometheus - 如何使用 PromQL 的 hour() 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56427808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com