zoukankan      html  css  js  c++  java
  • Prometheus+Altermanager钉钉报警

    Prometheus+Altermanager钉钉报警

    一、添加钉钉机器人

    参考钉钉官方文档:https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq

     二、在k8s上部署钉钉告警deployment,这里我们引用第三方的插件。

    [root@cn-hongkong webhook-dingtalk]# cat webhook-dingtalk.yaml
    apiVersion: apps/v1beta2
    kind: Deployment
    metadata:
      labels:
        app: webhook-dingtalk
      name: webhook-dingtalk
      namespace: monitoring
      #需要和alertmanager在同一个namespace
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: webhook-dingtalk
      template:
        metadata:
          labels:
            app: webhook-dingtalk
        spec:
          containers:
          - image: billy98/webhook-dingtalk:latest
            name: webhook-dingtalk
            args:
            - "https://oapi.dingtalk.com/robot/send?access_token=1fd59067ab85bea575122a5e4f05cefd6609d9d3e41a725e46a90c2fad9b3"
            #上面创建的钉钉机器人hook
            ports:
            - containerPort: 8080
              protocol: TCP
            resources:
              requests:
                cpu: 100m
                memory: 100Mi
              limits:
                cpu: 500m
                memory: 500Mi
            livenessProbe:
              failureThreshold: 3
              initialDelaySeconds: 30
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 1
              tcpSocket:
                port: 8080
            readinessProbe:
              failureThreshold: 3
              initialDelaySeconds: 30
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 1
              httpGet:
                port: 8080
                path: /
          imagePullSecrets:
            - name: IfNotPresent
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: webhook-dingtalk
      name: webhook-dingtalk
      namespace: monitoring
      #需要和alertmanager在同一个namespace
    spec:
      ports:
      - name: http
        port: 80
        protocol: TCP
        targetPort: 8080
      selector:
        app: webhook-dingtalk
      type: ClusterIP 
    

     三、alertmanager添加钉钉告警类型

      config:
        global:
          resolve_timeout: 5m
        route:
          group_by: ['job','severity']
          group_wait: 30s
          group_interval: 5m
          repeat_interval: 12h
          receiver: default
          receiver: webhook
          routes:
          - match:
              filesystem: node
            receiver: webhook
        receivers:
        - name: webhook
          webhook_configs:
          - url: http://webhook-dingtalk/dingtalk/send/
            send_resolved: true
    

     四、查看告警信息

  • 相关阅读:
    7.29随堂笔记
    LeetCode77. 组合
    347. 前 K 个高频元素
    LeetCode239. 滑动窗口最大值
    C++_数字字符串互相转换
    LeetCode150. 逆波兰表达式求值
    LeetCode1047. 删除字符串中的所有相邻重复项
    LeetCode20. 有效的括号
    Leetcode225. 用队列实现栈 && LeetCode232. 用栈实现队列
    leetCode5663. 找出第 K 大的异或坐标值
  • 原文地址:https://www.cnblogs.com/Dev0ps/p/11916963.html
Copyright © 2011-2022 走看看