【转帖】Prometheus AlertManager 微信报警配置

时间:2020-01-20 10:02:30   收藏:0   阅读:475

Prometheus AlertManager 微信报警配置

https://segmentfault.com/a/1190000015400227

改天尝试一下

 

 阅读约 5 分钟

Prometheus AlertManager 微信报警配置

alertmanager支持email,webhook等报警源支持,看到可以支持微信报警信息推送觉得有意思把玩一下,alertmanager0.15版本微信报警推送有问题,后来我把版本降到0.14后微信就能正常收到报警信息

微信企业号申请

Prometheus中AlertManager配置

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - localhost:9093
rule_files:
   - "/usr/local/prometheus/rules.yml"

Prometheus rules配置

groups:
- name: prometheus_go_goroutines
  rules:
  - alert: go_goroutines_numbers
    expr: go_goroutines > 45
    for: 15s
    annotations:
      summary: "prometheus的gorotine数据超过40!"

Prometheus 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_urlwechat对外接口https://qyapi.weixin.qq.com/cgi-bin/
wechat_api_secret: 企业微信("企业应用"-->"自定应用"[Prometheus]--> "Secret") Prometheus是本人自创建应用名称
wechat_api_corp_id: 企业信息("我的企业"--->"CorpID"[在底部])
to_party1值是组的ID 你可通过链接去定制报警信息接收人或者组(https://work.weixin.qq.com/ap...
agent_id: 企业微信("企业应用"-->"自定应用"[Prometheus]--> "AgentId") Prometheus是本人自创建应用名称

异常列表

报警信息推企业微信异常 invalid APISecret for CorpID

异常信息如下:

level=error ts=2019-06-20T08:33:42.779286895Z caller=dispatch.go:264 component=dispatchermsg="Notify for alerts failed" num_alerts=1 err="cancelling notify retry for \"wechat\"due to unrecoverable error: invalid APISecret for CorpID: xxxxxxxxxxx"

本人微信: 375419830

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!