docker 钉钉机器人报警
从清晨到日暮_ 人气:2本文主要介绍了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 钉钉机器人报警内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
加载全部内容