安装node_exporter
下载
解压
tar -zxvf node_exporter-1.7.0.linux-amd64.tar.gz
运行
nohup ./node_exporter &
出现监听端口就代表成功了
[root@aspfj738vhd034j node_exporter-1.7.0.linux-amd64]# tail -f nohup.out
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=thermal_zone
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=time
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=timex
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=udp_queues
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=uname
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=vmstat
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=xfs
ts=2024-01-02T06:02:21.028Z caller=node_exporter.go:117 level=info collector=zfs
ts=2024-01-02T06:02:21.030Z caller=tls_config.go:274 level=info msg="Listening on" address=[::]:9100
ts=2024-01-02T06:02:21.030Z caller=tls_config.go:277 level=info msg="TLS is disabled." http2=false address=[::]:9100
修改Prometheus容器内的配置文件
[root@aspfj738vhd034j node_exporter-1.7.0.linux-amd64]# docker exec -it prometheus /bin/sh
/prometheus $ vi /etc/prometheus/prometheus.yml
添加如下三行
- job_name: 'node'
static_configs:
- targets: [142.171.235.206:9100]
然后保存退出,重启prometheus容器
docker restart prometheus
进入prometheus的web界面,node的状态为up代表成功
设置node_exporter为系统服务
编辑服务文件
cat /usr/lib/systemd/system/node_exporter.service
添加如下内容
[Unit]
Description=node_exporter
[Service]
ExecStart=/soft/node_exporter-1.7.0.linux-amd64/node_exporter --web.listen-address=:9100
Restart=on-failure
[Install]
WantedBy=multi-user.target
重载服务
systemctl daemon-reload
启动服务
systemctl restart node_exporter.service
查看服务状态
systemctl status node_exporter.service
设置服务开机自启
systemctl enable node_exporter.service
发表评论