惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
雷峰网
雷峰网
Last Week in AI
Last Week in AI
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
D
DataBreaches.Net
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
美团技术团队
V
V2EX
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
腾讯CDC
Vercel News
Vercel News
A
About on SuperTechFans
J
Java Code Geeks
Martin Fowler
Martin Fowler
V
Visual Studio Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

mafeifan 的编程技术分享

mafengwo-mp3-downloader | mafeifan 的编程技术分享 示例页面 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 查看 default namespace 下的 default service account名称 mafeifan 的编程技术分享 检查日志 | mafeifan 的编程技术分享 bridge fdb show dev flannel.1 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 数据收集原理分析 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 几种方法 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 check the export on the very top of this document so we can use $do mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 延伸 -- 关于前端路由 xdebug 3 和 2 的区别
mafeifan 的编程技术分享
2026-01-16 · via mafeifan 的编程技术分享

在上一篇文章中我们学习了如何通过node-exporter获取主机监控信息。但安装好监控只是第一步,我们还需要知道哪些监控指标是我们需要关注的。

本文将对Prometheus相关的主机监控指标进行介绍。

一. CPU监控 ​

CPU负载 ​

node_load1
node_load5
node_load15

以上三个指标为主机的CPU平均负载,分别对应一分钟、五分钟和十五分钟的时间间隔。

CPU负载是指某段时间内占用CPU时间的进程和等待CPU时间的进程数之和。

一般来说,cpu负载数/cpu核数如果超过0.7,应该开始关注机器性能情况 ,如果超过1的话,运维人员应该介入处理。

CPU使用率 ​

node_cpu_seconds_total

该指标包括了多个标签,分别标记每种处理模式使用的CPU时间,该指标为counter类型。

这个指标不适合直接拿来使用,可通过前面学习的PromQL,将其转化成CPU使用率的指标 。

# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 3.56934038e+06
node_cpu_seconds_total{cpu="0",mode="iowait"} 6208.33
node_cpu_seconds_total{cpu="0",mode="irq"} 0
node_cpu_seconds_total{cpu="0",mode="nice"} 398.62
node_cpu_seconds_total{cpu="0",mode="softirq"} 2759.47
node_cpu_seconds_total{cpu="0",mode="steal"} 0
node_cpu_seconds_total{cpu="0",mode="system"} 65250.09
node_cpu_seconds_total{cpu="0",mode="user"} 190913.76
node_cpu_seconds_total{cpu="1",mode="idle"} 3.56738873e+06
node_cpu_seconds_total{cpu="1",mode="iowait"} 8643.69
node_cpu_seconds_total{cpu="1",mode="irq"} 0
node_cpu_seconds_total{cpu="1",mode="nice"} 378.03
node_cpu_seconds_total{cpu="1",mode="softirq"} 2633.77
node_cpu_seconds_total{cpu="1",mode="steal"} 0
node_cpu_seconds_total{cpu="1",mode="system"} 65323.76
node_cpu_seconds_total{cpu="1",mode="user"} 190535.96

mode="idle"代表CPU 的空闲时间,所以我们只需要算出空闲的时间占比,再以总数减去该值 ,便可知道CPU的使用率,此处使用irate方法。

由于现有的服务器一般为多核,所以加上avg求出所有cpu的平均值,便是CPU的使用率情况 ,如下 :

100 -avg(irate(node_cpu_seconds_total{mode="idle"}[5m])) by (instance)* 100

二. 内存监控 ​

物理内存使用率 对于内存,我们一般会关注内存的使用率,但node-exporter并不直接进行计算,我们需要根据node-exporter返回的内存指标自己写计算公式 。

需要用到的内存指标有下列几个:

node_memory_MemTotal_bytes    #总内存大小
node_memory_MemFree_bytes     #空闲内存大小
node_memory_Buffers_bytes     #缓冲缓存大小
node_memory_Cached_bytes      #页面缓存大小

计算的公式为:(总内存 -(空闲内存 + 缓冲缓存 + 页面缓存))/ 总内存 * 100

(node_memory_MemTotal_bytes - (node_memory_MemFree_bytes + node_memory_Buffers_bytes+node_memory_Cached_bytes ))/node_memory_MemTotal_bytes * 100

swap内存使用率 ​

Swap为交换内存分区,它使用磁盘上的部分空间来充当服务器内存,当系统物理内存吃紧时,Linux 会将内存中不常访问的数据保存到 swap 上,这样系统就有更多的物理内存为各个进程服务。而当系统需要访问 swap 上存储的内容时,再将 swap 上的数据加载到内存中,这就是常说的换出和换入。交换空间可以在一定程度上缓解内存不足的情况,但是它需要读写磁盘数据,所以性能不是很高。

swap内存用到的指标如下:

node_memory_SwapTotal_bytes  #swap内存总大小
node_memory_SwapFree_bytes   #swap空闲内存大小

计算的公式如下:(node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes)/node_memory_SwapTotal_bytes * 100

三. 磁盘监控 ​

分区使用率 ​

分区使用率的指标可以通过分区空间总容器和分区空闲容量计算出来

node_filesystem_size_bytes  # 分区空间总容量
node_filesystem_free_bytes  # 分区空闲容量

由于主机一般会有多个分区 ,需要通过指标的标签mountpoint 进行区分 ,如 获取 / 分区磁盘使用率可使用下列公式

(node_filesystem_size_bytes{mountpoint="/"} - node_filesystem_free_bytes{mountpoint="/"})/node_filesystem_size_bytes{mountpoint="/"} * 100

磁盘吞吐量 ​

node_disk_read_bytes_total  #分区读总字节数
node_disk_written_bytes_total #分区写总字节数

上面两个指标分别对应了分区读写的总字节数,指标为counter类型。前面文章讲过,counter类型会不断的累加,该指标直接使用对于监控没有意义,但可通过下面公式转化为磁盘的每秒读写速率。device代表对应的磁盘分区。

irate(node_disk_read_bytes_total{device="vda"}[5m]) 
irate(node_disk_written_bytes_total{device="vda"}[5m])

磁盘IOPS ​

IOPS表示每秒对磁盘的读写次数,它与吞吐量都是衡量磁盘的重要指标。对于IOPS的监控,可通过下面两个指标算得出

node_disk_reads_completed_total  #分区读总次数
node_disk_writes_completed_total  #分区写总次数

计算公式与上面相似,使用我们熟悉的irate或rate函数来处理

irate(node_disk_reads_completed_total{device="vda"}[5m])
irate(node_disk_writes_completed_total{device="vda"}[5m])

四. 网络监控 ​

网卡流量 网卡流量一般分为上传和下载流量,下面两个指标分别为总的字节数,可通过这两个指标计算出来网卡每秒流量

node_network_receive_bytes_total  #下载流量总字节数
node_network_transmit_bytes_total  #上传流量总字节数

计算公式如下,此处排除Loopback 网卡

irate(node_network_receive_bytes_total{device != "lo"}[1m]

除了监控主机的性能参数外,我们还需要关注实例的可用性情况,比如是否关机、exporter是否正常运行等。

在exporter返回的指标,有一个up指标,可用来实现这类监控需求。

up{job="node-exporter"}

结语 ​

主机监控是监控平面中最底层的一类,虽然基础但是非常重要,只有在主机层面稳定了,上层应用才能更好的运行。 本文讲解的内容只是主机监控中的基本指标,node-exporter自身还提供不少有用的指标,包括支持textfile的自定义指标。 在生产环境中,需要根据实际情况进行调试。