发布时间:2020-03-10 10:40:21编辑:admin阅读(2756)
Node_exporter是可以在* Nix和Linux系统上运行的计算机度量标准的导出器。
Node_exporter 主要用于暴露 metrics 给 Prometheus,其中 metrics 包括:cpu 的负载,内存的使用情况,网络等。
操作系统:centos 7.6
ip地址:192.168.31.150
https://prometheus.io/download/
目前最新版是:0.18.1
下载链接:
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
useradd prometheus -s /sbin/nologin tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz -C /data/ mv /data/node_exporter-0.18.1.linux-amd64 /data/node_exporter chown prometheus:prometheus -R /data/node_exporter
vi /etc/systemd/system/node-exporter.service
内容如下:
[Unit] Description=Prometheus Node Exporter After=network.target [Service] ExecStart=/data/node_exporter/node_exporter User=prometheus [Install] WantedBy=multi-user.target
注意:主要修改ExecStart和User
设置开机自启动
systemctl daemon-reload systemctl enable node-exporter systemctl start node-exporter
查看端口
# ss -tunlp|grep node tcp LISTEN 0 128 :::9100 :::* users:(("node_exporter",pid=990,fd=3))
登录到prometheus服务器,备份配置文件
cd /data/prometheus cp prometheus.yml prometheus.yml.bak cat prometheus.yml.bak|grep -v '^#'|grep -v '^ #'|grep -v '^ #' > prometheus.yml
名字为:node_exporter
vi prometheus.yml
完整内容如下:
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. alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 rule_files: scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node_exporter' static_configs: - targets: - 'localhost:9100'
systemctl restart prometheus
http://192.168.31.150:9090/targets
效果如下:
确保状态为UP
47745
46237
37110
34627
29229
25886
24745
19863
19417
17909
5716°
6315°
5836°
5888°
6985°
5829°
5846°
6361°
6316°
7673°