Prometheus Node Exporter¶
Prometheus Node Exporter提供了一系列硬件和内核相关metric
安装¶
下载安装执行程序:
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz tar xvfz node_exporter-1.3.1.linux-amd64.tar.gz cd node_exporter-1.3.1.linux-amd64/ sudo mv node_exporter /usr/local/bin/ # 直接运行 /usr/local/bin/node_exporter
要持续运行可以采用 screen
screen -S node_exporter -dm /usr/local/bin/node_exporter
注解
node_exporter
运行不需要root权限,并且会监听所有网络接口的 9100
端口,所以prometheus可以直接抓去指定服务器 node_exporter
输出的 metrics
检查¶
一旦
node_exporter
运行起来,可以见证metrics:curl http://localhost:9100/metrics
配置prometheus实例¶
我们在 Prometheus快速起步 安装的初始配置上添加以下内容来抓取指定服务器数据:
scrape_configs:
...
- job_name: "node"
static_configs:
- targets: ['localhost:9100']
然后重启 prometheus ,再通过浏览器观察查询一些案例表达式,例如:
rate(node_cpu_seconds_total{mode="system"}[1m])
表示在系统模式下每秒CPU消耗平均量,记录最近1分钟(每秒)
配置Ceph节点监控¶
Ceph Dashboard集成Prometheus 采用的架构:
- 在每个 ceph 节点安装 Prometheus Node Exporter ,然后 Prometheus快速起步 安装配置成从各个Ceph抓取数据
- 配置Grafana 从 Prometheus 获取数据结合到 Ceph Dashboard集成Prometheus 监控
以下为Ceph监控部署
在每个 Ceph 节点安装并运行
Prometheus
Node Exporter:for i in {1..3};do ssh z-b-data-${i} "sudo apt install screen -y";done for i in {1..3};do scp node_exporter z-b-data-${i}:/home/huatai/;done for i in {1..3};do ssh z-b-data-${i} "sudo mv /home/huatai/node_exporter /usr/local/bin/node_exporter;screen -S node_exporter -dm /usr/local/bin/node_exporter";done
然后修订
z-b-mon-1
上/etc/prometheus/prometheus.yml
继续在job_name: "node"
添加受监控节点:- job_name: "node" static_configs: - targets: ['localhost:9100'] - targets: ['z-b-data-1:9100'] - targets: ['z-b-data-2:9100'] - targets: ['z-b-data-3:9100']
注解
这里采用主机名,是因为我已经部署 私有云DNS服务(dnsmasq)和共享因特网(ICS) ,可以在任意主机上解析整个网络所有服务器