Prometheus AlertManager 微信报警配置
alertmanager
支持email,webhook等报警源支持,看到可以支持微信报警信息推送觉得有意思把玩一下,alertmanager
的0.15
版本微信报警推送有问题,后来我把版本降到0.14
后微信就能正常收到报警信息
微信企业号申请
- 微信企业号申请地址(https://work.weixin.qq.com/)
- 进入企业号注册页面,一些信息可以随便填写,但是管理员信息必须真实有效
- 创建应用("企业应用"-->"创建应用")
Prometheus中AlertManager配置
-
Prometheus AlertManager
配置如下,alerting
与global
同级
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
-
rules
配置文件加入到Prometheus
配置文件中
rule_files:
- "/usr/local/prometheus/rules.yml"
Prometheus rules配置
- 创建
rule.yml
文件 - 根据需求添加报警规则
groups:
- name: prometheus_go_goroutines
rules:
- alert: go_goroutines_numbers
expr: go_goroutines > 45
for: 15s
annotations:
summary: "prometheus的gorotine数据超过40!"
Prometheus AlertManager配置
-
alertmanager
配置文件,加入微信配置信息
global:
resolve_timeout: 2m
wechat_api_url: 'https://qyapi.weixin.qq.com/cgi-bin/'
wechat_api_secret: 'xxx'
wechat_api_corp_id: 'xxx'
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'wechat'
receivers:
- name: 'wechat'
wechat_configs:
- send_resolved: true
to_party: '1'
agent_id: '1000002'
wechat_api_url
: wechat
对外接口https://qyapi.weixin.qq.com/cgi-bin/
wechat_api_secret
: 企业微信("企业应用"-->"自定应用"[Prometheus
]--> "Secret") Prometheus
是本人自创建应用名称wechat_api_corp_id
: 企业信息("我的企业"--->"CorpID"[在底部])to_party
: 1
值是组的ID
你可通过链接去定制报警信息接收人或者组(https://work.weixin.qq.com/ap...agent_id
: 企业微信("企业应用"-->"自定应用"[Prometheus
]--> "AgentId") Prometheus
是本人自创建应用名称
本人QQ: 375419830