Prometheus+grafana監控linux


10.47.92.186    需要安裝的軟件:grafana,prometheus

10.81.44.176    需要安裝的軟件:node_exporter

一.安裝grafana(下載地址https://grafana.com/grafana/download)

在10.47.92.186服務器上執行以下操作
1.wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.0-1.x86_64.rpm 
rpm -ivh grafana-5.3.0-1.x86_64.rpm 
yum install urw-fonts -y
rpm -ivh grafana-5.3.0-1.x86_64.rpm

2.vi /etc/grafana/grafana.ini,修改如下值
;#################################### Dashboard JSON files ##########################
[dashboards.json]
;enabled = true
;path = /var/lib/grafana/dashboards

3.grafana-dashboards下載地址https://github.com/percona/grafana-dashboards
將grafana-dashboards/dashboards目錄下文件上傳到/var/lib/grafana/dashboards

4.systemctl daemon-reload
service grafana-server start

5.訪問地址http://10.47.92.186:3000

 

二.安裝node_exporter

在10.81.44.176服務器上執行以下操作(注意node_exporter的版本號必須是0.15.0,否則下面的system overview將搜集不到數據)

1.cd /app

wget https://github.com/prometheus/node_exporter/releases/download/v0.15.0/node_exporter-0.15.0.linux-amd64.tar.gz

tar xvf  node_exporter-0.15.0.linux-amd64.tar.gz

nohup /app/node_exporter-0.15.0.linux-amd64/node_exporter & > /dev/null &

 

2.判斷node_exporter是否啟動成功

root@iZbp1dey0fcjb1t6dhtnafZ:[/app]netstat -anp | grep 9100

tcp6       0      0 :::9100                 :::*                    LISTEN      25980/node_exporter 

 

三.安裝prometheus(下載地址https://github.com/prometheus/prometheus/releases)

在10.47.92.186服務器上執行以下操作
1.tar xvf prometheus-2.4.3.linux-amd64.tar.gz
cd prometheus-2.4.3.linux-amd64

2.vi prometheus.yml,其中10.47.92.186為數據庫服務器IP,添加以下紅色字體部分

global:

  scrape_interval:     15s

  evaluation_interval: 30s

  scrape_timeout:      10s

  external_labels:

    monitor: 'prometheus-server'

 

rule_files:

  - 'prometheus.rules.yml'

 

scrape_configs:

- job_name: zxy9_db_linux

  static_configs:

    - targets: ['10.81.44.176:9100']

      labels:

        instance: zxy9_db

 

3.啟動prometheus

cd /app/prometheus-2.4.3.linux-amd64
nohup ./prometheus & > /dev/null &

 

4.訪問prometheus,默認端口9090,10.47.92.186為prometheus服務器IP

http://10.47.92.186:9090/

 

四.配置grafana與prometheus的關聯性

1.登陸grafana,訪問地址為http://10.47.92.186:3000/,10.47.92.186為grafana服務器IP

2.導入dashboard

點擊Upload .json File,選擇具體的模版

dashboard的json文件是System_Overview.json文件鏈接如下

System_Overview.json

導入成功之后,可以看到導入成功后的dashboard

 


免責聲明!

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



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