docker部署钉钉机器人报警通知的实现
本文主要介绍了docker部署钉钉机器人报警通知的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
目录结构
[root@node1 ~]# tree prom
prom
├── docker-compose.yml #docker-compose文件
├── grafana #grafana数据挂载
├── prometheus_data #Prometheus数据挂载
├── rules #报警规则文件
│ ├── cpu_over.yml
│ ├── disk_over.yml
│ ├── memory_over.yml
│ └── node_alived.yml
└── yml
├── alertmanager.yml alertmanager配置
├── config.yml 钉钉机器人配置
└── prometheus.yml Prometheus配置
[root@node1 prom]# cat docker-compose.yml
version: "3.7"
services:
node-exporter:
image: prom/node-exporter:latest
container_name: "node-exporter"
ports:
- "9100:9100"
restart: always
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
restart: always
ports:
- '8080:8080'
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
restart: always
volumes:
- "./yml/prometheus.yml:/etc/prometheus/prometheus.yml"
- "./prometheus_data:/prometheus"
- "./rules:/etc/prometheus/rules"
grafana:
image: grafana/grafana
container_name: "grafana"
ports:
- "3000:3000"
restart: always
volumes:
- "./grafana:/var/lib/grafana"
alertmanager:
image: prom/alertmanager:latest
restart: "always"
ports:
- 9093:9093
container_name: "alertmanager"
volumes:
- "./yml/alertmanager.yml:/etc/alertmanager/alertmanager.yml"
webhook:
image: timonwong/prometheus-webhook-dingtalk
restart: "always"
ports:
- 8060:8060
container_name: "webhook"
volumes:
- "./yml/config.yml:/etc/prometheus-webhook-dingtalk/config.yml"
[root@node1 prom]# cat yml/prometheus.yml
# my global config
global: # 此片段指定的是prometheus的全局配置, 比如采集间隔,抓取超时时间等.
scrape_interval: 1m # 抓取间隔 默认1m
evaluation_interval: 1m # 评估规则间隔 默认1m
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
# 此片段指定报警配置, 这里主要是指定prometheus将报警规则推送到指定的alertmanager实例地址
alerting:
alertmanagers:
- static_configs:
- targets:
- 192.168.10.10:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "/etc/prometheus/rules/*.yml" #报警规则文件
# - "cpu_over.yml"
# - "disk_over.yml"
# - "memory_over.yml"
# - "node_alived.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# 抓取配置列表
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "linux"
static_configs:
- targets: ["192.168.10.10:9100","192.168.10.10:8080","192.168.10.20:9100","192.168.10.20:8080"]
[root@node1 prom]#cat alertmanager.yml
global:
resolve_timeout: 5m #在指定时间内没有新的事件就发送恢复通知
route:
receiver: webhook #设置接收人
group_wait: 1m #组告警等待时间。在等待时间结束后,如果有同组告警一起发出
group_interval: 1m #两组告警间隔时间。
repeat_interval: 1m #重复告警间隔时间,减少相同邮件的发送频率。
group_by: [alertname] #采用那个标签来作为分组。
receivers: #通知接收者列表
- name: webhook
webhook_configs:
- url: http://192.168.10.10:8060/dingtalk/webhook1/send
send_resolved: true
#########################################################
[root@node1 prom]# cat yml/config.yml
targets:
webhook1:
url: https://oapi.dingtalk.com/robot/send?access_token=XXXXXX #webhook
secret: SEC000000 #加签
[root@node1 prom]#cat alertmanager.yml
global:
resolve_timeout: 5m #在指定时间内没有新的事件就发送恢复通知
route:
receiver: webhook #设置接收人
group_wait: 1m #组告警等待时间。在等待时间结束后,如果有同组告警一起发出
group_interval: 1m #两组告警间隔时间。
repeat_interval: 1m #重复告警间隔时间,减少相同邮件的发送频率。
group_by: [alertname] #采用那个标签来作为分组。
receivers: #通知接收者列表
- name: webhook
webhook_configs:
- url: http://192.168.10.10:8060/dingtalk/webhook1/send
send_resolved: true
#########################################################
[root@node1 prom]# cat yml/config.yml
targets:
webhook1:
url: https://oapi.dingtalk.com/robot/send?access_token=XXXXXX #webhook
secret: SEC000000 #加签
配置完成后docker-compose up -d 启动容器
http://localhost:8080 #cadvisor
http://localhost:8080/metrics #cadvisor数据
http://localhost:9100/metrics #node-exporter数据
http://localhost:9090 #prometheus
http://localhost:3000 #grafana
http://localhost:9090/alerts

实现效果

到此这篇关于docker部署钉钉机器人报警通知的实现的文章就介绍到这了,更多相关docker 钉钉机器人报警内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
栏 目:其它服务器
下一篇:在Nginx服务器上安装SSL证书完成HTTPS请求的步骤详解(springboot项目)
本文标题:docker部署钉钉机器人报警通知的实现
本文地址:https://zz.feitang.co/server/32513.html
您可能感兴趣的文章
- 12-20Kubernetes中使用临时容器进行故障排查的方法
- 12-20Nginx设置HTTPS的方法步骤
- 12-20二进制方式安装 Kubernetes1.18.3版本实现脚本
- 12-20Nginx工作模式及代理配置的使用细节
- 12-20ZooKeeper分布式协调服务设计核心概念及安装配置
- 12-20Kubernetes部署可视化地图的十个步骤
- 12-20关于docker清理Overlay2占用磁盘空间的问题(亲测有效)
- 12-20Docker compose配置文件写法及命令使用示例
- 12-20openwrt安装docker并启动的操作方法
- 12-20云原生Kubernetes初始化容器Init使用教程


阅读排行
推荐教程
- 12-07一文教你怎么选择Tomcat对应的JDK版本
- 12-07新版Eclipse集成Tomcat时找不到server选项的解决方法
- 12-06IIS7 应用程序池自动回收关闭的解决方案
- 12-05Windows Server 2019安装VMware
- 12-05Windows服务器默认IE浏览器无法下载文件的解决方法
- 12-05Docker安装Jenkins全过程
- 12-19Zabbix SAML SSO 登录绕过漏洞的操作流程
- 12-15Docker-Compose搭建Spark集群的实现方法
- 12-14Docker Desktop无法正常启动解决(failed to start...)
- 12-14k8s 与docker空间使用分析与清理方法





