Rancher中设置钉钉告警

背景:现在的办公都使用钉钉,告警很多地方也用到了钉钉机器人的webhook,但是研究了rancher的告警好一会才知道rancher原来是不支持钉钉webhook。真的是吐血~

系统环境

centos7.8

rancher v2.4.5

docker 19.03.12

步骤

  • rancher-ui启用集群监控
  • rancher-ui启用项目监控 (这里注意如果启用持久化存储,grafana pvc挂载的权限问题,会导致grafana异常,创建的pv目录权限给足就行)

我这里使用开源大佬的timonwong/prometheus-webhook-dingtalk来转发消息,更详细的直接GitHub上搜。

 编辑服务发现:

yaml文件内容如下:

kind: Service
apiVersion: v1
metadata:
  name: webhook-dingtalk
  namespace: my-public
spec:
  selector:
    app: webhook-dingtalk
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8060
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webhook-dingtalk
  namespace: my-public
  labels:
    app: webhook-dingtalk
spec:
  replicas: 1
  selector:
    matchLabels:
      app: 
  template:
    metadata:
      labels:
        app: webhook-dingtalk
    spec:
      imagePullSecrets:
        - name: pipeline-docker-registry
      containers:
        - name: webhook-dingtalk
          image: timonwong/prometheus-webhook-dingtalk
          args:
          - --ding.profile=webhook1=xxxxxxxxxxxxxxxx
          ports:
            - containerPort: 8060

添加通知示例 

 

http://webhook-dingtalk.my-public.svc.cluster.local/dingtalk/webhook1/send

大家将my-public修改为自己的服务所在的命名空间名称即可,如果要使用多个群组机器人,在yaml文件中spec.containers.args字段下,添加多个ding.profile即可,然后通知栏uri修改为你自定义的webhook名称,比如webhook2

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 16
    评论
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值