kube-prometheus实现企业微信机器人告警
公司kubernetes生产环境部署了kube-prometheus-release-0.3用于监控kubernetes集群状态,但是默认预置了告警规则,但是不能发送告警信息。本文着重介绍自己在公司环境实现alertmanager通过企业微信发送告警信息。具体实现方式的逻辑如下图:
实现方式:
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.在企业微信群聊创建机器人
3.创建webhook服务,用于转发alertmanager的告警消息到企业微信机器人
---
apiVersion: apps/v1
kind: Deployment
metadata:labels:run: prometheus-webhook-qywxname: prometheus-webhook-qywxnamespace: monitoring
spec:selector:matchLabels:run: prometheus-webhook-qywxtemplate:metadata:labels:run: prometheus-webhook-qywxspec: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-dingtalkports:- containerPort: 80protocol: TCP
---
apiVersion: v1
kind: Service
metadata:labels:run: prometheus-webhook-qywxname: prometheus-webhook-qywxnamespace: monitoring
spec:ports:- port: 8060protocol: TCPtargetPort: 80selector:run: prometheus-webhook-qywxtype: 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实现企业微信机器人告警相关推荐
- Prometheus+Grafana+企业微信机器人告警
Prometheus+Grafana+企业微信机器人告警 开源监控和报警系统 Prometheus+Grafana+企业微信机器人告警 Prometheus+Grafana+企业微信机器人告警 1.P ...
- prometheus 通过企业微信接收告警 WeChat告警模版配置
实现WeChat 告警-准备工作 step 1: 访问网站 注册企业微信账号(不需要企业认证). step 2: 访问apps 创建第三方应用,点击创建应用按钮 -> 填写应用信息: 部门ID: ...
- prometheus自定义邮件告警和自定义微信机器人告警
目录 ---------------------------- 一.自定义邮件告警 二.使用docker部署微信机器人告警 1.制作镜像 2.启动容器和指定webhook容器 ------------ ...
- 企业微信机器人推送mysql_Zabbix.5.0设置企业微信群机器人推送告警信息
一.企业微信端配置 1.创建微信群机器人 在需要接收告警信息的企业微信群上右键(注意群里成员至少要3人以上),选择"添加群机器人",设置机器人名称,系统自动生成此机器人的webho ...
- 企业微信机器人还能这么玩?
英剧<黑镜:圣诞特别篇>中有一集讲到女主日程非常忙碌,同时又对自己要求很高,于是选择在代码世界复制了一个自己,作为自己的"智能管家",这个智能管家堪称完美,完全熟悉女主 ...
- PowerShell 实现企业微信机器人推送消息
前言企业微信机器人 在ARMS告警管理中创建企业微信机器人后,您可以在通知策略中指定对应的企业微信群用于接收告警.当通知策略的匹配规则被触发时,系统会自动向您指定的企业微信群发送告警通知.企业微信群收 ...
- Prometheus配置企业微信报警
Prometheus配置企业微信报警 更多技术博客,请关注微信公众号:运维之美 Prometheus被号称是下一代的监控,可以解决云上K8S集群的监控问题,搭配部署alertmanager,可以实现告 ...
- 企业微信机器人发送消息
背景:之前用钉钉机器人可以发送消息,可以将线上的告警通知发送到消息群中,后来企业微信也支持在群组中增加机器人了,钉钉和企业微信机器人的使用很相似,都是使用webhook的方式来进行实现的,话不多说,咱 ...
- zabbix监控-企业微信webhook告警并使用markdown格式
zabbix监控-企业微信webhook告警并使用markdown格式 最终告警样式: markdown格式与text格式的优点:文字排版清晰,可对不同文字标识颜色,大小等. 此方法使用zabbix提 ...
最新文章
- 十一Python之路,Day6 - 面向对象学习
- idea编辑springboot,如何打成war包
- java中如何将非整数保留到小数点后指定的位数
- 台式电脑如何截屏_如何选购台式电脑显卡?小白装机通俗易懂的独立显卡知识指南...
- 安卓APP_ 控件(3)—— EditText
- C语言中volatile关键字与汇编__volatile__
- Think in Java读书笔记--对象入门
- CSDN新版下载频道改版上线了
- Idea2017破解下载地址
- VISTA 服务详解
- HTML——倒计时制作
- linux录音硬件电路,电话扩音录音装置电路及制作
- 「CodePlus 2017 11 月赛」大吉大利,晚上吃鸡!(dij+bitset)
- 2019.5.11 提高B组 T3 nssl-1322 清兵线
- 微众银行客服电话是95384 认准官方的人工客服电话
- shell基础---exit用法
- 经济危机会影响软件质量吗?
- 自习室风口!使用网上预约系统助力自习室预约
- terminate called after throwing an instance of ‘std::runtime_error‘ what(): locale::facet::_S_cre
- 遗传算法优化BP神经网络出现输入参数不足,是什么原因啊,求大神指导,代码如下