我试图在Prometheus的alert.rules文件中设置一个警报,该警报只在特定时间内触发。我已经测试了下面的代码块,在expr-标记中没有时间限制,它运行得非常好。
如PromQL文档: hour()所述,hour()根据当前的UTC返回介于0到23之间的值。
- 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() < 22替换为and ON() hour() > 5 < 22
发布于 2019-06-03 15:37:53
在本例中,ON()是联接操作,它忽略了来自左侧的匹配标签。否则,普罗米修斯会期望在左边和右边都有相同的标签。您可以阅读更多的在这个博客上。
https://stackoverflow.com/questions/56427808
复制相似问题