docker部署釘釘機器人報警通知的實現(xiàn)
本文主要介紹了docker部署釘釘機器人報警通知的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(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 釘釘機器人配置
└── 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 # 評估規(guī)則間隔 默認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] #采用那個標簽來作為分組。
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] #采用那個標簽來作為分組。
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)效果

到此這篇關(guān)于docker部署釘釘機器人報警通知的實現(xiàn)的文章就介紹到這了,更多相關(guān)docker 釘釘機器人報警內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用Docker compose編排Laravel應(yīng)用的方法
本篇文章主要介紹了使用Docker compose編排Laravel應(yīng)用的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-07-07
docker容器狀態(tài)的轉(zhuǎn)換實現(xiàn)
這篇文章主要介紹了docker容器狀態(tài)的轉(zhuǎn)換實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11
如何解決mysql配置文件錯誤導(dǎo)致在docker中無法啟動的問題
這篇文章主要介紹了如何解決mysql配置文件錯誤導(dǎo)致在docker中無法啟動的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-01-01
Docker數(shù)據(jù)卷掛載命令volume(-v)與mount的使用總結(jié)
本文主要介紹了Docker數(shù)據(jù)卷掛載命令volume(-v)與mount的使用總結(jié),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08
Docker學(xué)習(xí)筆記之Weave實現(xiàn)跨主機容器互聯(lián)
這篇文章主要介紹了Docker學(xué)習(xí)筆記之Weave實現(xiàn)跨主機容器互聯(lián),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-04-04

