From 2f363a2cffd36a43e3bb2da731d33edadce41454 Mon Sep 17 00:00:00 2001 From: Guodong Zhang Date: Thu, 11 Dec 2025 11:21:29 +0800 Subject: [PATCH] fix(metric_system_v2): add fd metrics as string not float64 --- plugins/input/systemv2/input_system_linux.go | 7 ++----- plugins/input/systemv2/input_system_v2.go | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/input/systemv2/input_system_linux.go b/plugins/input/systemv2/input_system_linux.go index b2939ad631..4aa8e87393 100644 --- a/plugins/input/systemv2/input_system_linux.go +++ b/plugins/input/systemv2/input_system_linux.go @@ -22,7 +22,6 @@ import ( "bytes" "io" "os" - "strconv" "strings" "github.com/alibaba/ilogtail/pkg/helper/containercenter" @@ -163,10 +162,8 @@ func (r *InputSystem) CollectOpenFD(collector pipeline.Collector) { logger.Warning(r.context.GetRuntimeContext(), "FILENR_PATTERN_ALARM", "want", 3, "got", len(parts)) return } - allocated, _ := strconv.ParseFloat(string(parts[0]), 64) - maximum, _ := strconv.ParseFloat(string(parts[2]), 64) - r.addMetric(collector, "fd_allocated", &r.commonLabels, allocated) - r.addMetric(collector, "fd_max", &r.commonLabels, maximum) + r.addMetricStringVal(collector, "fd_allocated", &r.commonLabels, string(parts[0])) + r.addMetricStringVal(collector, "fd_max", &r.commonLabels, string(parts[2])) } // CollectDiskUsage use `/proc/1/mounts` to find the device rather than `proc/self/mounts` diff --git a/plugins/input/systemv2/input_system_v2.go b/plugins/input/systemv2/input_system_v2.go index e8d7f9ed77..d05c8b59ab 100644 --- a/plugins/input/systemv2/input_system_v2.go +++ b/plugins/input/systemv2/input_system_v2.go @@ -108,6 +108,10 @@ func (r *InputSystem) addMetric(collector pipeline.Collector, name string, label collector.AddRawLog(helper.NewMetricLog(name, r.collectTime.UnixNano(), value, labels)) } +func (r *InputSystem) addMetricStringVal(collector pipeline.Collector, name string, labels *helper.MetricLabels, value string) { + collector.AddRawLog(helper.NewMetricLogStringVal(name, r.collectTime.UnixNano(), value, labels)) +} + func (r *InputSystem) CollectCore(collector pipeline.Collector) { // host info