我遇到了一些关于普罗米修斯记忆警报的问题。如果我备份Gitlab,那么内存使用率将达到95%。我想要在一个特定的时间提醒记忆。
例如,如果我在凌晨2点进行备份,那么我需要暂停Prometheus内存警报。有可能吗?
发布于 2019-12-04 04:35:41
正如Marcelo所说,没有办法安排静默,但如果备份是定期进行的(比如每晚从凌晨2点到凌晨3点),您可以将其包括在警报表达式中。
- alert: OutOfMemory
expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10 AND ON() absent(hour() >= 2 <= 3)如果您想要使许多规则静默(或者如果您想要更复杂的抑制计划),这会很快变得单调乏味。在这种情况下,您可以通过以下方式使用警报管理器的inhibition rule。
第一步是在Prometheus中定义一个警报,在您想要禁止发生的时间触发:
- alert: BackupHours
expr: hour() >= 2 <= 3
for: 1m
labels:
notification: none
annotations:
description: 'This alert fires during backup hours to inhibit others'请记住在警报管理器中添加路由,以避免通知此警报:
routes:
- match:
notification: none
receiver: do_nothing
receivers:
- name: do_nothing然后使用禁止规则在这段时间内使目标规则静默:
inhibit_rules:
- source_match:
alertname: BackupHours
target_match:
# here can be any other selection of alert
alertname: OutOfMemory请注意,它只适用于UTC计算。如果你需要DST,它需要更多的样板(通过示例记录规则)。
顺便说一句,如果您正在监视备份过程,您可能已经有了一个指示备份正在进行的指标。如果是这样,您可以使用此指标来抑制其他警报,而不需要维护计划。
发布于 2019-12-03 21:46:19
不,不可能有预定的静默。
以下是您的案例的一些解决方法:
1)也许您可以更改Prometheus配置并增加"for“子句,以便在不触发警报的情况下有更多时间执行备份。
2)您可以使用REST API在备份开始/结束时创建/删除静默。
有关此主题的更多信息,请参阅here。
发布于 2020-06-01 02:55:24
您可以比较历史上的条件,因此如果指标在过去两天内的差异不超过2次,则不会弹出警报。
- alert: CPULoadAlert
# Condition for alerting
expr: >-
node_load5 / node_load5 offset 1d > 2 and
node_load5 / node_load5 offset 2d > 2 and
node_load5 > 1
for: 5m
# Annotation - additional informational labels to store more information
annotations:
summary: 'Instance {{ $labels.instance }} got an unusual high load on CPU'
description: '{{ $labels.instance }} of job {{ $labels.job }} got CPU spike over 2x compared to previous 2 days.'
# Labels - additional labels to be attached to the alert
labels:
severity: 'warning'https://stackoverflow.com/questions/59157537
复制相似问题