Prometheus(普羅米修斯)是一套開源的監控&報警&時間序列數據庫的組合,由 SoundCloud 公司開發。
Prometheus 基本原理是通過 HTTP 協議周期性抓取被監控組件的狀態,這樣做的好處是任意組件只要提供 HTTP 接口就可以接入監控系統,不需要任何 SDK 或者其他的集成過程。這樣做非常適合虛擬化環境比如 VM 或者 Docker 。
Prometheus 應該是為數不多的適合 Docker、Mesos、Kubernetes 環境的監控系統之一。
易于管理:
強大的查詢語言 PromQL:
高效:
可擴展:
sharding
)+ 聯邦集群(federation
)可以對其進行擴展。易于集成:
可視化:
如上圖,Prometheus 主要由以下部分組成:
Prometheus
:主要是負責存儲、抓取、聚合、查詢方面。Alertemanager
:主要是負責實現報警功能。Pushgateway
:主要是實現接收有 Client-push 過來的指標數據,在指定的時間間隔,有主程序來抓取。*_exporter
:主要是負責采集物理機、中間件的信息。準備工作:
主機名 | 操作系統 | IP 地址 |
---|---|---|
Prometheus | CentOS 7.4 | 192.168.1.1 |
Client | CentOS 7.4 | 192.168.1.2 |
Granfana | CentOS 7.4 | 192.168.1.3 |
ntpdate
工具,并進行時間同步(因為 Prometheus 對時間要求非常嚴格)yum -y install ntpdate/usr/sbin/ntpdate ntp1.aliyun.com
[root@Prometheus ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.16.0/prometheus-2.16.0.linux-amd64.tar.gz[root@Prometheus ~]# tar xf prometheus-2.16.0.linux-amd64.tar.gz[root@Prometheus ~]# mv prometheus-2.16.0.linux-amd64 /usr/local/prometheus
[root@Prometheus ~]# useradd -s /sbin/nologin prometheus[root@Prometheus ~]# chown -R prometheus:prometheus /usr/local/prometheus/
[root@Prometheus ~]# vim /usr/lib/systemd/system/prometheus.service[Unit]Description=prometheusAfter=network.target [Service]User=prometheusGroup=prometheusWorkingDirectory=/usr/local/prometheusExecStart=/usr/local/prometheus/prometheus[Install]WantedBy=multi-user.target
[root@Prometheus ~]# systemctl daemon-reload[root@Prometheus ~]# systemctl enable --now prometheus# 啟動并開啟自啟
當啟動 Prometheus 后,便可以通過 9090
端口來訪問 Prometheus 自帶的 UI 界面:
/usr/local/prometheus/data
目錄,存儲數據的大小受限和擴展不便;influxdb
作為后端的數據庫來存儲數據。1)安裝
[root@Prometheus ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.8.x86_64.rpm[root@Prometheus ~]# yum -y localinstall influxdb-1.7.8.x86_64.rpm[root@Prometheus ~]# cp /etc/influxdb/influxdb.conf /etc/influxdb/influxdb.conf.default[root@Prometheus ~]# systemctl enable --now influxdb
2)驗證
[root@Prometheus ~]# influxConnected to http://localhost:8086 version 1.7.8InfluxDB shell version: 1.7.8> create database prometheus;> exit
3)配置 Prometheus 集成 infuxdb
[root@Prometheus ~]# vim /usr/local/prometheus/prometheus.yml在最后面添加:remote_write: - url: "http://localhost:8086/api/v1/prom/write?db=prometheus"remote_read: - url: "http://localhost:8086/api/v1/prom/read?db=prometheus"[root@Prometheus ~]# systemctl restart prometheus# 重啟 Prometheus
influxdb
配置密碼,請參考 官網文檔 來進行配置。[root@Client ~]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz[root@Client ~]# tar xf node_exporter-0.18.1.linux-amd64.tar.gz[root@Client ~]# mv node_exporter-0.18.1.linux-amd64 /usr/local/exporter/
[root@Client ~]# vim /usr/lib/systemd/system/node_exporter.service[Unit]Description=node_exporterAfter=network.target [Service]User=prometheusGroup=prometheusExecStart=/usr/local/exporter/node_exporter --web.listen-address=:20001 --collector.systemd --collector.systemd.unit-whitelist=(sshd|nginx).service --collector.processes[Install]WantedBy=multi-user.target[root@Client ~]# systemctl daemon-reload[root@Client ~]# systemctl enable --now node_exporter
當啟動 node_exporter
服務后,便可以通過 20001
端口來訪問 Client 的監控指標。
[root@Prometheus ~]# vim /usr/local/prometheus/prometheus.yml- job_name: "Client" static_configs: - targets: - "192.168.1.2:20001"[root@Prometheus ~]# systemctl restart prometheus
[root@Grafana ~]# wget https://dl.grafana.com/oss/release/grafana-6.1.4-1.x86_64.rpm[root@Grafana ~]# tar xf grafana-6.1.4-1.x86_64.rpm[root@Grafana ~]# systemctl enable --now grafana-server[root@Grafana ~]# netstat -anpt | grep 3000
Add data source(添加數據源)
Import(導入模板)
161737.html
本文由 貴州做網站公司 整理發布,部分圖文來源于互聯網,如有侵權,請聯系我們刪除,謝謝!
網絡推廣與網站優化公司(網絡優化與推廣專家)作為數字營銷領域的核心服務提供方,其價值在于通過技術手段與策略規劃幫助企業提升線上曝光度、用戶轉化率及品牌影響力。這...
在當今數字化時代,公司網站已成為企業展示形象、傳遞信息和開展業務的重要平臺。然而,對于許多公司來說,網站建設的價格是一個關鍵考量因素。本文將圍繞“公司網站建設價...
在當今的數字化時代,企業網站已成為企業展示形象、吸引客戶和開展業務的重要平臺。然而,對于許多中小企業來說,高昂的網站建設費用可能會成為其發展的瓶頸。幸運的是,隨...
北京到麗江有高鐵嗎?目前北京沒有直達麗江的高鐵。不僅沒有直達云南麗江的高鐵,也沒有直達列車。如果一定要坐高鐵從北京到麗江,只能坐高鐵從北京到云南昆明。到達昆明后,換乘D字頭雙層旅游列車,從昆明可以直達麗江。北京到麗江自駕游最佳路線攻略?走京石高速岳各莊大橋、京昆高速、石太高速、太舊高速、太元高速、大云高速、運城、Xi安高速、侯鈺高速、西玉高速、潼關高速、戶縣高速、西漢高速、赫爾高速。走108國道到...
蘋果4電池輸出多少?蘋果4電池輸出2.3毫安。4 iPhone4電池容量為1420mA鋰電池,待機時間300小時,視頻播放時間10小時,音頻播放時間40小時。這些是理論上的待機時間!IPhone是一種結合了照相手機、個人數字助理、媒體播放器和無線通信設備的手持設備。它由蘋果CEO史蒂夫喬布斯于2007年1月9日在Macworld上宣布,并于2007年6月29日在美國上市。iPhone 4還有電池...
itunes怎么下載軟件?當前版本的iTunxp系統如何下載itunes軟件?在蘋果官網下載相應的win版本即可。怎樣查看iTunes正在下載軟件?下載軟件后,可以在iTun怎么下載itunes安裝到電腦?1.點擊開始菜單或者點擊win10系統的win圖標打開,找到app storitunes怎么安裝到電腦?1.點擊開始菜單或者點擊win10系統的win圖標打開,找到app storitunes里...