Prometheus 监控之alertmanager 路由配置

#通过配置alertmanager 路由,来实现 不同的告警等级 发给不同的接收对象

global:

smtp_smarthost: 'smtp.163.com:25'

smtp_from: '13057531912@163.com'

smtp_auth_username: '13057531912@163.com'

smtp_auth_password: 'FDSAFDFDSFASDFSDFWEWE'

smtp_require_tls: false

route:

receiver: 'default-receiver-mail'

group_by: [instance,alertname]

group_wait: 10s

group_interval: 10s

repeat_interval: 1h

routes:

- receiver: 'database-pager'

match:

job: mysql

- receiver: 'admin_SRE'

match_re:

severity: waring|critical

templates:

- '/etc/alertmanager/template/email.tmpl'

receivers:

- name: 'default-receiver-mail'

email_configs:

- to: '974907350@qq.com'

html: '{{ template "email.html" . }}'

headers: { Subject: "[WARN] Prometheus 告警邮件" }

- name: 'database-pager'

email_configs:

- to: '3245386243@qq.com,974907350@qq.com'

html: '{{ template "email.html" . }}'

headers: { Subject: "[WARN] Prometheus 告警邮件" }

- name: 'admin_SRE'

email_configs:

- to: 'hjk13057531912@126.com,974907350@qq.com'

html: '{{ template "email.html" . }}'

headers: { Subject: "[WARN] Prometheus 告警邮件" }

 

==============================================

配置文件详解

global:

smtp_smarthost: ‘smtp.163.com:25’

smtp_from: ‘13057531912@163.com’

smtp_auth_username: ‘13057531912@163.com’

smtp_auth_password: ‘FDSAFDFDSFASDFSDFWEWE’

smtp_require_tls: false

route:

receiver: ‘default-receiver-mail’ #设置告警默认接收者

group_by: [instance,alertname] #根据 labael(标签)进行匹配,如果是多个,就要多个都匹配

group_wait: 10s #等待该组的报警,看有没有一起合伙搭车的

group_interval: 10s #下一次报警开车时间

repeat_interval: 1h #重复报警时间

routes:

– receiver: ‘database-pager’ #匹配标签名为job,值为mysql的告警,并把告警发送给”database-pager”接收者

match: #匹配标签

job: mysql

– receiver: ‘admin_SRE’ #正则匹配标签名为severity(告警等级),值为 waring 或 critical ,并把告警发送给”admin_SRE”接收者

match_re: #正则匹配标签

severity: waring|critical

templates:

– ‘/etc/alertmanager/template/email.tmpl’ #定义的邮件告警的模板路径

receivers:

– name: ‘default-receiver-mail’

email_configs:

– to: ‘974907350@qq.com’ #默认接收者邮件地址,当没有匹配上上面的所有标签,默认兜底策略

html: ‘{{ template “email.html” . }}’

headers: { Subject: “[WARN] Prometheus 告警邮件” } #邮件主题

– name: ‘database-pager’

email_configs:

– to: ‘3245386243@qq.com,974907350@qq.com’ #可以定义多个邮件地址,中间使用逗号隔开 (匹配标签名为job,值为mysql的告警,都发送到这两个邮件地址上)

html: ‘{{ template “email.html” . }}’

headers: { Subject: “[WARN] Prometheus 告警邮件” } #邮件主题

– name: ‘admin_SRE’

email_configs:

– to: ‘hjk13057531912@126.com,974907350@qq.com’ #可以定义多个邮件地址,中间使用逗号隔开 (正则匹配标签名为severity(告警等级),值为 waring 或 critical的告警,都发送到这两个邮件地址上)

html: ‘{{ template “email.html” . }}’

headers: { Subject: “[WARN] Prometheus 告警邮件” } #邮件主题

邮件告警展示:

Prometheus 监控之alertmanager 路由配置

Prometheus 监控之alertmanager 路由配置

Prometheus 监控之alertmanager 路由配置

本文版权归 飞翔沫沫情 作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出 原文链接 如有问题, 可发送邮件咨询,转贴请注明出处:https://www.fxkjnj.com/2514/

发表评论

登录后才能评论