alertmanager接微信

alertmanger 配置:

global:
  resolve_timeout: 2m
# 邮箱  
smtp_smarthost: 'smtp.qiye.aliyun.com:465'
  smtp_from: 'your_email'
  smtp_auth_username: 'your_email'
  smtp_auth_password: 'passwd'
  smtp_hello: 'your_email'
  smtp_require_tls: false

# 微信模版
templates:
  - '/var/lib/alertmanager/wechat.tmpl'
route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 5m
  receiver: wechat 

  routes:
  - receiver: email
    match_re:
      serverity: email
    group_wait: 10s

receivers:
# 微信
- name: 'wechat'
  wechat_configs:
    - corp_id: '企业ID'
      to_party: '部门ID'
      agent_id: '1000002'
      api_secret: 's2yqcDSLo6y81j6ONsztxUj_qeZQ3OoefCZzxDBqcrc'
      send_resolved: true

# 钉钉
- name: 'dingding'
  webhook_configs:
  - url: http://localhost:8060/dingtalk/webhook1/send  
    send_resolved: true

# email
- name: 'email'
  email_configs:
  - to: 'email@test.com'
    send_resolved: true

微信报警模版:

{{ define "wechat.default.message" }}
{{ range $i, $alert :=.Alerts }}
========监控报警==========
告警状态:{{   .Status }}
告警级别:{{ $alert.Labels.severity }}
告警类型:{{ $alert.Labels.alertname }}
告警应用:{{ $alert.Annotations.summary }}
告警主机:{{ $alert.Labels.instance }}
告警详情:{{ $alert.Annotations.description }}
触发阀值:{{ $alert.Annotations.value }}
告警时间:{{ $alert.StartsAt.Format "2006-01-02 15:04:05" }}
========end=============
{{ end }}
{{ end }}

参数说明:
corp_id: 企业微信账号唯一 ID, 可以在我的企业中查看。
to_party: 需要发送的组。
agent_id: 第三方企业应用的 ID,可以在自己创建的第三方企业应用详情页面查看。
api_secret: 第三方企业应用的密钥,可以在自己创建的第三方企业应用详情页面查看。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值