在从活动更改为非活动之前延迟 Prometheus 警报
Delay Prometheus alert before changing from active to inactive
我的 Prometheus 设置中有一个警报,当 someMetric > 100
对 5m
有效时发送警报,然后根据以下配置每隔 24h
重新发送警报:
普罗米修斯-alert.yml
- alert: TestAlert
expr: someMetric > 100
for: 5m
alertmanager-config.yml
repeat_interval: 24h
但是 someMetric
有一种行为,它可以 "stable" 高于 100(这意味着警报处于活动状态)但每隔一段时间它会下降到 100 以下,以便之前的一次抓取跳回到 100 以上。这将导致 active 警报变为 inactive(已解决) 然后返回 pending 和 active 5 分钟后再次。这将导致普罗米修斯重新发送警报,这是我想避免的。
有没有办法将 Prometheus 配置为具有类似于 for: 5m
的东西,但对于转换 active -> inactive(已解决)?
在您的示例中,您可以使用 aggregation-over-time promQL 函数之一来 'filter out' 低于 100 的信号?在您的情况下,听起来 max 可能有用吗?唯一的 down-side 是一旦该值永久低于 100,结束警报可能需要几分钟时间。
- alert: TestAlert
expr: max_over_time(someMetric[2m]) > 100
for: 5m
我的 Prometheus 设置中有一个警报,当 someMetric > 100
对 5m
有效时发送警报,然后根据以下配置每隔 24h
重新发送警报:
普罗米修斯-alert.yml
- alert: TestAlert
expr: someMetric > 100
for: 5m
alertmanager-config.yml
repeat_interval: 24h
但是 someMetric
有一种行为,它可以 "stable" 高于 100(这意味着警报处于活动状态)但每隔一段时间它会下降到 100 以下,以便之前的一次抓取跳回到 100 以上。这将导致 active 警报变为 inactive(已解决) 然后返回 pending 和 active 5 分钟后再次。这将导致普罗米修斯重新发送警报,这是我想避免的。
有没有办法将 Prometheus 配置为具有类似于 for: 5m
的东西,但对于转换 active -> inactive(已解决)?
在您的示例中,您可以使用 aggregation-over-time promQL 函数之一来 'filter out' 低于 100 的信号?在您的情况下,听起来 max 可能有用吗?唯一的 down-side 是一旦该值永久低于 100,结束警报可能需要几分钟时间。
- alert: TestAlert
expr: max_over_time(someMetric[2m]) > 100
for: 5m