2020-08-25
Prometheus å®ç°é®ä»¶åè¦ï¼Prometheus+Alertmanager+QQé®ç®±æè ç½æé®ç®±ï¼ç®åæµè¯è¿è¿ä¸¤ç§é®ç®±é½å¯ä»¥åéåè¦é®ä»¶ï¼
Prometheuså®ç°é®ä»¶åè¦åçå¦ä¸ï¼
Prometheuså®æ¹æä¸ä¸ªé带çä¸é´ä»¶ï¼alertmanagerï¼éè¿è®¾ç½®rulesè§ååè·¯ç±è½¬åå¯ä»¥å®ç°é®ä»¶åè¦ï¼åææ¯ä½ éè¦æä¸ä¸ªå¯ä»¥åéé®ä»¶çé®ä»¶æå¡ç«¯ï¼å¯ä»¥èªå»ºæè 使ç¨äºèç½å ¬å¸æä¾çå è´¹é®ç®±ï¼
åè¦åçå¾
Prometheuså®æ´æ¶æå¾
æä¹åå¾åºçé误ç»è®ºå¦ä¸ï¼
æ¨èç´æ¥å¨èææºæä½ç³»ç»ä¸ç´æ¥å®è£ PrometheusåAlertmanagerï¼ä¸æ¨èå ¶ä¸ä»»ä½ä¸æ¹å¨å®¹å¨ä¸è¿è¡ï¼å 为æµè¯è¿å¨å®¹å¨ä¸è¿è¡Prometheusåalertmanagerï¼ç»æåºç°å¦ä¸é误æ åµ
第ä¸ç§æ åµæ¯ï¼æçnode-exporteræ线è·æºäºï¼æå¨å ³æºï¼æ¨¡æçªç¶æ线è·æºï¼ï¼Prometheuså´æ示èç¹ä¾ç¶å¨çº¿ï¼ææ¶åå´è½å¤æ£å¸¸æ¾ç¤ºèç¹æ线è·æºï¼çæåè¦åéé®ä»¶
第äºç§æ åµæ¯ï¼æçnode-exporteræ线è·æºäºï¼æå¨å ³æºï¼æ¨¡æçªç¶æ线è·æºï¼ï¼Prometheusæ示èç¹æ线ï¼åè¦çæï¼ä½æ¯æ²¡æåéé®ä»¶ï¼ææå¨æ¢å¤node-exporteråï¼åè¦è§£é¤ï¼é®ä»¶è½æ£å¸¸åéé®ä»¶æ示åè¦å·²ç»è§£é¤ãããã
第ä¸ç§æ åµæ¯ï¼æçnode-exporteræ线è·æºäºï¼æå¨å ³æºï¼æ¨¡æçªç¶æ线è·æºï¼ï¼Prometheusæ示èç¹æ线ï¼åè¦çæï¼æ£å¸¸æååéé®ä»¶ï¼ææå¨æ¢å¤node-exporteråï¼åè¦è§£é¤ï¼é®ä»¶æ²¡æåéåºæ¥ãããã
以ä¸ä¸ç§æ åµä¹åç»å¸¸åºç°ï¼å½æ¶ç¬¬ä¸æ¥ä»¥ä¸ºæ¯èªå·±è®¾ç½®çscrape_intervalä¸åç导è´çï¼ç»æè°è¯å 次ï¼é®é¢æ²¡æ解å³ï¼ç¬¬äºæ¥ä»¥ä¸ºæ¯èªå·±çæå¡å¨æ¶é´æ²¡æåå°ç²¾ç¡®åæ¥ï¼ç¶åæå»è®¾ç½®åé¿éäºçntpæå¡å¨åæ¥ï¼ç»æé®é¢ä¾ç¶æ²¡æ解å³ï¼ç¬¬ä¸æ¥ï¼æ¢ä¸ªæ¹åï¼æalertmanagerè¿ç§»å°èææºæä½ç³»ç»ä¸å®è£ è¿è¡ï¼é®é¢è§£å³ï¼
å京æ¶é´æ¯GMT+8å°æ¶ï¼æäºåå¿çæ¶é´å¯è½æ¯UTCçï¼ä½æ¯å¦ææ¯å¨è¦æ±ä¸å¤ªåå精确çæ åµä¸ï¼UTCæ¶é´æ¯åå好çäºGMTæ¶é´
为äºé¿å æ¶åºçæ··ä¹±ï¼prometheusææçç»ä»¶å é¨é½å¼ºå¶ä½¿ç¨Unixæ¶é´ï¼å¯¹å¤å±ç¤ºä½¿ç¨GMTæ¶é´ã
è¦æ¹æ¶åºæ两个åæ³
1 .ä¿®æ¹æºç ï¼éæ°ç¼è¯ã
2. ä½¿ç¨ docker è¿è¡ Prometheusï¼æè½½æ¬å°æ¶åºæ件
docker run --restart always -e TZ=Asia/Shanghai --hostname prometheus --name prometheus-server -d -p : -v /data/prometheus/server/data:/prometheus -v /data/prometheus/server/conf/prometheus.yml:/etc/prometheus/prometheus.yml -u root prom/prometheus:v2.5.0
æ£æå¼å§
å®è£ alertmanager
容å¨å®è£ æ¹å¼ï¼
docker run -d --name alertmanager -p : -v /usr/local/Prometheus/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml prom/alertmanager:latest
å å¨å®¿ä¸»æº/usr/local/Prometheusä¸å建ä¸ä¸ªæ件夹alertmanagerï¼ç¶åå¨æ件夹éå建alertmanager.ymlé ç½®æ件ï¼å¾ ä¼æè½æ å°å°alertmanager容å¨éç/etc/alertmanagerç®å½ä¸
globalï¼å ¨å±é ç½®
resolve_timeout: é®é¢è§£å³çè¶ æ¶æ¶é´
smtp_from: åéåè¦é®ä»¶çé®ç®±è´¦å·
smtp_smarthost: é®ç®± SMTP æå¡å°å,è¿éæ¯ä»¥QQé®ç®±ä¸ºä¾ï¼ä¹å¯ä»¥ç¨ç½æé®ç®±ï¼è¿ä¸ªåæä¹å设置zabbixé®ä»¶åè¦æ¶çé ç½®ä¸æ ·
smtp_auth_username: å¦æ没æ设置é®ç®±å«åï¼é£å°±æ¯è´¦æ·å
smtp_auth_password: é®ç®±çææç ï¼ä¸æ¯ è´¦æ·å¯ç ï¼ä½ å¯ä»¥å¨QQé®ç®±æè ç½æé®ç®±ç½é¡µç«¯è®¾ç½®ï¼å¼å¯ POP3/SMTP æå¡æ¶ä¼æ示ï¼åé ç½®zabbixé®ä»¶åè¦çæ¶åå ä¹ä¸æ ·
smtp_require_tls: æ¯å¦ä½¿ç¨ tlsï¼æ ¹æ®ç¯å¢ä¸åï¼æ¥éæ©å¼å¯åå ³éãå¦ææ示æ¥é email.loginAuth failed: Must issue a STARTTLS command firstï¼é£ä¹å°±éè¦è®¾ç½®ä¸º trueãçé说æä¸ä¸ï¼å¦æå¼å¯äº tlsï¼æ示æ¥é starttls failed: x: certificate signed by unknown authorityï¼éè¦å¨ email_configs ä¸é ç½® insecure_skip_verify: true æ¥è·³è¿ tls éªè¯ã
templatesï¼ åè¦æ¨¡æ¿ç®å½ï¼å¯ä»¥ä¸ç¼å模æ¿ï¼æé»è®¤æ¨¡æ¿
Subject: '{ { template "email.default.subject" . }}'
html: '{ { template "email.default.html" . }}'
routeï¼æ¥è¦çåå设置
group_byï¼åç»
group_wait: åç»çå¾ æ¶é´
group_interval: 5m æ¯ç»æ¶é´é´é
repeat_interval: m éå¤é´é
receiver: æ¥æ¶æ¹å¼ï¼è¯·æ³¨æï¼è¿éçååè¦å¯¹åºä¸é¢receiversä¸çä»»ä½ä¸ä¸ªååï¼ä¸ç¶ä¼æ¥éï¼è¿éå ¶å®å°±æ¯éæ©æ¹å¼ï¼æé®ç®±ï¼ä¼ä¸å¾®ä¿¡ï¼wehookï¼victoropsçç
receiversï¼æ¥åæ¹å¼æ±æ»ï¼å³åè¦æ¹å¼æ±æ»
ä¾åï¼
receivers:
- name:'default-receiver'
email_configs:
- to:'whiiip@.com'
html: '{ { template "alert.html" . }}'
headers: { Subject: "[WARN] æ¥è¦é®ä»¶test"}
inhibit_rules: æå¶è§å
å½åå¨ä¸å¦ä¸ç»å¹é çè¦æ¥ï¼æºï¼æ¶ï¼æå¶è§åå°ç¦ç¨ä¸ä¸ç»å¹é çè¦æ¥ï¼ç®æ ï¼ã
å æ¬æºå¹é åç®æ å¹é
alertmanagerå®æ¹æ¯è¿æ ·è¯´ç
Inhibition
Inhibition is a concept of suppressing notifications for certain alerts if certain other alerts are already firing.
Example: An alert is firing that informs that an entire cluster is not reachable. Alertmanager can be configured to mute all other alerts concerning this cluster if that particular alert is firing. This prevents notifications for hundreds or thousands of firing alerts that are unrelated to the actual issue.
Inhibitions are configured through the Alertmanager's configuration file.
å½åå¨ä¸å¦ä¸ç»å¹é å¨å¹é çè¦æ¥ï¼æºï¼æ¶ï¼ç¦æ¢è§åä¼ä½¿ä¸ä¸ç»å¹é å¨å¹é çè¦æ¥ï¼ç®æ ï¼éé³ãç®æ è¦æ¥åæºè¦æ¥çequalå表ä¸çæ ç¾å称é½å¿ é¡»å ·æç¸åçæ ç¾å¼ã
å¨è¯ä¹ä¸ï¼ç¼ºå°æ ç¾å带æ空å¼çæ ç¾æ¯åä¸ä»¶äºãå æ¤ï¼å¦æequalæºè¦æ¥åç®æ è¦æ¥é½ç¼ºå°ååºçæææ ç¾å称ï¼åå°åºç¨ç¦æ¢è§åã
为äºé²æ¢è¦æ¥ç¦æ¢èªèº«ï¼ä¸è§åçç®æ åæºç«¯ é½ å¹é çè¦æ¥ä¸è½è¢«è¦æ¥ï¼å æ¬å ¶æ¬èº«ï¼ä¸ºçæ¥ç¦æ¢ãä½æ¯ï¼æ们建议éæ©ç®æ å¹é å¨åæºå¹é å¨ï¼ä»¥ä½¿è¦æ¥æ°¸è¿ä¸ä¼åæ¶å¹é åæ¹ãè¿å¾å®¹æè¿è¡æ¨çï¼å¹¶ä¸ä¸ä¼è§¦åæ¤ç¹æ®æ åµã
æ¥çæ¯è§årules
ä¸è§£éäºï¼èªå·±ç 究å®æ¹ææ¡£
alertmanagerçé容å¨å®è£ æ¹å¼æ¯
wget /api-grammar.html中的tag修饰符
Tips学习源码推荐fork出来边看边写注释和心得,可以加深理解,源码酷炫的h5网页源码以后用到这块功能的源码纵横四海文字游戏源码时候也可以回头翻阅。
项目地址/zeromicro/go-zero
欢迎使用go-zero并star支持我们!源码h5手机网站源码下载
微信交流群关注『微服务实践』公众号并点击交流群获取社区群二维码。源码h5页面制作工具源码
源码源码2024-11-23 07:06
2024-11-23 06:52
2024-11-23 06:49
2024-11-23 05:56
2024-11-23 05:09