k8s中prometheus operator配置钉钉报警

315次阅读
没有评论

共计 1380 个字符,预计需要花费 4 分钟才能阅读完成。

安装可以参考我前面的文章。
准备钉钉的 configmap 的文件,内容如下

vim dingtalk-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: dingtalk-config
  namespace: monitoring
data:
  config.yml: |-
    targets:
      webhook:
        url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx #设置成钉钉机器人地址
        mention:
          all: true

钉钉 pod 的 yaml 文件

vim dingtalk-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dingtalk
  namespace: monitoring
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dingtalk
  template:
    metadata:
      name: dingtalk
      labels:
        app: dingtalk
    spec:
      containers:
      - name: dingtalk
        image: timonwong/prometheus-webhook-dingtalk:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8060
        volumeMounts:
        - name: config
          mountPath: /etc/prometheus-webhook-dingtalk
      volumes:
      - name: config
        configMap:
          name: dingtalk-config
---
apiVersion: v1
kind: Service
metadata:
  name: dingtalk
  namespace: monitoring
  labels:
    app: dingtalk
  annotations:
    prometheus.io/scrape: 'false'
spec:
  selector:
    app: dingtalk
  ports:
  - name: dingtalk
    port: 8060
    protocol: TCP
    targetPort: 8060

安装
kubectl apply -f dingtalk-config.yaml
kubectl apply -f -f dingtalk-deployment.yaml

修改 alertmanager-main 的配置密文,我是直接通过 web 界面删除修改

"global":
  "resolve_timeout": "5m"
"receivers":
- "name": "Webhook"
  "webhook_configs":
  - "url": "http://dingtalk.monitoring.svc.cluster.local:8060/dingtalk/webhook/send"
"route":
  "group_by":
  - "namespace"
  "group_wait": "30s"
  "receiver": "Webhook"
  "repeat_interval": "12h"
  "routes":
  - "matchers":
    - "alertname = Webhook"
    "receiver": "Webhook"

2022-08-05T07:22:44.png

然后效果如下(安装好后还需要自己调优)到此完成!
k8s 中 prometheus operator 配置钉钉报警

正文完
 0
yx
版权声明:本站原创文章,由 yx 于2022-08-05发表,共计1380字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码