【发布时间】:2016-06-08 19:57:06
【问题描述】:
我希望 Prometheus 在指标超过特定阈值时从 Gmail (Gapps) 帐户发送电子邮件。 在Alertmanager config docs 中,没有提到密码。如何对 SMTP 服务器进行身份验证?
【问题讨论】:
标签: smtp gmail smtp-auth prometheus
我希望 Prometheus 在指标超过特定阈值时从 Gmail (Gapps) 帐户发送电子邮件。 在Alertmanager config docs 中,没有提到密码。如何对 SMTP 服务器进行身份验证?
【问题讨论】:
标签: smtp gmail smtp-auth prometheus
这可以通过配置文件中的auth_username、auth_password 和auth_identity 字段来完成。
http://www.robustperception.io/sending-email-with-the-alertmanager-via-gmail/ 有完整指南
确保您使用的是最新的警报管理器,0.1.1 将无法工作。
【讨论】:
note,将环境变量用于机密信息(例如应用程序密码/令牌)是违反最佳实践的。 @brian-brazil 的文章将在编写配置时更改变量。
您可以在警报管理器配置文件中使用以下模板,并根据您的要求更改值。
config:
global:
resolve_timeout: 5m
route:
group_by: ['job']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h
receiver: 'tech-email'
routes:
- match:
alertname: Watchdog
receiver: 'null'
receivers:
- name: 'tech-email'
email_configs:
- to: 'to-email@example.com'
from: 'from-email@outlook.com'
auth_username: **********
auth_password: **********
require_tls: yes
smarthost: **********
send_resolved: true
- name: 'null'
对于 auth_username、auth_password 和 smarthost,您可以从 SES 或任何提供商生成凭据。
【讨论】: