我有Prometheus警报管理器和简单的规则
>
job_name:Host_PROstatic_configs:
job_name:"Host_PRE"static_configs:
global:
# The smarthost and SMTP sender used for mail notifications.
smtp_smarthost: 'example:587'
smtp_from: 'example'
smtp_auth_username: 'example'
smtp_auth_password: 'example'
smtp_require_tls: true
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 24h
routes:
- match:
group: alert
receiver: mail
receivers:
- name: 'mail'
email_configs:
- to: 'example@gmail.com'
- alert: NodeCPU_0_High
expr: 100 - (avg by(instance, cpu) (irate(node_cpu_seconds_total{mode="idle", cpu="0"}[1m])) * 100) > 80
for: 2m
labels:
severity: critical
app_type: linux
category: cpu
annotations:
summary: "Node CPU_0 usage is HIGH"
description: "CPU_0 load for instance {{ $labels.instance }} has reached {{ $value }}%"
如何仅在组“警报”为高的主机时发送电子邮件?
在alertmanager. yml文件中设置以下内容:
route:
...
routes:
- receiver: none
matchers:
- group != alert
- receiver: mail
matchers:
- group = alert
receivers:
- name: none
- name: 'mail'
email_configs:
- to: 'example@gmail.com'