(五)Prometheus监控思科交换机 ---Alertmanager 钉钉报警展现

Alertmanager 同时触发邮件报警和钉钉报警

全部文章索引:http://www.javashuo.com/article/p-bedpreph-nu.htmlgit

获取钉钉群组机器人的 Webhook 地址;

  • 添加 Webhook 类型的群机器人

(五)Prometheus监控思科交换机 ---Alertmanager 钉钉报警展现

  • 获取 token 地址,并经过白名单机制进行接入,若是不知道本身的访问钉钉的IP,则能够在服务器上使用 curl 命令获取;

(五)Prometheus监控思科交换机 ---Alertmanager 钉钉报警展现

  • 获取IP办法
    curl 'https://oapi.dingtalk.com/robot/send?access_token=******' -H 'Content-Type: application/json'    -d '{"msgtype": "text","text": {"content": "我就是我, 是不同的烟火"}}'

    (五)Prometheus监控思科交换机 ---Alertmanager 钉钉报警展现

安装 prometheus-webhook-dingtalk

GitHub地址:https://github.com/timonwong/prometheus-webhook-dingtalkgithub

docker pull timonwong/prometheus-webhook-dingtalk:latest

docker run -d --restart always -p 8060:8060 timonwong/prometheus-webhook-dingtalk:latest --ding.profile="webhook1=https://oapi.dingtalk.com/robot/send?access_token=******"

调整报警策略,加入以前邮件报警的 receiver 组中,使之同时触发报警

[root@localhost alertmanager]# cat alertmanager.yml
global:
  resolve_timeout: 5m
  smtp_smarthost: 'smtp.163.com:25'
  smtp_from: '******@163.com'
  smtp_auth_username: '******@163.com'
  smtp_auth_password: '******'

route:
  group_by: ['alertname']
  group_wait: 10s  # 报警触发等待时间
  group_interval: 1m # 报警触发时间
  repeat_interval: 5m # 轮询报警触发时间
  receiver: jsb # 接收方
  routes:
  - receiver: jsb
    group_wait: 10s
    group_interval: 1m
    repeat_interval: 5m

receivers:
- name: 'jsb'
  email_configs:
  - to: "*****@qq.com, ******@163.com"
  webhook_configs:   # 能够在另写一个 receiver_name ,而后进行匹配,为了同时验证效果写在一个 name 下边,这样邮件和钉钉能够同时触发
  - url: http://192.168.202.239:8060/dingtalk/webhook1/send
    send_resolved: true

systemctl restart alertmanager.service

报警演示

(五)Prometheus监控思科交换机 ---Alertmanager 钉钉报警展现
(五)Prometheus监控思科交换机 ---Alertmanager 钉钉报警展现