Prometheus系列之部署Node_exporter
在Prometheus的架构设计中,Prometheus Server并不直接服务监控特定的目标,其主要任务负责数据的收集,存储并且对外提供数据查询支持。因此为了能够监控到某些东西,如主机的cpu使用率,我们需要使用到Exporter。Prometheus周期性的从Exporter暴露的HTTP服务地址(通常时metrics)拉取监控样本数据。
Node Exporter可以采集到系统相关的信息,例如CPU、内存、硬盘等系统信息。Node Exporter采用Golang编写,并且不存在任何的第三方依赖,只需要下载,解压即可运行。
下载安装
[root@prometheus software]# wget https://github.com/prometheus/node_exporter/releases/download/v1.9.1/node_exporter-1.9.1.linux-amd64.tar.gz
[root@prometheus software]# tar -zxvf node_exporter-1.9.1.linux-amd64.tar.gz
[root@prometheus software]# mv node_exporter-1.9.1.linux-amd64 /usr/local/node_exporter
systemctl
[root@prometheus software]# vim /etc/systemd/system/node_exporter.service
[Unit]
Description=node exporter
Documentation=node exporter
[Service]
ExecStart=/usr/local/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target
[root@prometheus software]# systemctl daemon-reload
[root@prometheus software]# systemctl enable node_exporter
[root@prometheus software]# systemctl start node_exporter
查看采集数据
启动成功后,可以通过http://<ip或domain>:9100看到很多相关的系统指标,从指标中我们可以获得类似相关参数指标信息:
- node_boot_time:系统启动时间
- node_cpu:系统CPU使用量
- nodedisk:磁盘IO
- nodefilesystem:文件系统用量
- node_load1:系统负载
- nodememeory:内存使用量
- nodenetwork:网络带宽
- nodetime:当前系统时间
- go:node exporter中go相关指标
- process_:node exporter自身进程相关运行指标

对接Prometheus Server
编辑prometheus.yml 配置文件,将Node_exporter添加到Prometheus Server中。
[root@prometheus software]# vim /usr/local/prometheus/prometheus.yml
scrape_configs:
...
- job_name: 'node-exporter'
static_configs:
- targets: ["192.168.3.232:9100","192.168.3.167:9100"]
[root@prometheus software]# systemctl restart prometheus
Grafana
选择一个合适的模板,导入到Grafana中,下图中是用的是ID 1860的模板。
