global:
resolve_timeout: 5m #處理超時時間,默認為5min
smtp_smarthost: 'smtp.sina.com:25' # 郵箱smtp服務器代理
smtp_from: '******@sina.com' # 發送郵箱名稱
smtp_auth_username: '******@sina.com' # 郵箱名稱
smtp_auth_password: '******' # 郵箱密碼或授權碼
wechat_api_url: 'https://qyapi.weixin.qq.com/cgi-bin/' # 企業微信地址
# 定義模板信心
templates:
- 'template/*.tmpl'
# 定義路由樹信息
route:
group_by: ['alertname'] # 報警分組依據
group_wait: 10s # 最初即第一次等待多久時間發送一組警報的通知
group_interval: 10s # 在發送新警報前的等待時間
repeat_interval: 1m # 發送重復警報的周期 對於email配置中,此項不可以設置過低,否則將會由於郵件發送太多頻繁,被smtp服務器拒絕
receiver: 'email' # 發送警報的接收者的名稱,以下receivers name的名稱
# 定義警報接收者信息
receivers:
- name: '<email>' # 警報
-
以上是在網上找到的錯誤演示配置,也不能說絕對錯誤,可能alertmanager版本問題
-
報錯
$ docker logs d1c
level=error ts=2019-08-26T05:52:52.19072198Z caller=main.go:337 msg="Loading configuration file failed" file=/usr/local/prometheus/alertmanager/alertmanager.yml err="yaml: unmarshal errors:\n line 12: field receivers not found in type config.plain"
翻譯過來的意思,就是我寫的那個名字,沒有在route中定義
- 正確配置
global:
resolve_timeout: 5m #處理超時時間,默認為5min
smtp_smarthost: 'smtp.sina.com:25' # 郵箱smtp服務器代理
smtp_from: '******@sina.com' # 發送郵箱名稱
smtp_auth_username: '******@sina.com' # 郵箱名稱
smtp_auth_password: '******' # 郵箱密碼或授權碼
wechat_api_url: 'https://qyapi.weixin.qq.com/cgi-bin/' # 企業微信地址
# 定義模板信心
templates:
- 'template/*.tmpl'
# 定義路由樹信息
route:
group_by: ['alertname'] # 報警分組依據
group_wait: 10s # 最初即第一次等待多久時間發送一組警報的通知
group_interval: 10s # 在發送新警報前的等待時間
repeat_interval: 1m # 發送重復警報的周期 對於email配置中,此項不可以設置過低,否則將會由於郵件發送太多頻繁,被smtp服務器拒絕
receiver: 'email' # 發送警報的接收者的名稱,以下receivers name的名稱
# 定義警報接收者信息
receivers:
- name: 'email' # 警報
完事,另外還有一個報錯信息是permission deny的意思,我這里換了一個alertmanager的鏡像.官方的不一定是最優的
