一、下载与安装
1、下载
curl -OL https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
2、安装
将下载的文件解压到合适目录。
>tar -xzf node_exporter-1.0.1.linux-amd64.tar.gz >cd node_exporter-1.0.1.linux-amd64 >mv node_exporter /usr/local/bin
二、配置服务
设置开机自启服务。
vi /etc/systemd/system/node-exporter.service
配置内容如下:
[Unit] Description=Prometheus Node Exporter After=network.target [Service] ExecStart=/usr/local/bin/node_exporter User=root [Install] WantedBy=multi-user.target
重新加载daemon
。
>systemctl daemon-reload >systemctl enable node-exporter Created symlink from /etc/systemd/system/multi-user.target.wants/node-exporter.service to /etc/systemd/system/node-exporter.service. >systemctl start node-exporter >systemctl status node-exporter node-exporter.service - Prometheus Node Exporter Loaded: loaded (/etc/systemd/system/node-exporter.service; enabled; vendor preset: disabled) Active: active (running) since 四 2020-11-26 23:50:30 CST; 5s ago Main PID: 1343 (node_exporter) CGroup: /system.slice/node-exporter.service └─1343 /usr/local/bin/node_exporter
查看端口。
>ss -tunlp|grep node tcp LISTEN 0 128 [::]:9100 [::]:* users:(("node_exporter",pid=1343,fd=3))
三、访问服务
访问服务器http://IP:9100/metrics
地址,能够得到如下响应:
四、配置采集节点到 Prometheus
找到prometheus.yml
配置文件,添加node-exporter
节点,默认包含自身监听。
scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node_exporter' static_configs: - targets: - '部署Node-Exporter对应主机IP:9100'
重启Prometheus服务,访问http://localhost:9090/targets
,出现如下列表则表示采集节点配置成功。