先创建钉钉群聊
群成员>=3
添加群机器人

Alertmanager配置钉钉告警_alertmanager

Alertmanager配置钉钉告警_alertmanager_02

https://oapi.dingtalk.com/robot/send?access_token=b713c27c658c4bbc798392d5ce76cc1408c9c0517b0146f75278e5c845a90031
启动钉钉告警插件
[root@k8smaster1 altermanager]# tar -zxvf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz 
[root@k8smaster1 prometheus-webhook-dingtalk-0.3.0.linux-amd64]# nohup ./prometheus-webhook-dingtalk --web.listen-address="0.0.0.0:8060" --ding.profile="k8s=https://oapi.dingtalk.com/robot/send?access_token=b713c27c658c4bbc798392d5ce76cc1408c9c0517b0146f75278e5c845a90031" &

Alertmanager配置钉钉告警_alertmanager_03

创建alertmanager configMap 配置文件
kind: ConfigMap
apiVersion: v1
metadata:
  name: alertmanager
  namespace: monitor-sa
data:
  alertmanager.yml: |-
    global:
      resolve_timeout: 1m
      smtp_smarthost: 'smtp.126.com:25'
      smtp_from: 'fanhuaruxu@126.com'
      smtp_auth_username: 'fanhuaruxu@126.com'
      smtp_auth_password: 'YDINTNORLQYACWQZ'
      smtp_require_tls: false
    route:
      group_by: [alertname]
      group_wait: 10s
      group_interval: 10s
      repeat_interval: 10m
      receiver: k8s
    receivers:
    - name: k8s
      webhook_configs:
      - url: 'http://192.168.1.170:8060/dingtalk/k8s/send'
        send_resolved: true
查看告警信息
[root@k8smaster1 altermanager]# kubectl logs pod  prometheus-server-f9bb6686-zrcxc  -c  alertmanager -n monitor-sa

Alertmanager配置钉钉告警_alertmanager_04