專案監控之Prometheus初體驗(一)

2021-10-03 15:53:00 字數 2037 閱讀 6605

最近由於工作的專案需要接入prometheus的監控體系,所以也花了一點時間在這方面的學習上,也體驗到了prometheus在專案監控的靈活性,這裡也稍微做點記錄以便日後用到時有個參考。以下的安裝主要使用docker進行安裝部署,其他環境主要為(centos 7,prometheus和grafana均為當前最新版本映象),本章主要是介紹了prometheus和grafana安裝及搭配使用(prometheus進行資料指標採集,grafana進行統一的視覺化的監控指標展示),後面有時間將繼續更新prometheus與專案的整合使用。

參考文件:

1)、安裝和執行

docker pull prom/prometheus

docker run -p 9090:9090 prom/prometheus

檢視容器啟動情況

(補充,想通過本地配置檔案執行的話可以參考)

1、拷貝容器中的prometheus.yml 檔案到本地目錄(/etc/prometheus)

注:prometheus.yml 為prometheus啟動時指定的配置檔案,用於配置監控位址等其他資訊,一般使用 --config.file 進行指定

docker cp 容器id:/etc/prometheus/prometheus.yml /etc/prometheus
2、停掉原來的prometheus容器(也可以不停,這裡是想繼續使用9090埠)

docker stop 容器id
3、啟動prometheus容器並以資料卷繫結的方式指定本地配置檔案

docker run -p 9090:9090 --name prometheus -d  -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  prom/prometheus
2)、指標的檢視

瀏覽器訪問 http://伺服器ip:9090 (埠號為容器對映的外部埠號)

參考文件:

1)、安裝和執行

docker pull grafana/grafana

docker run -d -p 3000:3000 --name grafana grafana/grafana

2)、grafana的使用

(1) 瀏覽器訪問 http://伺服器ip:3000 (埠號為容器對映的外部埠號),預設賬號密碼均為 admin

(2) 指定prometheus資料來源

(3) 視覺化面板的新增匯入

到此,專案監控的基本環境即已搭建完成,後續有時間繼續更新prometheus與專案的整合使用。

Prometheus 監控節點

tar xf node exporter 0.18.1.linux amd64.tar.gz cd node exporter 0.18.1.linux amd64 cp node exporter usr local bin 檢視版本 root server03 media prometheus ...

prometheus監控exporter部署

harbor exporter docker run d p 9107 9107 restart always network harbor harbor add host mec hub.21cn.com x.x.x.x e harbor username admin e harbor passw...

安裝prometheus監控

github位址包含docker compose安裝方法 元件介紹 prometheus server 包含資料採集scrapes job,stores time series data push gateway prometheus server的乙個 節點,當一些節點沒有提供http endpo...