prometheus+grafana實現服務監控


一、安裝prometheus:

下載相應的版本 :https://prometheus.io/download/ 

解壓:

Linux:tar -zxvf XXX.tar.gz

windows:直接下載.ism 安裝程序

mac:未使用過

 

進入到解壓后的文件夾可以直接運行:

 ./prometheus --config.file=prometheus.yml

瀏覽器打開“http://localhost:9090” 訪問

 

 

 

二、配置啟動項

方法1 直接在prometheus.yml進行配置(監控內容較少的時候):

  

  - job_name: 'linux' 
    static_configs:
    - targets: ['localhost:9104']

 

方法2 指定配置文件 :

  

# prometheus.yml 配置
  - job_name: 'Linux'
    file_sd_configs:
    - files: ['/opt/prometheus/sd_cfg/Linux.yml']
# /opt/prometheus/sd_cfg/Linux.yml 中文件配置
- targets: ['IP地址:9100']
  labels:
    name: Linux-node1[這里建議給每個主機打個有意義的標簽,方便識別.]

 

配置文件檢查命令(檢查配置是否存在錯誤):

./promtool check config prometheus.yml

 

配置文件詳解:

 

創建專用用戶:

groupadd prometheus
useradd -g prometheus -m -d /opt/prometheus/ -s /sbin/nologin prometheus

 

二、配置 Linux系統監控

node_exporter 服務安裝:

下載地址:https://github.com/prometheus/node_exporter/releases/

解壓命令:tar -zxvf node_exporter-xxx.tar.gz

解壓完成 進入解壓文件夾: cd node_exporter-xxx

啟動: ./node_exporter

成功效果

 

 

 

 

三、安裝配置Grafana

下載地址:https://grafana.com/grafana/download

安裝編譯:yum localinstall grafana-xxx.rpm

安裝完成訪問 : http://localhost:3000 

默認賬號/密碼:admin/admin

 

 配置  node_exporter監控:

網址和服務名稱填寫就可以了。

 

 

添加統計圖模板:

模板網址:https://grafana.com/grafana/dashboards

找到模板ID

 

填寫模板ID 

 

 效果:

 

教程地址:https://www.cnblogs.com/guoxiangyue/p/11772717.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM