目录
前提
已配置Prometheus告警规则: Prometheus 配置文件详解(告警规则)
#默认配置
receivers,它定义了告警的处理方式:alertmananger将告警转发到这个url。
alertmanager提供多种告警处理方式,webhook_configs只是其中一种,还是如下多种方式:
email_config
hipchat_config
pagerduty_config
pushover_config
slack_config
opsgenie_config
victorops_config
webhook_config
wechat_config
# 邮件告警
alertmanager配置邮件通知告警例子:
global:
smtp_smarthost: 'mail.xxx.cn:25' #邮箱smtp服务器
smtp_from: 'ops@xxx.cn' #发件用的邮箱地址
smtp_auth_username: ' ops@xxx.cn' #发件人账号
smtp_auth_password: 'xxxxx' #发件人邮箱密码
smtp_require_tls: false #不进行tls验证
route:
group_by: [alertname]
group_wait: 10s
group_interval: 10s
repeat_interval: 10m
receiver: default-receiver
receivers:
- name: 'default-receiver'
email_configs:
- to: 'abc@aaa.com' #接收告警用的邮箱
alertmanager.yml文件配置完成后,重启alertmanager服务重新加载配置后,就可以测试邮件告警功能了。
邮件效果