1.node_exporter介绍
2.二进制部署node_exporter
3.docker部署node_exporter
1.node_exporter介绍
Node-exporter 可以采集机器(物理机、虚拟机、云主机)的监控指标数据,能够采集到的指标包括cpu、内存、磁盘、网络、文件数等信息。
2.二进制部署node_exporter
#下载软件包
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
#解压软件包
tar xf node_exporter-1.5.0.linux-amd64.tar.gz
#做软连接
mv node_exporter-1.5.0.linux-amd64 node_exporter-1.5.0
ln -s node_exporter-1.5.0 node_exporter
#做systemd启动文件
cat /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=Prometheus node_exporter
[Service]
User=nobody
ExecStart=/opt/node_exporter/node_exporter --log.level=error
ExecStop=/usr/bin/killall node_exporter
[Install]
WantedBy=default.target
#检查node_exporter是否启动
root@RainGod:/opt# systemctl daemon-reload
root@RainGod:/opt# systemctl start node_exporter.service
root@RainGod:/opt# systemctl status node_exporter.service
● node_exporter.service - Prometheus node_exporter
Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2023-01-23 13:44:18 GMT; 8s ago
Main PID: 2905779 (node_exporter)
Tasks: 4 (limit: 1101)
Memory: 2.1M
CGroup: /system.slice/node_exporter.service
└─2905779 /opt/node_exporter/node_exporter --log.level=error
Jan 23 13:44:18 RainGod systemd[1]: Started Prometheus node_exporter.
root@RainGod:/opt# ss -nutlp|grep 9100
tcp LISTEN 0 4096 *:9100 *:* users:(("node_exporter",pid=2905779,fd=3))
root@RainGod:/opt# curl localhost:9100/metrics |grep cpu
# TYPE node_cpu_guest_seconds_total counter
node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0
node_cpu_guest_seconds_total{cpu="0",mode="user"} 0
# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 1.935248206e+07
node_cpu_seconds_total{cpu="0",mode="iowait"} 2597.66
node_cpu_seconds_total{cpu="0",mode="irq"} 0
docker部署node_exporter
docker run --name node-exporter -d \
--restart=always \
-p 9100:9100 \
-v "/proc:/host/proc:ro" \
-v "/sys:/host/sys:ro" \
-v "/:/rootfs:ro" \
--net="host" \
prom/node-exporter
标签:node,opt,exporter,seconds,Prometheus,total,cpu
From: https://www.cnblogs.com/yangtao416/p/17065583.html