新开一台服务器,做客户端
systemctl stop firewalld.service
setenforce 0
安装 node_exporter 收集数据
[root@pre3 ~]# tar zxf node_exporter-0.18.1.linux-amd64.tar.gz
[root@pre3 ~]# ls
anaconda-ks.cfg node_exporter-0.18.1.linux-amd64.tar.gz
node_exporter-0.18.1.linux-amd64
[root@pre3 ~]# mv node_exporter-0.18.1.linux-amd64 /usr/local/node_exporter
[root@pre3 ~]# cd /usr/local/node_exporter
[root@pre3 node_exporter]# ls
LICENSE node_exporter NOTICE
[root@pre3 node_exporter]# cp node_exporter /usr/local/bin/
[root@pre3 node_exporter]# node_exporter
服务端添加配置文件
[root@pre1 ~]# mkdir -p /usr/local/prometheus/target/{node,docker}
[root@pre1 ~]# cd /usr/local/prometheus/target/
[root@pre1 target]# ls
docker node
[root@pre1 target]# vim node/host_status.json
[
{
"targets": [ "192.168.122.103:9100" ],
"labels": {
"job": "node2-status",
"service": "node2"
}
}
]
修改 Prometheus 配置文件
[root@pre1 target]# vim /usr/local/prometheus/conf/prometheus.yml
- job_name: 'host-status'
file_sd_configs:
- files:
- "/usr/local/prometheus/target/node/host_status.json"
refresh_interval: 6s
重启 Prometheus
第一次引用,所以定义完成之后,需要重启一下,如果后续再添加节点,则直接写入json文件即可,无需重启Prometheus服务
[root@pre1 target]# systemctl restart prometheus.service
查看 Prometheus 监控
查看 Grafana 的数据