配置Alertmanager發送報警到企業微信


配置Alertmanager發送報警到企業微信

一、配置步驟

1.1、注冊企業微信

注冊地址:https://work.weixin.qq.com/

找到應用管理,創建應用

image-20210712123746591

image-20210712123957294

AgentId:1000005

Secret:xGVnhrm2n2LhJcrBzULKrAH0rzIXGkQV4IiTFJYERHw

1.2、修改alertmanager-cm.yaml文件

[root@k8s-master1 prometheus]# cp alertmanager-cm.yaml alertmanager-cm-ding.yaml
[root@k8s-master1 prometheus]# cat  alertmanager-cm.yaml
kind: ConfigMap
apiVersion: v1
metadata:
  name: alertmanager
  namespace: monitor-sa
data:
  alertmanager.yml: |-
    global:
      resolve_timeout: 1m
      smtp_smarthost: 'smtp.163.com:25'
      smtp_from: '18665870472@163.com'
      smtp_auth_username: '18665870472'
      smtp_auth_password: 'GGCTEDQDVLKPCIID'
      smtp_require_tls: false
    route:
      group_by: [alertname]
      group_wait: 10s
      group_interval: 10s
      repeat_interval: 10m
      receiver: prometheus
    receivers:
    - name: 'prometheus'
      wechat_configs:
      - corp_id: wwc84b5a8706c67480
        to_user: '@all'
        agent_id: 1000005
        api_secret: xGVnhrm2n2LhJcrBzULKrAH0rzIXGkQV4IiTFJYERHw

參數說明:

# 參數說明:
secret: 企業微信("企業應用"-->"自定應用"[Prometheus]--> "Secret") 
wechat是本人自創建應用名稱
corp_id: 企業信息("我的企業"--->"CorpID"[在底部])
agent_id: 企業微信("企業應用"-->"自定應用"[Prometheus]--> "AgentId") 
wechat是自創建應用名稱 #在這創建的應用名字是wechat,那么在配置route時,receiver也應該是Prometheus
to_user: '@all' :發送報警到所有人

1.3、更新服務

[root@k8s-master1 prometheus]# kubectl apply  -f alertmanager-cm.yaml
configmap/alertmanager configured
[root@k8s-master1 prometheus]# kubectl delete -f  prometheus-alertmanager-deploy.yaml
deployment.apps "prometheus-server" deleted
[root@k8s-master1 prometheus]# kubectl apply -f  prometheus-alertmanager-deploy.yaml
deployment.apps/prometheus-server created

[root@k8s-master1 prometheus]# kubectl get pods -n monitor-sa 
NAME                                 READY   STATUS    RESTARTS   AGE
node-exporter-nl5qz                  1/1     Running   0          16h
node-exporter-nxwkf                  1/1     Running   0          16h
node-exporter-x494t                  1/1     Running   0          16h
prometheus-server-76dd9f8dc6-fhggv   2/2     Running   0          26s

接收到的微信報警:

image-20210712125059199


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM