kube-prometheus实现企业微信机器人告警

这篇具有很好参考价值的文章主要介绍了kube-prometheus实现企业微信机器人告警。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

公司kubernetes生产环境部署了kube-prometheus-release-0.3用于监控kubernetes集群状态,但是默认预置了告警规则,但是不能发送告警信息。本文着重介绍自己在公司环境实现alertmanager通过企业微信发送告警信息。具体实现方式的逻辑如下图:

kube-prometheus实现企业微信机器人告警

 实现方式:

1.查看部署的kube-prometheus

[root@k8s-master-03 kube-prometheus-release-0.3]# kubectl get pod -n monitoring
NAME                                       READY   STATUS    RESTARTS   AGE
alertmanager-main-0                        2/2     Running   0          6h20m
alertmanager-main-1                        2/2     Running   0          6h20m
alertmanager-main-2                        2/2     Running   0          6h2m
grafana-77978cbbdc-x9qpp                   1/1     Running   0          5d22h
kube-state-metrics-7f6d7b46b4-nnjrs        3/3     Running   0          5d22h
node-exporter-42hpk                        2/2     Running   0          5d22h
node-exporter-5d99p                        2/2     Running   0          5d22h
node-exporter-5fcd8                        2/2     Running   0          5d22h
node-exporter-66mxt                        2/2     Running   0          5d22h
node-exporter-6tcg6                        2/2     Running   0          5d22h
node-exporter-8dkc2                        2/2     Running   0          5d22h
node-exporter-8wrq5                        2/2     Running   0          5d22h
node-exporter-9z778                        2/2     Running   0          5d22h
node-exporter-b2lpm                        2/2     Running   0          5d22h
node-exporter-dvfmw                        2/2     Running   0          5d22h
node-exporter-f794p                        2/2     Running   0          5d22h
node-exporter-frfzm                        2/2     Running   0          5d22h
node-exporter-hffpg                        2/2     Running   0          5d22h
node-exporter-hkhkh                        2/2     Running   0          5d22h
node-exporter-jjszd                        2/2     Running   0          5d22h
node-exporter-lgslx                        2/2     Running   0          5d22h
node-exporter-nxdtj                        2/2     Running   0          5d22h
node-exporter-q458q                        2/2     Running   0          5d22h
node-exporter-r6mff                        2/2     Running   0          5d22h
node-exporter-s9jw2                        2/2     Running   0          5d22h
node-exporter-vfp24                        2/2     Running   0          5d22h
node-exporter-w2q6g                        2/2     Running   0          5d22h
node-exporter-xgmn5                        2/2     Running   0          5d22h
prometheus-adapter-68698bc948-xtnvm        1/1     Running   0          5d22h
prometheus-k8s-0                           3/3     Running   1          5d1h
prometheus-k8s-1                           3/3     Running   0          5d2h
prometheus-operator-6685db5c6-4zwcn        1/1     Running   0          5d22h

2.在企业微信群聊创建机器人

kube-prometheus实现企业微信机器人告警

 3.创建webhook服务,用于转发alertmanager的告警消息到企业微信机器人

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: prometheus-webhook-qywx
  name: prometheus-webhook-qywx
  namespace: monitoring
spec:
  selector:
    matchLabels:
      run: prometheus-webhook-qywx
  template:
    metadata:
      labels:
        run: prometheus-webhook-qywx
    spec:
      containers:
      - args:
        - --adapter=/app/prometheusalert/wx.js=/adapter/wx=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c3578c16-1a8e-ssssdddd8888888  #注意变更这个地址,即企业微信机器人的webhook地址
        image: registry.cn-hangzhou.aliyuncs.com/guyongquan/webhook-adapter  
        name: prometheus-webhook-dingtalk
        ports:
        - containerPort: 80
          protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: prometheus-webhook-qywx
  name: prometheus-webhook-qywx
  namespace: monitoring
spec:
  ports:
  - port: 8060
    protocol: TCP
    targetPort: 80
  selector:
    run: prometheus-webhook-qywx
  type: ClusterIP

备注:

adapter=/app/prometheusalert/wx.js=/adapter/wx=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c3578c16-1a8e-ssssdddd8888888  #注意变更这个地址,即企业微信机器人的webhook地址  

4.报警方式,即alertmanager的配置文件变更

变更命名空间monitoring下的alertmanager-main的secret,这个是alertmanager的配置文件

默认安装的时候,缺省配置为

"global":
  "resolve_timeout": "5m"
"receivers":
- "name": "null"
"route":
  "group_by":
  - "job"
  "group_interval": "5m"
  "group_wait": "30s"
  "receiver": "null"
  "repeat_interval": "12h"
  "routes":
  - "match":
      "alertname": "Watchdog"
    "receiver": "null"

根据需求变更为

"global":
  "resolve_timeout": "5m"
"receivers":
- name: 'web.hook'
  webhook_configs:
  - url: 'http://prometheus-webhook-qywx.monitoring.svc.cluster.local:8060/adapter/wx'               # 刚刚创建的webhook地址
    send_resolved: false
"route":
  "group_by":
  - "job"
  - "namespaces"
  - "alertname"
  "group_interval": "5m"
  "group_wait": "30s"
  "receiver": "web.hook"
  "repeat_interval": "10m"
  "routes":
  - "match":
      "alertname": "Watchdog"
    "receiver": "web.hook"

http://prometheus-webhook-qywx.monitoring.svc.cluster.local:8060 是上面创建的webhook转发服务的service

配置企业微信机器人告警时需要先安装webhook;最后重启alertmanger-main-0,alertmanger-main-1,alertmanger-main-3

5.查看企业微信机器人的告警信息

kube-prometheus实现企业微信机器人告警

 文章来源地址https://www.toymoban.com/news/detail-400379.html

到了这里,关于kube-prometheus实现企业微信机器人告警的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • k8s v1.27.4 部署metrics-serverv:0.6.4,kube-prometheus,镜像下载问题处理

    只有一个问题,原来的httpGet存活、就绪检测一直不通过,于是改为tcpSocket后pod正常。 修改后的yaml文件,镜像修改为阿里云 部署kube-prometheus 兼容1.27的为main分支 只克隆main分支 处理: 修改prometheus-clusterRole.yaml 使用ServiceMonitor添加监控: 以ingress-nginx为例 修改ingress-nginx.yaml的

    2024年02月05日
    浏览(32)
  • 第八篇: K8S Prometheus Operator实现Ceph集群企业微信机器人告警

    我们的k8s集群与ceph集群是部署在不同的服务器上,因此实现方案如下: (1) ceph集群开启mgr内置的exporter服务,用于获取ceph集群的metrics (2) k8s集群通过 Service + Endponit + ServiceMonitor建立ceph集群metrics与Prometheus之间的联系 建立一个 ServiceMonitor 对象,用于 Prometheus 添加监控项; 为

    2024年02月14日
    浏览(28)
  • 企业微信群:机器人实现定时提醒功能

    如果每天都需要,或者经常需要提醒企业微信群里面的人做某一件事情的话,靠人力去实现比较费力,而且偶尔忘记。 正好,企业微信群有一个机器人,正可以实现这一功能。 1、首先,在企业微信群,添加一个机器人。 2、根据企业微信机器人的配置说明,编写程序。这里

    2024年02月16日
    浏览(94)
  • PowerShell 实现企业微信机器人推送消息

    在ARMS告警管理中创建企业微信机器人后,您可以在通知策略中指定对应的企业微信群用于接收告警。当通知策略的匹配规则被触发时,系统会自动向您指定的企业微信群发送告警通知。企业微信群收到通知后,您可以在企业微信群中对告警进行管理。 通过接口实现在群里发

    2024年02月06日
    浏览(92)
  • Alertmanager实现企业微信机器人webhook告警

    由于企业微信更新问题,现在已经无法直接使用创建应用后在alertmanager的配置文件中定义企业id及secret就可以发送告警信息了,除非填写备案后域名;为了我们这种个人开发者非常的不便,所以本文档是为了解决想使用企业微信告警但又无法备案的朋友;下面只是我的操作过

    2024年04月28日
    浏览(25)
  • 运用python实现企业微信群机器人消息推送

    使用场景 :将BI报表精准推送入(群),精准触达用户 目的 :提高管理层对数据的感知度 工具:python+企业微信 步骤: 1、创建企业微信群机器人,提取Webhook地址(群机器人地址) 2、编写代码填充推送内容信息实现推送 3、其他需求自定义代码编写 实现方法1–优化后 实现

    2024年02月16日
    浏览(26)
  • Python实现企业微信群机器人自动化推送

    人工智能(Artificial Intelligence),英文缩写为AI。它是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门新的技术科学。 ——《百度百科》 实际工作中,有类似这样的场景, 需要将某些通知信息定期发送到企业微信群,需要将公司某些指标的异

    2024年02月09日
    浏览(47)
  • WorkTool无障碍服务实现企业微信机器人接口

    想要实现一个企业微信机器人,如京东/拼多多福利群、美团瑞幸定时营销群、自助订单查询、智能咨询或社群管理机器人等,首先官方未提供外部群/客户群的机器人API,会话存档也只在一定场景下适用,及时使用会话存档也存在只能收不能发的问题,有哪些办法可以合规的

    2024年02月14日
    浏览(37)
  • 封装Python脚本:使用企业微信机器人发送消息至企业微信

    官方文档地址:https://developer.work.weixin.qq.com/document/path/91770#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E7%BE%A4%E6%9C%BA%E5%99%A8%E4%BA%BA 可以通过如下步骤设置企业微信机器人: 首先建立或者进入某个群聊 进入群聊设置页面, 点击“群机器人添加”可添加一个机器人成功 添加成功后,复制并保

    2024年02月09日
    浏览(26)
  • k8s入门:kube-prometheus-stack 全家桶搭建(Grafana + Prometheus)

    系列文章 第一章:✨ k8s入门:裸机部署 k8s 集群 第二章:✨ k8s入门:部署应用到 k8s 集群 第三章:✨ k8s入门:service 简单使用 第四章:✨ k8s入门:StatefulSet 简单使用 第五章:✨ k8s入门:存储(storage) 第六章:✨ K8S 配置 storageclass 使用 nfs 动态申领本地磁盘空间 第七章:

    2024年02月08日
    浏览(46)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包