From 03dfa0b5df02e23824a9142a16e9765590debb46 Mon Sep 17 00:00:00 2001 From: Evan <31562192+EvanLjp@users.noreply.github.com> Date: Mon, 8 May 2023 14:20:26 +0800 Subject: [PATCH] fix system disk total val (#835) * fix system disk total val --------- Co-authored-by: liujiapeng.ljp --- CHANGELOG.md | 5 ++++- plugins/input/systemv2/input_system_v2.go | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f05fe2ef..5938ff68fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,9 @@ your changes, such as: ## Example -- [public] [both] [fix] do not read env config from exited containers +- [public] [both] [updated] add a new feature ## [Unreleased] +- [public] [both] [fixed] Resolved issue of double counting disk total metrics in the disk partition condition of metric_system_v2 +- [public] [both] [fixed] do not read env config from exited containers + diff --git a/plugins/input/systemv2/input_system_v2.go b/plugins/input/systemv2/input_system_v2.go index 2426f787b8..c7fe7066ae 100644 --- a/plugins/input/systemv2/input_system_v2.go +++ b/plugins/input/systemv2/input_system_v2.go @@ -233,6 +233,14 @@ func (r *InputSystem) CollectDisk(collector pipeline.Collector) { if err == nil { totalIoCount := disk.IOCountersStat{} for _, ioCount := range allIoCounters { + if ioCount.Name == "" { + continue + } + lastChar := ioCount.Name[len(ioCount.Name)-1] + if lastChar >= '0' && lastChar <= '9' { + // means disk partition, don't need to record to total metrics + continue + } totalIoCount.ReadBytes += ioCount.ReadBytes totalIoCount.WriteBytes += ioCount.WriteBytes totalIoCount.ReadCount += ioCount.ReadCount