目录
一、简介
二、下载安装
一、简介
Exporter是Prometheus的指标数据收集组件。它负责从目标Jobs收集数据,并把收集到的数据转换为Prometheus支持的时序数据格式。 和传统的指标数据收集组件不同的是,他只负责收集,并不向Server端发送数据,而是等待Prometheus Server 主动抓取
因为环境原因,网络不可达的场景,Prometheus可以使用Pushgateway这个组件推送node-exporter的指标数据到远端Prometheus,node-exporter用于采集node的运行指标,包括node的cpu、load、filesystem、meminfo、network等基础监控指标,node-exporter由Prometheus官方提供、维护,属于监控指标收集类UNIX内核操作系统的必备的exporter。
二、下载安装
官网
[root@rabbitmq_2 prometheus]# wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
[root@rabbitmq_2 prometheus]# tar -zxvf node_exporter-1.7.0.linux-amd64.tar.gz
[root@rabbitmq_2 prometheus]# mv node_exporter-1.7.0.linux-amd64 /opt/prometheus/node_exporter
[root@rabbitmq_2 prometheus]# chown -R prometheus:prometheus /opt/prometheus
使用ansible批量安装
- hosts: nodes_exporter
vars:
- node_exporter_package: node_exporter-1.7.0.linux-amd64.tar.gz
- package_version: node_exporter-1.7.0.linux-amd64
tasks:
- name: copy node_exporter_pkg
copy:
src: ./{{node_exporter_package}}
dest: /opt/prometheus/{{node_exporter_package}}
owner: root
group: root
mode: 0644
- name: "Copy Node_Exporter SystemctlFile"
copy:
src: ./node_exporter.service
dest: /usr/lib/systemd/system/node-exporter.service
owner: root
group: root
mode: 0644
- name: "Unzip"
unarchive:
src: /opt/prometheus/{{node_exporter_package}}
dest: /opt/prometheus/node_exporter
remote_src: yes
mode: 0755
notify:
- "ln -sv"
handlers:
- name: "ln -sv"
file:
src: /opt/prometheus/{{package_version}}
dest: /opt/prometheus/node_exporter
state: link
ansible-playbook -i hosts -e variable_host="nodes_exporter" node_exporter_install.yml
创建systemd服务
vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/opt/prometheus/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动
[root@rabbitmq_2 node_exporter]# systemctl daemon-reload
[root@rabbitmq_2 node_exporter]# systemctl start node_exporter.service
[root@rabbitmq_2 node_exporter]# systemctl status node_exporter.service
访问web地址
http://192.168.134.133:9100/metrics
把node_exporter加到prometheus服务
[root@rabbitmq_2 prometheus]# vim prometheus.yml
在scrape_configs 这行下边添加如下配置
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
# node_exporter配置
- job_name: "node_exporter"
scrape_interval: 15s
static_configs:
- targets: ["localhost:9100"]
labels:
instance: Prometheus服务器
重新载入配置
curl -X POST http://192.168.134.133:9090/-/reload
或
systemctl reload prometheus