(2)node_exporter部署監控容器主機

監控容器服務器CPU、內存、磁盤、I/O等信息,首先需要安裝node_exporter。node_exporter的作用是用於機器系統數據收集。

(1)下載node_exporter
https://prometheus.io/download/
shell> cd /Download/
shell> wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

(2)解壓安裝
shell> tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz
shell>cd node_exporter-0.18.1.linux-amd64
shell> mv node_exporter-0.18.1.linux-amd64 node_exporter
shell> chown -R prometheus.prometheus node_exporter
shell> systemctl restart node_exporter
shell>systemctl status node_exporter
shell>netstat -tunlp | grep node_exporter

(3)創建systemd服務
shell>cat > /etc/systemd/system/node_exporter.service << EOF
[Unit]
Description=node_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/Download/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF

shell>systemctl daemon-reload
shell> systemctl start node_exporter #啓動node_exporter服務
shell> systemctl status node_exporter

(4)prometheus_server 中添加job
shell> vim /Download/prometheus/prometheus.yml

  • job_name: 'docker39'
    scrape_interval: 5s
    static_configs:
    • targets: ['10.10.204.39:9100']
      labels:

shell>systemctl restart prometheus #重啓prometheus服務

(5)查看prometheus控制檯是否獲取到了數據
瀏覽器->x.x.x.x:9090 ->status->targets 就可以看到所監控的node

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章