From d6d3176f5eb84c2a75cd622b4883c5c8c1ad3990 Mon Sep 17 00:00:00 2001 From: Kulwant Singh Date: Wed, 21 Feb 2024 20:03:42 +0000 Subject: [PATCH] fix fstype (#164) --- .../internal/k8swindows/extractors/extractor.go | 2 ++ .../internal/k8swindows/extractors/fs_extractor.go | 5 ++--- .../k8swindows/extractors/fs_extractor_test.go | 10 +++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/extractor.go b/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/extractor.go index 3e904fd22606..4ebfa6cf7b1c 100644 --- a/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/extractor.go +++ b/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/extractor.go @@ -32,6 +32,8 @@ type MemoryStat struct { type FileSystemStat struct { Time time.Time Name string + Device string + Type string AvailableBytes uint64 CapacityBytes uint64 UsedBytes uint64 diff --git a/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor.go b/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor.go index 0120736f7840..b77c90ff6db6 100644 --- a/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor.go +++ b/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor.go @@ -34,9 +34,8 @@ func (f *FileSystemMetricExtractor) GetValue(rawMetric RawMetric, _ cExtractor.C for _, v := range rawMetric.FileSystemStats { metric := cExtractor.NewCadvisorMetric(containerType, f.logger) - if v.Name != "" { - metric.AddTag(ci.DiskDev, v.Name) - } + metric.AddTag(ci.DiskDev, v.Device) + metric.AddTag(ci.FSType, v.Type) metric.AddField(ci.MetricName(containerType, ci.FSUsage), v.UsedBytes) metric.AddField(ci.MetricName(containerType, ci.FSCapacity), v.CapacityBytes) diff --git a/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor_test.go b/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor_test.go index e53e68d4543c..8ea57e92d8c0 100644 --- a/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor_test.go +++ b/receiver/awscontainerinsightreceiver/internal/k8swindows/extractors/fs_extractor_test.go @@ -35,7 +35,9 @@ func TestFSStats(t *testing.T) { "node_filesystem_utilization": float64(40.358791544917224), } expectedTags := map[string]string{ - "Type": "NodeFS", + "fstype": "", + "device": "", + "Type": "NodeFS", } cExtractor.AssertContainsTaggedField(t, cMetrics[0], expectedFields, expectedTags) @@ -66,7 +68,8 @@ func TestFSStats(t *testing.T) { "container_filesystem_utilization": float64(0.3955174875484043), } expectedTags = map[string]string{ - "device": "rootfs", + "fstype": "", + "device": "", "Type": "ContainerFS", } cExtractor.AssertContainsTaggedField(t, cMetrics[0], expectedFields, expectedTags) @@ -78,7 +81,8 @@ func TestFSStats(t *testing.T) { "container_filesystem_utilization": float64(0.0010704219949207732), } expectedTags = map[string]string{ - "device": "logfs", + "fstype": "", + "device": "", "Type": "ContainerFS", } cExtractor.AssertContainsTaggedField(t, cMetrics[1], expectedFields, expectedTags)