Centos7.x安装Node_exporter
下载安装Node_exporter
NODE_PATH='/data/prometheus/node_exporter/' cd /usr/local/src/ mkdir -p ${NODE_PATH} wget https://github.com/prometheus/node_exporter/releases/download/v0.18.0/node_exporter-0.18.0.linux-amd64.tar.gz tar -xvf node_exporter-0.18.0.linux-amd64.tar.gz cp node_exporter-0.18.0.linux-amd64/node_exporter ${NODE_PATH} chown -R prometheus.prometheus ${NODE_PATH}
配置Node_exporter系统服务
cat > /lib/systemd/system/node_exporter.service <<EOF [Unit] Description=node_exporter Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus/node_exporter/node_exporter Restart=on-failure [Install] WantedBy=multi-user.target EOF
现在使用下面的systemctl命令重新加载systemd系统,并查看服务是否启动
systemctl daemon-reload systemctl enable node_exporter.service systemctl start node_exporter.service systemctl status node_exporter.service
查看端口是否正常
netstat -plntu |grep9100
这里需要放行9100端口
访问http://IP:9100/metrics
如果出现上图,就成功啦!!!
最后一步,配置prometheus.yml
如果是跟着我的安装步骤走的话,它的路径是 /data/prometheus/conf
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] # 主要是新增了node_exporter的job,如果有多个node_exporter,在targets数组后面加即可 - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100']
配置Grafana
这里就不展开如何安装Grafana了哈,不懂的可以查看这篇博客:https://www.cnblogs.com/poloyy/p/12219145.html
配置完之后,就能自动读取prometheus存储的数据,然后就dengdengdengdeng!!厉酷炫吧!!
如果你读取失败,请务必检查自己的prometheus和Node_exporter是否有安装成功,通过访问9090和9100端口的网址来判断即可!