国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Prometheus實戰(zhàn)-從0構建高可用監(jiān)控平臺(二)

2023-04-25 23:40 作者:小毛驢的爛筆頭  | 我要投稿

當今的互聯(lián)網(wǎng)應用系統(tǒng)越來越復雜,其中涉及的組件和服務越來越多,需要進行高效、可靠的監(jiān)控,以保證系統(tǒng)的穩(wěn)定性和性能。Prometheus是一款功能強大的開源監(jiān)控系統(tǒng),可以實時監(jiān)控多個維度的指標數(shù)據(jù),并支持強大的查詢語言和告警機制,是目前廣泛使用的云原生應用監(jiān)控系統(tǒng)之一。

本文檔合集《Prometheus實戰(zhàn):從0構建高可用監(jiān)控平臺》將從零開始,手把手教您如何構建一套高可用的Prometheus監(jiān)控平臺,涵蓋了以下內容:

  1. Prometheus集群搭建:實現(xiàn)高可用和可擴展的監(jiān)控系統(tǒng)

  2. 動態(tài)監(jiān)控指標:自動發(fā)現(xiàn)和注冊要監(jiān)控的目標

  3. ?告警機制配置:靈活配置告警規(guī)則、分組、過濾、抑制,實時通知異常情況

  4. Grafana可視化展示:直觀了解系統(tǒng)運行狀態(tài)和趨勢

本文檔合集的目標讀者是具有一定Linux系統(tǒng)和網(wǎng)絡知識的系統(tǒng)管理員和DevOps工程師。通過本文檔合集的學習,您將掌握Prometheus的核心概念和實踐技巧,能夠快速搭建一套高效、可靠的監(jiān)控平臺,幫助您更好地管理和維護復雜的互聯(lián)網(wǎng)應用系統(tǒng)。

本文內容是基于Thanos安裝一個高可用和可擴展的Prometheus集群。

基礎信息見上一篇文章,這篇主要介紹Prometheus集群搭建和配置注意事項

Prometheus全家桶

如之前規(guī)劃,node2 和 node3 都安裝 Prometheus , Alertmanager, PrometheusAlert.

Prometheus集群安裝

node2 node3 都執(zhí)行以下安裝內容

cd?/usr/local/src/
wget?https://github.com/prometheus/prometheus/releases/download/v2.37.0/prometheus-2.37.0.linux-amd64.tar.gz
tar?xf?prometheus-2.37.0.linux-amd64.tar.gz?-C?/usr/local
ln?-sv?/usr/local/prometheus-2.37.0.linux-amd64?/usr/local/prometheus

groupadd?-r?prometheus
useradd?-r?-g?prometheus?-s?/sbin/nologin?-c?"prometheus?Daemons"?prometheus

mkdir?/data/prometheus
chown?-R?prometheus.?/data/prometheus
chown?prometheus:prometheus?/usr/local/prometheus/?-R


cat?>?/etc/systemd/system/prometheus.service?<<EOF
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus?--config.file=/usr/local/prometheus/prometheus.yml?--web.enable-admin-api?--web.enable-lifecycle?--storage.tsdb.path=/data/prometheus?--storage.tsdb.retention=15d
ExecReload=/bin/kill?-HUP?$MAINPID
Restart=on-failure
LimitNOFILE=655350
LimitNPROC=655350
LimitCORE=infinity
[Install]
WantedBy=multi-user.target
EOF

systemctl?daemon-reload
systemctl?start?prometheus
systemctl?enable?prometheus

允許用戶通過HTTP請求來查詢、配置和管理Prometheus實例。

//?啟動時候添加參數(shù)--web.enable-admin-api
/usr/local/prometheus/prometheus?--config.file=/usr/local/prometheus/prometheus.yml?--web.enable-admin-api?--storage.tsdb.path=/data/prometheus

curl?-X?POST?-g?'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={job="JMX"}'

Config

上面設置好就可以配置采集節(jié)點和告警規(guī)則。具體見后面文章

mkdir?/usr/local/prometheus/{rules,targets}

Prometheus配置文件

global:
??external_labels:
????region:?"fb"
alerting:
??alertmanagers:
????-?static_configs:
??????-?targets:
????????-?10.2.0.27:19093
rule_files:
??-?"rules/*.yml"
scrape_configs:
??-?job_name:?'consul-exporter'
????metrics_path:?/metrics
????scheme:?http
????consul_sd_configs:
??????-?server:?localhost:8500
????????token:?'xxxxxxxx'
????????services:?['consul_exporter']
????relabel_configs:
??????-?regex:?__meta_consul_service_metadata_(.+)
????????action:?labelmap
??
??-?job_name:?"prometheus"
????static_configs:
??????-?targets:
????????-?'10.2.0.10:9090'
????????-?'10.2.0.41:9090'
??-?job_name:?"alertmanager"
????static_configs:
??????-?targets:
????????-?'10.2.0.10:9093'
????????-?'10.2.0.41:9093'
remote_write:
??-?url:?http://10.2.0.6:10908/api/v1/receive
????headers:
??????THANOS-TENANT:?fb
??-?url:?http://10.2.0.10:10908/api/v1/receive
????headers:
??????THANOS-TENANT:?fb
??-?url:?http://10.2.0.41:10908/api/v1/receive
????headers:
??????THANOS-TENANT:?fb

注意點:

  1. ?node2 和 node3 是同一業(yè)務線的高可用的Prometheus集群,故兩個節(jié)點配置一樣。同其他業(yè)務線區(qū)別使用external_labels(這個配置項也是thanos做數(shù)據(jù)去重的重要依據(jù)), 如:

global:
??external_labels:
????region:?"bf"

  1. ?安裝之前的規(guī)劃,Alertmanager 是主備模式,這個地方填的是 keepalived 配置的 vip (haproxy),見下一篇文章。

  2. 這里配置了一個consul_sd_configs,方便動態(tài)添加收集節(jié)點 , token對應上篇文章cosul安裝的時候生成的token。

添加服務的功能腳本見:?https://mp.weixin.qq.com/s/rXMsnY-j_xQj9JiKhllOqQ

  1. ?由于prometheus 和 alertmanager 一般不會變,這里使用了static_configs收集相關服務的指標數(shù)據(jù)。

  2. ?remote_write 對應 上篇文章 -- Receive配置。


Prometheus實戰(zhàn)-從0構建高可用監(jiān)控平臺(二)的評論 (共 條)

分享到微博請遵守國家法律
休宁县| 宕昌县| 二手房| 兴文县| 尖扎县| 江城| 蓝田县| 元氏县| 南昌县| 方城县| 确山县| 舞阳县| 金湖县| 高阳县| 汉中市| 崇左市| 义乌市| 广西| 甘泉县| 北票市| 固原市| 浏阳市| 嘉善县| 库车县| 新密市| 五大连池市| 华池县| 曲阳县| 新蔡县| 佛山市| 凌海市| 镇康县| 盖州市| 凤阳县| 习水县| 西乌珠穆沁旗| 南和县| 淮滨县| 施甸县| 廊坊市| 奉化市|