Prometheus AlertManager 微信報警配置

Prometheus AlertManager 微信報警配置

alertmanager支持email,webhook等報警源支持,看到能夠支持微信報警信息推送以爲有意思把玩一下,alertmanager0.15版本微信報警推送有問題,後來我把版本降到0.14後微信就能正常收到報警信息web

微信企業號申請

  • 微信企業號申請地址(https://work.weixin.qq.com/)
  • 進入企業號註冊頁面,一些信息能夠隨便填寫,可是管理員信息必須真實有效
  • 建立應用("企業應用"-->"建立應用")

Prometheus中AlertManager配置

  • Prometheus AlertManager配置以下,alertingglobal同級
# 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: 375419830c#

相關文章
相關標籤/搜索