網(wǎng)站首頁 編程語言 正文
本文主要介紹了docker部署釘釘機(jī)器人報警通知的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
目錄結(jié)構(gòu)
[root@node1 ~]# tree prom
prom
├── docker-compose.yml #docker-compose文件
├── grafana #grafana數(shù)據(jù)掛載
├── prometheus_data #Prometheus數(shù)據(jù)掛載
├── rules #報警規(guī)則文件
│ ├── cpu_over.yml
│ ├── disk_over.yml
│ ├── memory_over.yml
│ └── node_alived.yml
└── yml
├── alertmanager.yml alertmanager配置
├── config.yml 釘釘機(jī)器人配置
└── 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 # 抓取間隔 默認(rèn)1m
evaluation_interval: 1m # 評估規(guī)則間隔 默認(rèn)1m
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
# 此片段指定報警配置, 這里主要是指定prometheus將報警規(guī)則推送到指定的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" #報警規(guī)則文件
# - "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 #在指定時間內(nèi)沒有新的事件就發(fā)送恢復(fù)通知
route:
receiver: webhook #設(shè)置接收人
group_wait: 1m #組告警等待時間。在等待時間結(jié)束后,如果有同組告警一起發(fā)出
group_interval: 1m #兩組告警間隔時間。
repeat_interval: 1m #重復(fù)告警間隔時間,減少相同郵件的發(fā)送頻率。
group_by: [alertname] #采用那個標(biāo)簽來作為分組。
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 #在指定時間內(nèi)沒有新的事件就發(fā)送恢復(fù)通知
route:
receiver: webhook #設(shè)置接收人
group_wait: 1m #組告警等待時間。在等待時間結(jié)束后,如果有同組告警一起發(fā)出
group_interval: 1m #兩組告警間隔時間。
repeat_interval: 1m #重復(fù)告警間隔時間,減少相同郵件的發(fā)送頻率。
group_by: [alertname] #采用那個標(biāo)簽來作為分組。
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數(shù)據(jù)
http://localhost:9100/metrics ? #node-exporter數(shù)據(jù)
http://localhost:9090 #prometheus
http://localhost:3000 ? #grafana
http://localhost:9090/alerts?
實現(xiàn)效果
原文鏈接:https://blog.csdn.net/systemctl_/article/details/123811389
相關(guān)推薦
- 2022-04-08 詳解RIFF和WAVE音頻文件格式_相關(guān)技巧
- 2022-05-31 C語言實現(xiàn)帶頭雙向循環(huán)鏈表_C 語言
- 2022-07-11 PostgreSQL連接到數(shù)據(jù)庫增刪改查
- 2022-05-29 python3中的類繼承你真的了解嗎_python
- 2022-09-10 Go語言O(shè)RM包中使用worm構(gòu)造查詢條件的實例詳解_Golang
- 2022-06-12 Linux中rm命令使用以及C/C++代碼實現(xiàn)_C 語言
- 2022-04-14 Python報mongod:?error?while?loading?shared?librarie
- 2023-03-23 C語言中的字符型數(shù)據(jù)與ASCII碼表_C 語言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支