zoukankan      html  css  js  c++  java
  • 配置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

    作者:Lawrence

    -------------------------------------------

    个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!

    扫描上面二维码关注我
    如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!
    本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
  • 相关阅读:
    java_IO读写模版
    c#_DropdownList Panel Textbox 控件交互使用,有autopostback和没有的区别
    C#_datatable 写入大量数据_BulkCopy
    C#_datatable_读取
    C#_数据库交互_SqlHelper
    C#_数据库基本交互
    C#_Wpf_DataContex上下文整个类绑定
    C#_wpf_userinput_数据绑定_后台对象改变,界面数据也变化
    C#_delegate
    C#_delegate
  • 原文地址:https://www.cnblogs.com/hujinzhong/p/15001665.html
Copyright © 2011-2022 走看看