1、alertmanager.yml文件
global:
resolve_timeout: 5m
smtp_smarthost: 'smtp.163.com'
smtp_from: '13285921108@163.com'
smtp_auth_username: '13285921108@163.com'
smtp_auth_password: 'xxxxxxxxxx'
wechat_api_url: 'https://qyapi.weixin.qq.com/cgi-bin/'
templates:
- '/usr/local/alertmanager/template/*.tmpl'
route:
group_by: ['instance']
group_wait: 30s
group_interval: 1m
repeat_interval: 5m
routes:
- match:
severity: critical
receiver: allemail - match_re:
severity: ^(informational|warning)$
receiver: supportemail
定义警报接收者信息
receivers:
- name: 'allemail' # 警报
email_configs: # 邮箱配置- to: '13285921108@163.com' # 接收警报的email配置
html: '{{ template "email.html" . }}' # 设定邮箱的内容模板
headers: { Subject: "[WARN] 报警邮件"} # 接收邮件的标题
send_resolved: true
wechat_configs: # 企业微信报警配置 - send_resolved: true
to_party: '1' # 接收组的id
agent_id: '1000002' # (企业微信-->自定应用-->AgentId)
corp_id: '******' # 企业信息(我的企业-->CorpId[在底部])
api_secret: '******' # 企业微信(企业微信-->自定应用-->Secret)
message: '{{ template "wechat.html" . }}' # 发送消息模板的设定
- to: '13285921108@163.com' # 接收警报的email配置
- name: 'supportemail' # 警报
email_configs: # 邮箱配置- to: '13285921108@163.com' # 接收警报的email配置
html: '{{ template "email.html" . }}' # 设定邮箱的内容模板
headers: { Subject: "[WARN] 报警邮件"} # 接收邮件的标题
send_resolved: true
wechat_configs: # 企业微信报警配置 - send_resolved: true
to_party: '1' # 接收组的id
agent_id: '1000002' # (企业微信-->自定应用-->AgentId)
corp_id: '******' # 企业信息(我的企业-->CorpId[在底部])
api_secret: '******' # 企业微信(企业微信-->自定应用-->Secret)
message: '{{ template "wechat.html" . }}' # 发送消息模板的设定
- to: '13285921108@163.com' # 接收警报的email配置
一个inhibition规则是在与另一组匹配器匹配的警报存在的条件下,使匹配一组匹配器的警报失效的规则。两个警报必须具有一组相同的标签。
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
2、访问地址:
http://ip:9093/status
3、收集alertmanager指标
http://ip:9093/metrics
4、警报的3种状态
inactive,
pending
firing
5、以友好方式显示值
{{ humanize $value }}
6、severity:
warning
critical
7、silence:
http://ip:9093/
new silence
8、多个邮件接收人用", "
xx@163.com, yy@163.com
必须用,和空格的组合来区分
网友评论