官网地址:https://prometheus.io/download/#node_exporter
1.安装Node_Exporter
cd /opt/tools
wget https://github.com/prometheus/node_exporter/releases/download/v1.1.1/node_exporter-1.1.1.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/v1.1.0/node_exporter-1.1.0.linux-amd64.tar.gz
tar -xvf node_exporter-1.1.1.linux-amd64.tar.gz
mv node_exporter-1.1.1.linux-amd64 ../node_exporter
cd ../node_exporter
2.运行node exporter:
./node_exporter
3.Node Exporter收集监控数据
#编辑prometheus.yml并在scrape_configs节点下添加以下内容:
vim /opt/prometheus/prometheus.yml
scrape_configs:
...
# 采集node exporter监控数据
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
...
重新启动Prometheus Server
访问http://localhost:9090,进入到Prometheus Server。如果输入“up”并且点击执行按钮以后:
如果Prometheus能够正常从node exporter获取数据,则会看到以下结果:
up{instance="localhost:9090",job="prometheus"} 1
up{instance="localhost:9100",job="node"} 1
其中“1”表示正常,反之“0”则为异常。
4.可视化监控数据
导入模版 8919
gitlab 地址 https://github.com/starsliao/Prometheus
5.systemd启动
cat > /usr/lib/systemd/system/node_exporter.service <<EOF
[Unit]
Description=node_exporter
After=syslog.target
After=network.target
[Service]
Type=simple
ExecStart=/opt/node_exporter/node_exporter
Restart=always
RestartSec=10
StartLimitInterval=100
[Install]
WantedBy=multi-user.target
EOF