From 15a636c7e17897cea03a1f96d900668b3ee43bdf Mon Sep 17 00:00:00 2001 From: a-thomas-22 Date: Mon, 15 Jul 2024 09:29:44 -0500 Subject: [PATCH 1/4] Replace - with _ in device names --- util/iostat/iostat.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/iostat/iostat.go b/util/iostat/iostat.go index 9bc5ff800c..01a63fdfe1 100644 --- a/util/iostat/iostat.go +++ b/util/iostat/iostat.go @@ -30,7 +30,8 @@ func RegisterAndPopulateMetrics(ctx context.Context, spawnInterval, maxDeviceCou if _, ok := deviceMetrics[stat.DeviceName]; !ok { // Register metrics for a maximum of maxDeviceCount (fail safe incase iostat command returns incorrect names indefinitely) if len(deviceMetrics) < maxDeviceCount { - baseMetricName := fmt.Sprintf("isotat/%s/", stat.DeviceName) + sanitizedDeviceName := strings.Replace(stat.DeviceName, "-", "_", -1) + baseMetricName := fmt.Sprintf("isotat/%s/", sanitizedDeviceName) deviceMetrics[stat.DeviceName] = make(map[string]metrics.GaugeFloat64) deviceMetrics[stat.DeviceName]["readspersecond"] = metrics.NewRegisteredGaugeFloat64(baseMetricName+"readspersecond", nil) deviceMetrics[stat.DeviceName]["writespersecond"] = metrics.NewRegisteredGaugeFloat64(baseMetricName+"writespersecond", nil) From b8b8d6195909ad507972c508bdbf47653340c4eb Mon Sep 17 00:00:00 2001 From: a-thomas-22 Date: Mon, 15 Jul 2024 09:34:40 -0500 Subject: [PATCH 2/4] add coment --- util/iostat/iostat.go | 1 + 1 file changed, 1 insertion(+) diff --git a/util/iostat/iostat.go b/util/iostat/iostat.go index 01a63fdfe1..3db27e9423 100644 --- a/util/iostat/iostat.go +++ b/util/iostat/iostat.go @@ -30,6 +30,7 @@ func RegisterAndPopulateMetrics(ctx context.Context, spawnInterval, maxDeviceCou if _, ok := deviceMetrics[stat.DeviceName]; !ok { // Register metrics for a maximum of maxDeviceCount (fail safe incase iostat command returns incorrect names indefinitely) if len(deviceMetrics) < maxDeviceCount { + // Replace hyphens with underscores to avoid metric name issues sanitizedDeviceName := strings.Replace(stat.DeviceName, "-", "_", -1) baseMetricName := fmt.Sprintf("isotat/%s/", sanitizedDeviceName) deviceMetrics[stat.DeviceName] = make(map[string]metrics.GaugeFloat64) From cf2387435cfd70ef7670b52bd02cab852f5944b0 Mon Sep 17 00:00:00 2001 From: a-thomas-22 Date: Mon, 15 Jul 2024 09:36:29 -0500 Subject: [PATCH 3/4] fix metric name --- util/iostat/iostat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/iostat/iostat.go b/util/iostat/iostat.go index 3db27e9423..d401da761e 100644 --- a/util/iostat/iostat.go +++ b/util/iostat/iostat.go @@ -32,7 +32,7 @@ func RegisterAndPopulateMetrics(ctx context.Context, spawnInterval, maxDeviceCou if len(deviceMetrics) < maxDeviceCount { // Replace hyphens with underscores to avoid metric name issues sanitizedDeviceName := strings.Replace(stat.DeviceName, "-", "_", -1) - baseMetricName := fmt.Sprintf("isotat/%s/", sanitizedDeviceName) + baseMetricName := fmt.Sprintf("iostat/%s/", sanitizedDeviceName) deviceMetrics[stat.DeviceName] = make(map[string]metrics.GaugeFloat64) deviceMetrics[stat.DeviceName]["readspersecond"] = metrics.NewRegisteredGaugeFloat64(baseMetricName+"readspersecond", nil) deviceMetrics[stat.DeviceName]["writespersecond"] = metrics.NewRegisteredGaugeFloat64(baseMetricName+"writespersecond", nil) From 423c966f4599b1ef5ec3a92157c0bc754f3cff6e Mon Sep 17 00:00:00 2001 From: a-thomas-22 Date: Mon, 15 Jul 2024 09:51:42 -0500 Subject: [PATCH 4/4] lint fix --- util/iostat/iostat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/iostat/iostat.go b/util/iostat/iostat.go index d401da761e..342a44100e 100644 --- a/util/iostat/iostat.go +++ b/util/iostat/iostat.go @@ -31,7 +31,7 @@ func RegisterAndPopulateMetrics(ctx context.Context, spawnInterval, maxDeviceCou // Register metrics for a maximum of maxDeviceCount (fail safe incase iostat command returns incorrect names indefinitely) if len(deviceMetrics) < maxDeviceCount { // Replace hyphens with underscores to avoid metric name issues - sanitizedDeviceName := strings.Replace(stat.DeviceName, "-", "_", -1) + sanitizedDeviceName := strings.ReplaceAll(stat.DeviceName, "-", "_") baseMetricName := fmt.Sprintf("iostat/%s/", sanitizedDeviceName) deviceMetrics[stat.DeviceName] = make(map[string]metrics.GaugeFloat64) deviceMetrics[stat.DeviceName]["readspersecond"] = metrics.NewRegisteredGaugeFloat64(baseMetricName+"readspersecond", nil)