環境資訊
Prometheus 元件
下載下傳 & 安裝
通過指定配置檔案prometheus.yml啟動Prometheus
檢視采集到的性能名額
檢視prometheus規則
檢視監控對象
SpringBoot內建Prometheus
pom.xml
配置檔案
執行個體化MeterRegistryCustomizer
打包,上傳到伺服器上
Prometheus 修改配置檔案prometheus.yml 接入該工程
Grafana 元件
下載下傳 & 安裝 & 啟動Grafana
Grafana 接入Prometheus 的資料
Step1 添加Prometheus 資料源
Step2 設定相關資訊
Step3 導入想要的dashboards
OS: Centos7 (防火牆已經關閉)
IP: 192.168.31.34
APP: Spring Boot 2.1.3搭建的示範環境
官網: https://prometheus.io/
下載下傳位址: https://prometheus.io/download/
官方文檔: https://prometheus.io/docs/prometheus/latest/getting_started/
Prometheus是一套開源的監控&報警&時間序列資料庫的組合,基于應用的metrics來進行監控的開源工具 。
更多資訊請參考官網介紹: https://prometheus.io/docs/introduction/overview/
官網下載下傳速度太慢,我這裡就沒有使用最新版本,而是從 http://cactifans.hi-www.com 下載下傳了 prometheus-2.1.0的版本

配置檔案官方說明: https://prometheus.io/docs/prometheus/latest/configuration/configuration/
預設情況下,Prometheus會監控自己本身。
通路 http://192.168.31.34:9090/metrics
太多了,真是沒法看,還好有個弱弱的圖形頁面 (待會整合到Grafana 中就友善看了)
通路: http://192.168.31.34:9090/graph
選中某個名額,點選Execute . 超多名額可以檢視 …
如果使用properties
友善起見,我們就在啟動類中執行個體化吧
右鍵–Run As – Maven build ,輸入 <code>clean package</code>
伺服器上啟動該jar即可
增加如下配置:
重新開機Prometheus
通路 http://192.168.31.34:9090/targets
檢視配置檔案
服務自動發現
官網:https://grafana.com/
下載下傳位址: https://grafana.com/grafana/download
入門:http://docs.grafana.org/guides/getting_started/
剛才也說了,Prometheus 的可視化功能比較弱,這裡我們來接入Grafana 。
Grafana是一個跨平台的開源的度量分析和可視化工具,可以通過将采集的資料查詢然後可視化的展示,并及時通知。它主要有以下六大特點:
展示方式:快速靈活的用戶端圖表,面闆插件有許多不同方式的可視化名額和日志,官方庫中具有豐富的儀表盤插件,比如熱圖、折線圖、圖表等多種展示方式;
資料源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等;
通知提醒:以可視方式定義最重要名額的警報規則,Grafana将不斷計算并發送通知,在資料達到門檻值時通過Slack、PagerDuty等獲得通知;
混合展示:在同一圖表中混合使用不同的資料源,可以基于每個查詢指定資料源,甚至自定義資料源;
注釋:使用來自不同資料源的豐富事件注釋圖表,将滑鼠懸停在事件上會顯示完整的事件中繼資料和标記;
過濾器:Ad-hoc過濾器允許動态建立新的鍵/值過濾器,這些過濾器會自動應用于使用該資料源的所有查詢。
官網下載下傳速度太慢,我這裡就沒有使用最新版本,而是從 http://cactifans.hi-www.com 下載下傳了 grafana-5.4.2-1.x86_64.rpm的版本
配置檔案 /etc/grafana/grafana.ini , 預設3000端口,按需修改
通路 http://192.168.31.34:3000/login
預設的使用者名和密碼為 admin/admin
如何将 Prometheus 資料 添加到 Grafana 中,如下
Prometheus 官方指導 : https://prometheus.io/docs/visualization/grafana/
選擇 Prometheus
看闆位址: https://grafana.com/dashboards
可篩選
https://grafana.com/dashboards/4701
導入