(2)node_exporter部署监控容器主机

(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