alertmanger告警配置

钉钉告警:

  需先安装 Ding talk 配置 webhook

    vim docker-compose.yaml  

  webhook-dingtalk:
  image: timonwong/prometheus-webhook-dingtalk:latest
  ports:
  - 8060:8060
  command:
  - '--ding.profile=ops=https://oapi.dingtalk.com/robot/send?access_token=xxx' #此处为钉钉的webhook地址
  restart: always

  

  vim alertmanager.yml 

  global:
  resolve_timeout: 5m

  templates:
  - dingding_template.tmpl

  route:
  receiver: webhook
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 5m
  group_by: [alertname]
  routes:
  - receiver: webhook
  group_wait: 10s

  receivers:
  - name: webhook
  webhook_configs:
  - url: http://xxx.xxx.xxx.xxx:8060/dingtalk/ops/send #若dingtalk为docker启动,此处ip需写宿主机IP,不能写localhost
  send_resolved: true

 

企业微信告警:

  vim alertmanager.yml

  global:
  resolve_timeout: 2m


  route:
  group_by: ['alertname', 'instance', 'service', 'severity']
  group_wait: 10s
  group_interval: 1m
  repeat_interval: 5m
  receiver: 'wechat'
  routes:
  - match:
  severity: critical
  receiver: 'webhook'

  receivers:
  - name: 'wechat'
  wechat_configs:
  - corp_id: 'wx41f06dc30c1xxxxx' #此处为企业微信的组id
  to_party: '2'
  agent_id: '100000x' #此处为企业微信的 agentID

  api_secret: 'NolIn8uss9FW1c2bg2XxQg3ZBE43s7fx2xxxxxxxxxx' #此处为企业微信的API认证
  send_resolved: true

 

电子邮件告警:

  vim alertmanager.yml  

  global:
  resolve_timeout: 5m
  smtp_smarthost: 'smtp.qq.com:465'
  smtp_from: 'xxx@qq.com' # 此处为发送告警邮件的邮箱地址
  smtp_auth_username: 'xxx@qq.com'
  smtp_auth_password: 'pkwyycwrnjvibfad' #注:此处为邮箱的客户端认证,不是邮箱密码
  smtp_require_tls: false

  templates:
  - './email.tmpl' #此处为告警邮件的发送模版

  route:
  receiver: 'default'
  group_wait: 10s
  group_interval: 1m
  repeat_interval: 1h
  group_by: ['alertname']

  inhibit_rules:
  - source_match:
  severity: 'critical'
  target_match:
  severity: 'warning'
  equal: ['alertname', 'instance']

  receivers:
  - name: 'default'
  email_configs:
  - to: 'xxx@xxx.com' # 此处为接收告警邮件的邮箱地址
  headers: { subject: '[WARN]Prometheus告警邮件' }
  send_resolved: true

 

 

 

  

posted @ 2021-06-23 14:47  木易-故事里的人  阅读(34)  评论(0编辑  收藏  举报