Prometheus 使用之 node exporter


本文使用的 Prometheus 版本為 2.22.0,node exporter 版本為 1.0.1;部署在 Linux 服務器
Prometheus 是開源的監控報警系統和時序列數據庫 (TSDB);node exporter 用來監控服務器CPU、內存、磁盤、I/O等信息

一、node exporter

node exporter 下載地址:https://prometheus.io/download/#node_exporter,下載 node_exporter-1.0.1.linux-amd64.tar.gz
執行命令:

tar -xzvf node_exporter-1.0.1.linux-amd64.tar.gz
nohup ./xx/node_exporter-1.0.1.linux-amd64/node_exporter >/dev/null 2>&1 &
`

其中 xx 為自定義目錄
默認端口為 9100

二、Prometheus

Prometheus 下載地址:https://prometheus.io/download/#prometheus,下載 prometheus-2.22.0.linux-amd64.tar.gz
執行命令:

tar -xzvf prometheus-2.22.0.linux-amd64.tar.gz

在 prometheus.yml 文件末尾添加:

scrape_configs:
  ... ...
  - job_name: 'node'
    static_configs:
    - targets: ['localhost:9100']

啟動 Prometheus:

nohup /xx/prometheus-2.22.0.linux-amd64/prometheus \
--config.file=/xx/prometheus-2.22.0.linux-amd64/prometheus.yml \
--storage.tsdb.path=/xx/data/prometheus \
--storage.tsdb.retention=7d \
/dev/null 2>&1 &

其中 xx 為自定義目錄
默認端口為 9090

三、在 Grafana 中添加數據源與看板

3.1. 添加數據源

  1. 登錄 Grafana,在 Configuration > Data Sources 點擊 “Add data source” 按鈕,選中 Prometheus
  2. URL 填入 http://localhost:9090,並保存

    3.2. 添加看板

  3. 在 “+” 點擊 “Import”
  4. 在 “Import via grafana.com” 下面的輸入框,輸入 8919,然后點擊”Load”按鈕
  5. 在 Dashboards 即可看到面板列表
    關於 8919 的解釋:
    Grafana 官網有已經可以直接使用的 dashboard,地址:https://grafana.com/grafana/dashboards 輸入對應的 id 即可添加


免責聲明!

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



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