下载地址:
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
1.1安装
tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz
sudo groupadd -r prometheus
sudo useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus
mv node_exporter-0.18.1.linux-amd64 /usr/local/exporter/
cat > /usr/lib/systemd/system/node_exporter.service << EOF
[Unit]
Description=node_exporter
After=network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/usr/local/exporter/node_exporter \
--web.listen-address=:20001 \
--collector.systemd \
--collector.systemd.unit-whitelist=(sshd|nginx).service \
--collector.processes
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now node_exporter
1.2访问测试
curl http://localhost:20001/metrics
1.3 编辑prometheus.yaml文件,加入以下内容
- job_name: 'node_exporter'
static_configs:
- targets: ['*:20001']