集成邮件系统

在 Alertmanager 使用邮箱通知,只需要定义好 SMTP 相关的配置,并且在 receiver 中定义接收方的邮件地址即可。

global:
  [ smtp_from: <tmpl_string> ]
  [ smtp_smarthost: <string> ]
  [ smtp_hello: <string> | default = "localhost" ]
  [ smtp_auth_username: <string> ]
  [ smtp_auth_password: <secret> ]
  [ smtp_auth_identity: <string> ]
  [ smtp_auth_secret: <secret> ]
  [ smtp_require_tls: <bool> | default = true ]

完成全局 SMTP 之后,还需要为 receiver 配置 email_configs,定义一组接收告警的邮箱地址,如下所示:

name: <string>
email_configs:
  [ - <email_config>, ... ]

每个 email_config 中定义相应的接收人邮箱地址、邮件通知模板等信息,如果当前接收人需要单独的 SMTP 配置,那直接在 email_config 中进行覆盖。

[ send_resolved: <boolean> | default = false ]
to: <tmpl_string>
[ html: <tmpl_string> | default = '{{ template "email.default.html" . }}' ]
[ headers: { <string>: <tmpl_string>, ... } ]
  • 如果当前收件人需要接受告警恢复(global 中的 resolve_timeout)的通知的话,在 email_config 中定义send_resolved为 true。

  • 如果所有的邮件配置使用了相同的 SMTP 配置,则可以直接定义全局的 SMTP 配置。

最后更新于