使用Prometheus监控Linux系统各项指标

首先在Linux系统上安装一个探测器node explorer, 下载地址https://prometheus.io/docs/guides/node-exporter/

这个探测器会定期将linux系统的各项硬件指标和内核参数通过9100端口和url metrics暴露给外部。

clipboard1,1

启动node explorer,显示在9100端口上监听:

使用Prometheus监控Linux系统各项指标_第1张图片

浏览器里输入hostname:9100/metrics就可以访问到node explorer收集到的各项参数:

使用Prometheus监控Linux系统各项指标_第2张图片

一些例子:

CPU在不同工作模式下的使用时间:node_cpu_seconds_total

使用Prometheus监控Linux系统各项指标_第3张图片

文件系统可用字节数:node_filesystem_avail_bytes

clipboard5,5

网卡收到的字节数:node_network_receive_bytes_total

clipboard6,6

下面用Prometheus来收集和展示通过node explorer暴露出来的数据。

在Prometheus安装目录的prometheus.yml文件里定义一个job,指向Linux系统上运行的node explorer:

使用Prometheus监控Linux系统各项指标_第4张图片

本地启动Prometheus,打开下面的url:
http://localhost:9090/
输入node_cpu_seconds_total{mode=“system”},查询该服务器上所有CPU工作在系统态消耗的时间:

使用Prometheus监控Linux系统各项指标_第5张图片

还可以指定时间窗口,只查询过去1分钟之内的CPU运行数据:
rate(node_cpu_seconds_total{mode=“system”}[1m])

使用Prometheus监控Linux系统各项指标_第6张图片

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
公众号截图

你可能感兴趣的:(Jerry,Wang的原创SAP技术文章)