hertzbeat icon indicating copy to clipboard operation
hertzbeat copied to clipboard

[Question] 采集器是否有问题?采集数据异常

Open liJiaLei-ljl opened this issue 1 year ago • 4 comments

Question

1Panel和hertzbeat的监控数据不同,hertzbeat大多数数据都是整数,精度异常,以以下CPU采集数据为例: 1Panel中的监控数据带有小数,且波动正常 Image hertzbeat中的监控数据是整数,且波动异常 Image

liJiaLei-ljl avatar Jul 02 '25 01:07 liJiaLei-ljl

heartbeat收集linux的指标是通过ssh协议去执行linux命令获取信息的,可能跟1panel的收集逻辑不同,你的设备是什么版本的系统?你使用了heartbeat哪个收集器呢?

lx1229 avatar Jul 17 '25 15:07 lx1229

主机名称 iv-ydwsgsbsaoqbxysly2v4
发行版本 centos-9
内核版本 5.14.0-312.el9.x86_64
系统类型 x86_64

使用了heartbeat自带的采集器,没有使用其他三方采集器,比如普罗米修斯之类的。hertzbeat的配置也都是使用的默认配置,没有任何改动

liJiaLei-ljl avatar Aug 18 '25 01:08 liJiaLei-ljl

Root cause, still present on master: CPU usage is computed as usage=100-idle, where idle comes from vmstat 1 2 | awk 'NR==4{print $15}'. vmstat only prints whole percentages and this samples a single second, so the value is always an integer and jumps between samples.

https://github.com/apache/hertzbeat/blob/8104d7057c72f9c18dea31d32e076750d2c34020/hertzbeat-manager/src/main/resources/define/app-linux.yml#L373

The same command is used by the other Linux-family templates (centos, ubuntu, debian, redhat, rockylinux, almalinux, euleros, opensuse, coreos, freebsd, linux_script). Computing the usage from two /proc/stat readings would give decimal precision.

orangeCatDeveloper avatar Sep 28 '26 00:09 orangeCatDeveloper

Hi @liJiaLei-ljl, thank you for reporting this.

I would like to take this issue. @orangeCatDeveloper, thank you as well for the clear root-cause analysis — I will follow that direction and work on a fix.

Please feel free to share any extra details if needed. Thanks again.

xdn-code avatar Oct 04 '26 12:10 xdn-code