node_exporter
是一个 Prometheus 数据采集器,用于收集节点的监控指标数据,默认监听端口为9010。
介绍
node_exporter
支持采集系统的指标winlogbeat
本质是一个轻量的Beat,基于libbeat框架,用来采集 Windows 事件和日志等- 其他 exporter
- Blackbox Exporter 用于探测 HTTPS、HTTP、TCP、DNS、ICMP 和 grpc 等 Endpoint
- 在定义 Endpoint 后,Blackbox Exporter 会生成指标,可以使用 Grafana 等工具进行可视化
- 使用场景:探测外部 URL/K8S 集群内部 service、pod、ingress
安装
从 https://prometheus.io/download/ 获取 node_exporter
安装包。
解压
tar -zxvf node_exporter-1.0.1.linux-amd64.tar.gz -C /usr/local
cd /usr/local/node_exporter-1.0.1.linux-amd64.tar.gz node_exporter
ln -s /usr/local/node_exporter-1.0.1.linux-amd64 /usr/local/node_exporter
配置 service 文件
vim /etc/systemd/system/node-exporter.service
[Unit]
Description=The prometheus node_exporter service.
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
#User=prometheus
#Group=prometheus
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/node_exporter
LimitNOFILE=65535
ExecStart=/usr/local/node_exporter/node_exporter
# ExecStart=/usr/local/bin/node_exporter --collector.netdev.device-include=eth* --log.level=warn --no-collector.nvme
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
配置
web.config.yaml
,内容如下:
basic_auth_users:
"<name>:<secret>"
# bcrypt 密码生成 yum install httpd-tools -y / apt install apache2-utils
htpasswd -nBC 5 "<name>" | tr -d ':\n'
启动服务:
node_exporter --web.config=web.config.yaml
启动 node exporter
systemctl daemon-reload
systemctl start node-exporter
systemctl status node-exporter
systemctl enable node-exporter
重启可以使用 kill -HUP <pid>
访问 node exporter
- 端口:
9100
http://<ip>:9100/metrics
FAQ
nvme error
node_exporter: level=error ts=2021-08-01T01:33:15.964Z caller=collector.go:169 msg="collector failed" name=nvme duration_seconds=3.4698e-05 err="error obtaining NVMe class info: failed to list NVMe devices at \"/sys/class/nvme\": open /sys/class/nvme: no such file or directory
修改 /etc/systemd/system/node-exporter.service
:
[Service]
ExecStart=.../node_exporter ... --no-collector.nvme