From 106c3c1747bcf0004dcc7ec605a0207cbbb142b0 Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Fri, 11 Aug 2023 12:19:54 -0500 Subject: [PATCH 1/8] [receiver/kubeletstatsreciever] add volume attrs for CSI-backed PVCs --- .../kubeletstatsreceiver/documentation.md | 2 ++ .../internal/kubelet/conventions.go | 1 + .../internal/kubelet/volume.go | 26 +++++++++++++++ .../internal/kubelet/volume_test.go | 33 +++++++++++++++++++ .../internal/metadata/generated_config.go | 8 +++++ .../metadata/generated_config_test.go | 8 +++++ .../metadata/generated_metrics_test.go | 2 ++ .../internal/metadata/generated_resource.go | 14 ++++++++ .../metadata/generated_resource_test.go | 16 +++++++-- .../internal/metadata/testdata/config.yaml | 8 +++++ receiver/kubeletstatsreceiver/metadata.yaml | 8 +++++ 11 files changed, 124 insertions(+), 2 deletions(-) diff --git a/receiver/kubeletstatsreceiver/documentation.md b/receiver/kubeletstatsreceiver/documentation.md index 7f9687acc30b..ecc60797e7d1 100644 --- a/receiver/kubeletstatsreceiver/documentation.md +++ b/receiver/kubeletstatsreceiver/documentation.md @@ -504,6 +504,8 @@ The time since the pod started | ---- | ----------- | ------ | ------- | | aws.volume.id | The id of the AWS Volume | Any Str | true | | container.id | Container id used to identify container | Any Str | true | +| csi.driver | CSI driver | Any Str | true | +| csi.volume.handle | CSI volume handle | Any Str | true | | fs.type | The filesystem type of the Volume | Any Str | true | | gce.pd.name | The name of the persistent disk in GCE | Any Str | true | | glusterfs.endpoints.name | The endpoint name that details Glusterfs topology | Any Str | true | diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go b/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go index 23c53755dcef..4b04fa933108 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go @@ -16,5 +16,6 @@ const ( labelValueLocalVolume = "local" labelValueAWSEBSVolume = "awsElasticBlockStore" labelValueGCEPDVolume = "gcePersistentDisk" + labelValueCSIPersistentVolume = "csiPersistentVolume" labelValueGlusterFSVolume = "glusterfs" ) diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume.go index 19c9c26fb980..287db2849af7 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume.go @@ -5,6 +5,7 @@ package kubelet // import "github.com/open-telemetry/opentelemetry-collector-con import ( "strconv" + "strings" "go.opentelemetry.io/collector/pdata/pcommon" v1 "k8s.io/api/core/v1" @@ -13,6 +14,10 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/internal/metadata" ) +const ( + csiDriverGCP = "pd.csi.storage.gke.io" +) + func addVolumeMetrics(mb *metadata.MetricsBuilder, volumeMetrics metadata.VolumeMetrics, s stats.VolumeStats, currentTime pcommon.Timestamp) { recordIntDataPoint(mb, volumeMetrics.Available, s.AvailableBytes, currentTime) recordIntDataPoint(mb, volumeMetrics.Capacity, s.CapacityBytes, currentTime) @@ -65,6 +70,8 @@ func SetPersistentVolumeLabels(rb *metadata.ResourceBuilder, pv v1.PersistentVol Path: pv.Glusterfs.Path, ReadOnly: pv.Glusterfs.ReadOnly, }) + case pv.CSI != nil: + csiPersistentVolumeDims(rb, *pv.CSI) } } @@ -90,3 +97,22 @@ func glusterfsDims(rb *metadata.ResourceBuilder, vs v1.GlusterfsVolumeSource) { rb.SetGlusterfsEndpointsName(vs.EndpointsName) rb.SetGlusterfsPath(vs.Path) } + +func csiPersistentVolumeDims(rb *metadata.ResourceBuilder, vs v1.CSIPersistentVolumeSource) { + rb.SetK8sVolumeType(labelValueCSIPersistentVolume) + + // CSI specific labels. + rb.SetCsiVolumeHandle(vs.VolumeHandle) + rb.SetCsiDriver(vs.Driver) + rb.SetFsType(vs.FSType) + + // CSI driver specific labels. + switch vs.Driver { + case csiDriverGCP: + // This is in one of two formats: + // projects//regions//disks/ + // projects//zones//disks/ + parts := strings.SplitN(vs.VolumeHandle, "/", 6) + rb.SetGcePdName(parts[len(parts)-1]) + } +} diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go index 958617615bbe..48cf8ae71f0e 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go @@ -148,6 +148,39 @@ func TestDetailedPVCLabels(t *testing.T) { "k8s.namespace.name": "pod-namespace", }, }, + { + name: "persistentVolumeClaim - with detailed PVC labels (CSI PV with GCP driver)", + volumeName: "volume0", + volumeSource: v1.VolumeSource{ + PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ + ClaimName: "claim-name", + }, + }, + pod: pod{uid: "uid-1234", name: "pod-name", namespace: "pod-namespace"}, + detailedPVCLabelsSetterOverride: func(rb *metadata.ResourceBuilder, volCacheID, volumeClaim, namespace string) error { + SetPersistentVolumeLabels(rb, v1.PersistentVolumeSource{ + CSI: &v1.CSIPersistentVolumeSource{ + Driver: csiDriverGCP, + VolumeHandle: "projects/project-name/zones/us-central1-a/disks/disk-name", + ReadOnly: false, + FSType: "ext4", + }, + }) + return nil + }, + want: map[string]interface{}{ + "k8s.volume.name": "volume0", + "k8s.volume.type": labelValueCSIPersistentVolume, + "k8s.persistentvolumeclaim.name": "claim-name", + "k8s.pod.uid": "uid-1234", + "k8s.pod.name": "pod-name", + "k8s.namespace.name": "pod-namespace", + "gce.pd.name": "disk-name", + "csi.driver": csiDriverGCP, + "csi.volume.handle": "projects/project-name/zones/us-central1-a/disks/disk-name", + "fs.type": "ext4", + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go index a7d7a70dcb32..26e840479736 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go @@ -279,6 +279,8 @@ func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { type ResourceAttributesConfig struct { AwsVolumeID ResourceAttributeConfig `mapstructure:"aws.volume.id"` ContainerID ResourceAttributeConfig `mapstructure:"container.id"` + CsiDriver ResourceAttributeConfig `mapstructure:"csi.driver"` + CsiVolumeHandle ResourceAttributeConfig `mapstructure:"csi.volume.handle"` FsType ResourceAttributeConfig `mapstructure:"fs.type"` GcePdName ResourceAttributeConfig `mapstructure:"gce.pd.name"` GlusterfsEndpointsName ResourceAttributeConfig `mapstructure:"glusterfs.endpoints.name"` @@ -302,6 +304,12 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { ContainerID: ResourceAttributeConfig{ Enabled: true, }, + CsiDriver: ResourceAttributeConfig{ + Enabled: true, + }, + CsiVolumeHandle: ResourceAttributeConfig{ + Enabled: true, + }, FsType: ResourceAttributeConfig{ Enabled: true, }, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go index 91ecb174c7a1..a1b45698a021 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go @@ -86,6 +86,8 @@ func TestMetricsBuilderConfig(t *testing.T) { ResourceAttributes: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: true}, ContainerID: ResourceAttributeConfig{Enabled: true}, + CsiDriver: ResourceAttributeConfig{Enabled: true}, + CsiVolumeHandle: ResourceAttributeConfig{Enabled: true}, FsType: ResourceAttributeConfig{Enabled: true}, GcePdName: ResourceAttributeConfig{Enabled: true}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: true}, @@ -166,6 +168,8 @@ func TestMetricsBuilderConfig(t *testing.T) { ResourceAttributes: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: false}, ContainerID: ResourceAttributeConfig{Enabled: false}, + CsiDriver: ResourceAttributeConfig{Enabled: false}, + CsiVolumeHandle: ResourceAttributeConfig{Enabled: false}, FsType: ResourceAttributeConfig{Enabled: false}, GcePdName: ResourceAttributeConfig{Enabled: false}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: false}, @@ -217,6 +221,8 @@ func TestResourceAttributesConfig(t *testing.T) { want: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: true}, ContainerID: ResourceAttributeConfig{Enabled: true}, + CsiDriver: ResourceAttributeConfig{Enabled: true}, + CsiVolumeHandle: ResourceAttributeConfig{Enabled: true}, FsType: ResourceAttributeConfig{Enabled: true}, GcePdName: ResourceAttributeConfig{Enabled: true}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: true}, @@ -237,6 +243,8 @@ func TestResourceAttributesConfig(t *testing.T) { want: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: false}, ContainerID: ResourceAttributeConfig{Enabled: false}, + CsiDriver: ResourceAttributeConfig{Enabled: false}, + CsiVolumeHandle: ResourceAttributeConfig{Enabled: false}, FsType: ResourceAttributeConfig{Enabled: false}, GcePdName: ResourceAttributeConfig{Enabled: false}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go index ad03beaee512..dd4ecd5557a3 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go @@ -280,6 +280,8 @@ func TestMetricsBuilder(t *testing.T) { rb := mb.NewResourceBuilder() rb.SetAwsVolumeID("aws.volume.id-val") rb.SetContainerID("container.id-val") + rb.SetCsiDriver("csi.driver-val") + rb.SetCsiVolumeHandle("csi.volume.handle-val") rb.SetFsType("fs.type-val") rb.SetGcePdName("gce.pd.name-val") rb.SetGlusterfsEndpointsName("glusterfs.endpoints.name-val") diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go index c30835b4af74..3652b9790ab8 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go @@ -35,6 +35,20 @@ func (rb *ResourceBuilder) SetContainerID(val string) { } } +// SetCsiDriver sets provided value as "csi.driver" attribute. +func (rb *ResourceBuilder) SetCsiDriver(val string) { + if rb.config.CsiDriver.Enabled { + rb.res.Attributes().PutStr("csi.driver", val) + } +} + +// SetCsiVolumeHandle sets provided value as "csi.volume.handle" attribute. +func (rb *ResourceBuilder) SetCsiVolumeHandle(val string) { + if rb.config.CsiVolumeHandle.Enabled { + rb.res.Attributes().PutStr("csi.volume.handle", val) + } +} + // SetFsType sets provided value as "fs.type" attribute. func (rb *ResourceBuilder) SetFsType(val string) { if rb.config.FsType.Enabled { diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go index 80704d4d2842..f5aa00cf6963 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go @@ -15,6 +15,8 @@ func TestResourceBuilder(t *testing.T) { rb := NewResourceBuilder(cfg) rb.SetAwsVolumeID("aws.volume.id-val") rb.SetContainerID("container.id-val") + rb.SetCsiDriver("csi.driver-val") + rb.SetCsiVolumeHandle("csi.volume.handle-val") rb.SetFsType("fs.type-val") rb.SetGcePdName("gce.pd.name-val") rb.SetGlusterfsEndpointsName("glusterfs.endpoints.name-val") @@ -34,9 +36,9 @@ func TestResourceBuilder(t *testing.T) { switch test { case "default": - assert.Equal(t, 15, res.Attributes().Len()) + assert.Equal(t, 17, res.Attributes().Len()) case "all_set": - assert.Equal(t, 15, res.Attributes().Len()) + assert.Equal(t, 17, res.Attributes().Len()) case "none_set": assert.Equal(t, 0, res.Attributes().Len()) return @@ -54,6 +56,16 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "container.id-val", val.Str()) } + val, ok = res.Attributes().Get("csi.driver") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "csi.driver-val", val.Str()) + } + val, ok = res.Attributes().Get("csi.volume.handle") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "csi.volume.handle-val", val.Str()) + } val, ok = res.Attributes().Get("fs.type") assert.True(t, ok) if ok { diff --git a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml index 670fea221c4d..ae84a908283c 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml @@ -118,6 +118,10 @@ all_set: enabled: true container.id: enabled: true + csi.driver: + enabled: true + csi.volume.handle: + enabled: true fs.type: enabled: true gce.pd.name: @@ -263,6 +267,10 @@ none_set: enabled: false container.id: enabled: false + csi.driver: + enabled: false + csi.volume.handle: + enabled: false fs.type: enabled: false gce.pd.name: diff --git a/receiver/kubeletstatsreceiver/metadata.yaml b/receiver/kubeletstatsreceiver/metadata.yaml index b6319726e64b..d99c9125405e 100644 --- a/receiver/kubeletstatsreceiver/metadata.yaml +++ b/receiver/kubeletstatsreceiver/metadata.yaml @@ -70,6 +70,14 @@ resource_attributes: description: "Glusterfs volume path" enabled: true type: string + csi.volume.handle: + description: "CSI volume handle" + enabled: true + type: string + csi.driver: + description: "CSI driver" + enabled: true + type: string attributes: interface: From ce1a570a57e4163448bd778ea3467345b90faa2b Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Mon, 1 Apr 2024 10:32:55 -0500 Subject: [PATCH 2/8] add changelog entry --- .../kubeletstats_add_csi_volume_attrs.yaml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .chloggen/kubeletstats_add_csi_volume_attrs.yaml diff --git a/.chloggen/kubeletstats_add_csi_volume_attrs.yaml b/.chloggen/kubeletstats_add_csi_volume_attrs.yaml new file mode 100644 index 000000000000..d37726a343ef --- /dev/null +++ b/.chloggen/kubeletstats_add_csi_volume_attrs.yaml @@ -0,0 +1,31 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: kubeletstatsreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add CSI driver and volume handle attributes for PVCs + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [32055] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + Add `csi.driver` and `csi.volume.handle` resource attributes to PVC metrics. + Label volume metrics with type `csiPersistentVolume` if backed by CSI. + If a GCP PD is detected (uses `pd.csi.storage.gke.io`), set `gce.pd.name` to the parsed disk name. + This will match with disk names in GCP, allowing for correlation of GCE-native metrics. + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] From 1f72f5a11a815edf828a3d8bcfa459eee516e1aa Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Tue, 2 Apr 2024 09:15:54 -0500 Subject: [PATCH 3/8] lint --- receiver/kubeletstatsreceiver/internal/kubelet/volume.go | 3 +-- receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume.go index 287db2849af7..dd3e3d205aef 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume.go @@ -107,8 +107,7 @@ func csiPersistentVolumeDims(rb *metadata.ResourceBuilder, vs v1.CSIPersistentVo rb.SetFsType(vs.FSType) // CSI driver specific labels. - switch vs.Driver { - case csiDriverGCP: + if vs.Driver == csiDriverGCP { // This is in one of two formats: // projects//regions//disks/ // projects//zones//disks/ diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go index 48cf8ae71f0e..161fd5903c1d 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go @@ -157,7 +157,7 @@ func TestDetailedPVCLabels(t *testing.T) { }, }, pod: pod{uid: "uid-1234", name: "pod-name", namespace: "pod-namespace"}, - detailedPVCLabelsSetterOverride: func(rb *metadata.ResourceBuilder, volCacheID, volumeClaim, namespace string) error { + detailedPVCLabelsSetterOverride: func(rb *metadata.ResourceBuilder, _, volumeClaim, namespace string) error { SetPersistentVolumeLabels(rb, v1.PersistentVolumeSource{ CSI: &v1.CSIPersistentVolumeSource{ Driver: csiDriverGCP, From 652c2a18468fb49bb0eaaf661c17e23b2fa92d70 Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Wed, 3 Apr 2024 14:23:58 -0500 Subject: [PATCH 4/8] more lint --- receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go index 161fd5903c1d..9246bee46a4e 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go @@ -157,7 +157,7 @@ func TestDetailedPVCLabels(t *testing.T) { }, }, pod: pod{uid: "uid-1234", name: "pod-name", namespace: "pod-namespace"}, - detailedPVCLabelsSetterOverride: func(rb *metadata.ResourceBuilder, _, volumeClaim, namespace string) error { + detailedPVCLabelsSetterOverride: func(rb *metadata.ResourceBuilder, _, _, _ string) error { SetPersistentVolumeLabels(rb, v1.PersistentVolumeSource{ CSI: &v1.CSIPersistentVolumeSource{ Driver: csiDriverGCP, From c1ff70b880ec78877c6e96b703b3bfbe6b8b09a5 Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Fri, 19 Apr 2024 09:20:24 -0500 Subject: [PATCH 5/8] make generate --- .../internal/metadata/generated_metrics.go | 12 ++++++++++++ .../internal/metadata/testdata/config.yaml | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go index 63ed8fb7a32b..b4a7d88b2c0b 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go @@ -2978,6 +2978,18 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting if mbc.ResourceAttributes.ContainerID.Exclude != nil { mb.resourceAttributeExcludeFilter["container.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerID.Exclude) } + if mbc.ResourceAttributes.CsiDriver.Include != nil { + mb.resourceAttributeIncludeFilter["csi.driver"] = filter.CreateFilter(mbc.ResourceAttributes.CsiDriver.Include) + } + if mbc.ResourceAttributes.CsiDriver.Exclude != nil { + mb.resourceAttributeExcludeFilter["csi.driver"] = filter.CreateFilter(mbc.ResourceAttributes.CsiDriver.Exclude) + } + if mbc.ResourceAttributes.CsiVolumeHandle.Include != nil { + mb.resourceAttributeIncludeFilter["csi.volume.handle"] = filter.CreateFilter(mbc.ResourceAttributes.CsiVolumeHandle.Include) + } + if mbc.ResourceAttributes.CsiVolumeHandle.Exclude != nil { + mb.resourceAttributeExcludeFilter["csi.volume.handle"] = filter.CreateFilter(mbc.ResourceAttributes.CsiVolumeHandle.Exclude) + } if mbc.ResourceAttributes.FsType.Include != nil { mb.resourceAttributeIncludeFilter["fs.type"] = filter.CreateFilter(mbc.ResourceAttributes.FsType.Include) } diff --git a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml index 0625641ab442..12646c956a7b 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml @@ -307,6 +307,14 @@ filter_set_include: enabled: true include: - regexp: ".*" + csi.driver: + enabled: true + include: + - regexp: ".*" + csi.volume.handle: + enabled: true + include: + - regexp: ".*" fs.type: enabled: true include: @@ -369,6 +377,14 @@ filter_set_exclude: enabled: true exclude: - strict: "container.id-val" + csi.driver: + enabled: true + exclude: + - strict: "csi.driver-val" + csi.volume.handle: + enabled: true + exclude: + - strict: "csi.volume.handle-val" fs.type: enabled: true exclude: From 077c70cc6292f726f925f9c499f4644d610039ae Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Mon, 6 May 2024 12:13:21 -0500 Subject: [PATCH 6/8] make generate --- .../internal/metadata/generated_metrics.go | 12 ++++++++++++ .../internal/metadata/testdata/config.yaml | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go index b966d529769b..76c2a6fa3f05 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go @@ -2978,6 +2978,18 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting if mbc.ResourceAttributes.ContainerID.MetricsExclude != nil { mb.resourceAttributeExcludeFilter["container.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerID.MetricsExclude) } + if mbc.ResourceAttributes.CsiDriver.MetricsInclude != nil { + mb.resourceAttributeIncludeFilter["csi.driver"] = filter.CreateFilter(mbc.ResourceAttributes.CsiDriver.MetricsInclude) + } + if mbc.ResourceAttributes.CsiDriver.MetricsExclude != nil { + mb.resourceAttributeExcludeFilter["csi.driver"] = filter.CreateFilter(mbc.ResourceAttributes.CsiDriver.MetricsExclude) + } + if mbc.ResourceAttributes.CsiVolumeHandle.MetricsInclude != nil { + mb.resourceAttributeIncludeFilter["csi.volume.handle"] = filter.CreateFilter(mbc.ResourceAttributes.CsiVolumeHandle.MetricsInclude) + } + if mbc.ResourceAttributes.CsiVolumeHandle.MetricsExclude != nil { + mb.resourceAttributeExcludeFilter["csi.volume.handle"] = filter.CreateFilter(mbc.ResourceAttributes.CsiVolumeHandle.MetricsExclude) + } if mbc.ResourceAttributes.FsType.MetricsInclude != nil { mb.resourceAttributeIncludeFilter["fs.type"] = filter.CreateFilter(mbc.ResourceAttributes.FsType.MetricsInclude) } diff --git a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml index 43f485064d9b..e79b608481b4 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml @@ -309,11 +309,11 @@ filter_set_include: - regexp: ".*" csi.driver: enabled: true - include: + metrics_include: - regexp: ".*" csi.volume.handle: enabled: true - include: + metrics_include: - regexp: ".*" fs.type: enabled: true @@ -379,11 +379,11 @@ filter_set_exclude: - strict: "container.id-val" csi.driver: enabled: true - exclude: + metrics_exclude: - strict: "csi.driver-val" csi.volume.handle: enabled: true - exclude: + metrics_exclude: - strict: "csi.volume.handle-val" fs.type: enabled: true From 5f63e9ea268550878951b9b1c345e374d93cee56 Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Mon, 6 May 2024 14:16:04 -0500 Subject: [PATCH 7/8] lint: interface->any --- receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go index 9246bee46a4e..b3ed2de5a650 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go @@ -168,7 +168,7 @@ func TestDetailedPVCLabels(t *testing.T) { }) return nil }, - want: map[string]interface{}{ + want: map[string]any{ "k8s.volume.name": "volume0", "k8s.volume.type": labelValueCSIPersistentVolume, "k8s.persistentvolumeclaim.name": "claim-name", From 737587b564065dd76cce23b51e1b2baf3f9f91f1 Mon Sep 17 00:00:00 2001 From: Greg Dallavalle Date: Mon, 23 Sep 2024 11:50:07 -0500 Subject: [PATCH 8/8] rename csi metrics for semconv, keep PVC as vol type --- .../kubeletstats_add_csi_volume_attrs.yaml | 3 +- .../kubeletstatsreceiver/documentation.md | 4 +-- .../internal/kubelet/conventions.go | 1 - .../internal/kubelet/volume.go | 6 ++-- .../internal/kubelet/volume_test.go | 6 ++-- .../internal/metadata/generated_config.go | 10 +++---- .../metadata/generated_config_test.go | 16 +++++----- .../internal/metadata/generated_metrics.go | 24 +++++++-------- .../metadata/generated_metrics_test.go | 4 +-- .../internal/metadata/generated_resource.go | 24 +++++++-------- .../metadata/generated_resource_test.go | 16 +++++----- .../internal/metadata/testdata/config.yaml | 30 +++++++++---------- receiver/kubeletstatsreceiver/metadata.yaml | 8 ++--- 13 files changed, 74 insertions(+), 78 deletions(-) diff --git a/.chloggen/kubeletstats_add_csi_volume_attrs.yaml b/.chloggen/kubeletstats_add_csi_volume_attrs.yaml index d37726a343ef..e08a4181e348 100644 --- a/.chloggen/kubeletstats_add_csi_volume_attrs.yaml +++ b/.chloggen/kubeletstats_add_csi_volume_attrs.yaml @@ -16,8 +16,7 @@ issues: [32055] # These lines will be padded with 2 spaces and then inserted directly into the document. # Use pipe (|) for multiline entries. subtext: | - Add `csi.driver` and `csi.volume.handle` resource attributes to PVC metrics. - Label volume metrics with type `csiPersistentVolume` if backed by CSI. + Add `container.csi.plugin.name` and `container.csi.volume.id` resource attributes to PVC metrics. If a GCP PD is detected (uses `pd.csi.storage.gke.io`), set `gce.pd.name` to the parsed disk name. This will match with disk names in GCP, allowing for correlation of GCE-native metrics. diff --git a/receiver/kubeletstatsreceiver/documentation.md b/receiver/kubeletstatsreceiver/documentation.md index 76f7042fd7d8..32b5d2160dca 100644 --- a/receiver/kubeletstatsreceiver/documentation.md +++ b/receiver/kubeletstatsreceiver/documentation.md @@ -535,9 +535,9 @@ The time since the pod started | Name | Description | Values | Enabled | | ---- | ----------- | ------ | ------- | | aws.volume.id | The id of the AWS Volume | Any Str | true | +| container.csi.plugin.name | Container Storage Interface plugin name | Any Str | true | +| container.csi.volume.id | Container Storage Interface volume ID | Any Str | true | | container.id | Container id used to identify container | Any Str | true | -| csi.driver | CSI driver | Any Str | true | -| csi.volume.handle | CSI volume handle | Any Str | true | | fs.type | The filesystem type of the Volume | Any Str | true | | gce.pd.name | The name of the persistent disk in GCE | Any Str | true | | glusterfs.endpoints.name | The endpoint name that details Glusterfs topology | Any Str | true | diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go b/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go index 4b04fa933108..23c53755dcef 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/conventions.go @@ -16,6 +16,5 @@ const ( labelValueLocalVolume = "local" labelValueAWSEBSVolume = "awsElasticBlockStore" labelValueGCEPDVolume = "gcePersistentDisk" - labelValueCSIPersistentVolume = "csiPersistentVolume" labelValueGlusterFSVolume = "glusterfs" ) diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume.go index dd3e3d205aef..25ea553354c9 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume.go @@ -99,11 +99,9 @@ func glusterfsDims(rb *metadata.ResourceBuilder, vs v1.GlusterfsVolumeSource) { } func csiPersistentVolumeDims(rb *metadata.ResourceBuilder, vs v1.CSIPersistentVolumeSource) { - rb.SetK8sVolumeType(labelValueCSIPersistentVolume) - // CSI specific labels. - rb.SetCsiVolumeHandle(vs.VolumeHandle) - rb.SetCsiDriver(vs.Driver) + rb.SetContainerCsiVolumeID(vs.VolumeHandle) + rb.SetContainerCsiPluginName(vs.Driver) rb.SetFsType(vs.FSType) // CSI driver specific labels. diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go index 07c92e922c41..4c6371144f92 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/volume_test.go @@ -170,14 +170,14 @@ func TestDetailedPVCLabels(t *testing.T) { }, want: map[string]any{ "k8s.volume.name": "volume0", - "k8s.volume.type": labelValueCSIPersistentVolume, + "k8s.volume.type": labelValuePersistentVolumeClaim, "k8s.persistentvolumeclaim.name": "claim-name", "k8s.pod.uid": "uid-1234", "k8s.pod.name": "pod-name", "k8s.namespace.name": "pod-namespace", "gce.pd.name": "disk-name", - "csi.driver": csiDriverGCP, - "csi.volume.handle": "projects/project-name/zones/us-central1-a/disks/disk-name", + "container.csi.plugin.name": csiDriverGCP, + "container.csi.volume.id": "projects/project-name/zones/us-central1-a/disks/disk-name", "fs.type": "ext4", }, }, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go index fd3df54ca5c3..ea6549b3bfe1 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go @@ -304,9 +304,9 @@ func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { // ResourceAttributesConfig provides config for kubeletstats resource attributes. type ResourceAttributesConfig struct { AwsVolumeID ResourceAttributeConfig `mapstructure:"aws.volume.id"` + ContainerCsiPluginName ResourceAttributeConfig `mapstructure:"container.csi.plugin.name"` + ContainerCsiVolumeID ResourceAttributeConfig `mapstructure:"container.csi.volume.id"` ContainerID ResourceAttributeConfig `mapstructure:"container.id"` - CsiDriver ResourceAttributeConfig `mapstructure:"csi.driver"` - CsiVolumeHandle ResourceAttributeConfig `mapstructure:"csi.volume.handle"` FsType ResourceAttributeConfig `mapstructure:"fs.type"` GcePdName ResourceAttributeConfig `mapstructure:"gce.pd.name"` GlusterfsEndpointsName ResourceAttributeConfig `mapstructure:"glusterfs.endpoints.name"` @@ -327,13 +327,13 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { AwsVolumeID: ResourceAttributeConfig{ Enabled: true, }, - ContainerID: ResourceAttributeConfig{ + ContainerCsiPluginName: ResourceAttributeConfig{ Enabled: true, }, - CsiDriver: ResourceAttributeConfig{ + ContainerCsiVolumeID: ResourceAttributeConfig{ Enabled: true, }, - CsiVolumeHandle: ResourceAttributeConfig{ + ContainerID: ResourceAttributeConfig{ Enabled: true, }, FsType: ResourceAttributeConfig{ diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go index 695c2cd816b1..b7523311ce32 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go @@ -88,9 +88,9 @@ func TestMetricsBuilderConfig(t *testing.T) { }, ResourceAttributes: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: true}, + ContainerCsiPluginName: ResourceAttributeConfig{Enabled: true}, + ContainerCsiVolumeID: ResourceAttributeConfig{Enabled: true}, ContainerID: ResourceAttributeConfig{Enabled: true}, - CsiDriver: ResourceAttributeConfig{Enabled: true}, - CsiVolumeHandle: ResourceAttributeConfig{Enabled: true}, FsType: ResourceAttributeConfig{Enabled: true}, GcePdName: ResourceAttributeConfig{Enabled: true}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: true}, @@ -174,9 +174,9 @@ func TestMetricsBuilderConfig(t *testing.T) { }, ResourceAttributes: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: false}, + ContainerCsiPluginName: ResourceAttributeConfig{Enabled: false}, + ContainerCsiVolumeID: ResourceAttributeConfig{Enabled: false}, ContainerID: ResourceAttributeConfig{Enabled: false}, - CsiDriver: ResourceAttributeConfig{Enabled: false}, - CsiVolumeHandle: ResourceAttributeConfig{Enabled: false}, FsType: ResourceAttributeConfig{Enabled: false}, GcePdName: ResourceAttributeConfig{Enabled: false}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: false}, @@ -227,9 +227,9 @@ func TestResourceAttributesConfig(t *testing.T) { name: "all_set", want: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: true}, + ContainerCsiPluginName: ResourceAttributeConfig{Enabled: true}, + ContainerCsiVolumeID: ResourceAttributeConfig{Enabled: true}, ContainerID: ResourceAttributeConfig{Enabled: true}, - CsiDriver: ResourceAttributeConfig{Enabled: true}, - CsiVolumeHandle: ResourceAttributeConfig{Enabled: true}, FsType: ResourceAttributeConfig{Enabled: true}, GcePdName: ResourceAttributeConfig{Enabled: true}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: true}, @@ -249,9 +249,9 @@ func TestResourceAttributesConfig(t *testing.T) { name: "none_set", want: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: false}, + ContainerCsiPluginName: ResourceAttributeConfig{Enabled: false}, + ContainerCsiVolumeID: ResourceAttributeConfig{Enabled: false}, ContainerID: ResourceAttributeConfig{Enabled: false}, - CsiDriver: ResourceAttributeConfig{Enabled: false}, - CsiVolumeHandle: ResourceAttributeConfig{Enabled: false}, FsType: ResourceAttributeConfig{Enabled: false}, GcePdName: ResourceAttributeConfig{Enabled: false}, GlusterfsEndpointsName: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go index 71a7942ef8dd..88af8b5e244b 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go @@ -3184,23 +3184,23 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, opt if mbc.ResourceAttributes.AwsVolumeID.MetricsExclude != nil { mb.resourceAttributeExcludeFilter["aws.volume.id"] = filter.CreateFilter(mbc.ResourceAttributes.AwsVolumeID.MetricsExclude) } - if mbc.ResourceAttributes.ContainerID.MetricsInclude != nil { - mb.resourceAttributeIncludeFilter["container.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerID.MetricsInclude) + if mbc.ResourceAttributes.ContainerCsiPluginName.MetricsInclude != nil { + mb.resourceAttributeIncludeFilter["container.csi.plugin.name"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerCsiPluginName.MetricsInclude) } - if mbc.ResourceAttributes.ContainerID.MetricsExclude != nil { - mb.resourceAttributeExcludeFilter["container.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerID.MetricsExclude) + if mbc.ResourceAttributes.ContainerCsiPluginName.MetricsExclude != nil { + mb.resourceAttributeExcludeFilter["container.csi.plugin.name"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerCsiPluginName.MetricsExclude) } - if mbc.ResourceAttributes.CsiDriver.MetricsInclude != nil { - mb.resourceAttributeIncludeFilter["csi.driver"] = filter.CreateFilter(mbc.ResourceAttributes.CsiDriver.MetricsInclude) + if mbc.ResourceAttributes.ContainerCsiVolumeID.MetricsInclude != nil { + mb.resourceAttributeIncludeFilter["container.csi.volume.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerCsiVolumeID.MetricsInclude) } - if mbc.ResourceAttributes.CsiDriver.MetricsExclude != nil { - mb.resourceAttributeExcludeFilter["csi.driver"] = filter.CreateFilter(mbc.ResourceAttributes.CsiDriver.MetricsExclude) + if mbc.ResourceAttributes.ContainerCsiVolumeID.MetricsExclude != nil { + mb.resourceAttributeExcludeFilter["container.csi.volume.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerCsiVolumeID.MetricsExclude) } - if mbc.ResourceAttributes.CsiVolumeHandle.MetricsInclude != nil { - mb.resourceAttributeIncludeFilter["csi.volume.handle"] = filter.CreateFilter(mbc.ResourceAttributes.CsiVolumeHandle.MetricsInclude) + if mbc.ResourceAttributes.ContainerID.MetricsInclude != nil { + mb.resourceAttributeIncludeFilter["container.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerID.MetricsInclude) } - if mbc.ResourceAttributes.CsiVolumeHandle.MetricsExclude != nil { - mb.resourceAttributeExcludeFilter["csi.volume.handle"] = filter.CreateFilter(mbc.ResourceAttributes.CsiVolumeHandle.MetricsExclude) + if mbc.ResourceAttributes.ContainerID.MetricsExclude != nil { + mb.resourceAttributeExcludeFilter["container.id"] = filter.CreateFilter(mbc.ResourceAttributes.ContainerID.MetricsExclude) } if mbc.ResourceAttributes.FsType.MetricsInclude != nil { mb.resourceAttributeIncludeFilter["fs.type"] = filter.CreateFilter(mbc.ResourceAttributes.FsType.MetricsInclude) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go index 58811e17cef9..b6606817678f 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go @@ -304,9 +304,9 @@ func TestMetricsBuilder(t *testing.T) { rb := mb.NewResourceBuilder() rb.SetAwsVolumeID("aws.volume.id-val") + rb.SetContainerCsiPluginName("container.csi.plugin.name-val") + rb.SetContainerCsiVolumeID("container.csi.volume.id-val") rb.SetContainerID("container.id-val") - rb.SetCsiDriver("csi.driver-val") - rb.SetCsiVolumeHandle("csi.volume.handle-val") rb.SetFsType("fs.type-val") rb.SetGcePdName("gce.pd.name-val") rb.SetGlusterfsEndpointsName("glusterfs.endpoints.name-val") diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go index 3652b9790ab8..0740eb029bdd 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource.go @@ -28,24 +28,24 @@ func (rb *ResourceBuilder) SetAwsVolumeID(val string) { } } -// SetContainerID sets provided value as "container.id" attribute. -func (rb *ResourceBuilder) SetContainerID(val string) { - if rb.config.ContainerID.Enabled { - rb.res.Attributes().PutStr("container.id", val) +// SetContainerCsiPluginName sets provided value as "container.csi.plugin.name" attribute. +func (rb *ResourceBuilder) SetContainerCsiPluginName(val string) { + if rb.config.ContainerCsiPluginName.Enabled { + rb.res.Attributes().PutStr("container.csi.plugin.name", val) } } -// SetCsiDriver sets provided value as "csi.driver" attribute. -func (rb *ResourceBuilder) SetCsiDriver(val string) { - if rb.config.CsiDriver.Enabled { - rb.res.Attributes().PutStr("csi.driver", val) +// SetContainerCsiVolumeID sets provided value as "container.csi.volume.id" attribute. +func (rb *ResourceBuilder) SetContainerCsiVolumeID(val string) { + if rb.config.ContainerCsiVolumeID.Enabled { + rb.res.Attributes().PutStr("container.csi.volume.id", val) } } -// SetCsiVolumeHandle sets provided value as "csi.volume.handle" attribute. -func (rb *ResourceBuilder) SetCsiVolumeHandle(val string) { - if rb.config.CsiVolumeHandle.Enabled { - rb.res.Attributes().PutStr("csi.volume.handle", val) +// SetContainerID sets provided value as "container.id" attribute. +func (rb *ResourceBuilder) SetContainerID(val string) { + if rb.config.ContainerID.Enabled { + rb.res.Attributes().PutStr("container.id", val) } } diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go index f5aa00cf6963..42c9ccb222cc 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_resource_test.go @@ -14,9 +14,9 @@ func TestResourceBuilder(t *testing.T) { cfg := loadResourceAttributesConfig(t, test) rb := NewResourceBuilder(cfg) rb.SetAwsVolumeID("aws.volume.id-val") + rb.SetContainerCsiPluginName("container.csi.plugin.name-val") + rb.SetContainerCsiVolumeID("container.csi.volume.id-val") rb.SetContainerID("container.id-val") - rb.SetCsiDriver("csi.driver-val") - rb.SetCsiVolumeHandle("csi.volume.handle-val") rb.SetFsType("fs.type-val") rb.SetGcePdName("gce.pd.name-val") rb.SetGlusterfsEndpointsName("glusterfs.endpoints.name-val") @@ -51,20 +51,20 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "aws.volume.id-val", val.Str()) } - val, ok = res.Attributes().Get("container.id") + val, ok = res.Attributes().Get("container.csi.plugin.name") assert.True(t, ok) if ok { - assert.EqualValues(t, "container.id-val", val.Str()) + assert.EqualValues(t, "container.csi.plugin.name-val", val.Str()) } - val, ok = res.Attributes().Get("csi.driver") + val, ok = res.Attributes().Get("container.csi.volume.id") assert.True(t, ok) if ok { - assert.EqualValues(t, "csi.driver-val", val.Str()) + assert.EqualValues(t, "container.csi.volume.id-val", val.Str()) } - val, ok = res.Attributes().Get("csi.volume.handle") + val, ok = res.Attributes().Get("container.id") assert.True(t, ok) if ok { - assert.EqualValues(t, "csi.volume.handle-val", val.Str()) + assert.EqualValues(t, "container.id-val", val.Str()) } val, ok = res.Attributes().Get("fs.type") assert.True(t, ok) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml index 504e7343924d..6c630386583b 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml @@ -124,11 +124,11 @@ all_set: resource_attributes: aws.volume.id: enabled: true - container.id: + container.csi.plugin.name: enabled: true - csi.driver: + container.csi.volume.id: enabled: true - csi.volume.handle: + container.id: enabled: true fs.type: enabled: true @@ -281,11 +281,11 @@ none_set: resource_attributes: aws.volume.id: enabled: false - container.id: + container.csi.plugin.name: enabled: false - csi.driver: + container.csi.volume.id: enabled: false - csi.volume.handle: + container.id: enabled: false fs.type: enabled: false @@ -319,15 +319,15 @@ filter_set_include: enabled: true metrics_include: - regexp: ".*" - container.id: + container.csi.plugin.name: enabled: true metrics_include: - regexp: ".*" - csi.driver: + container.csi.volume.id: enabled: true metrics_include: - regexp: ".*" - csi.volume.handle: + container.id: enabled: true metrics_include: - regexp: ".*" @@ -389,18 +389,18 @@ filter_set_exclude: enabled: true metrics_exclude: - strict: "aws.volume.id-val" - container.id: + container.csi.plugin.name: enabled: true metrics_exclude: - - strict: "container.id-val" - csi.driver: + - strict: "container.csi.plugin.name-val" + container.csi.volume.id: enabled: true metrics_exclude: - - strict: "csi.driver-val" - csi.volume.handle: + - strict: "container.csi.volume.id-val" + container.id: enabled: true metrics_exclude: - - strict: "csi.volume.handle-val" + - strict: "container.id-val" fs.type: enabled: true metrics_exclude: diff --git a/receiver/kubeletstatsreceiver/metadata.yaml b/receiver/kubeletstatsreceiver/metadata.yaml index 2460412fd6a5..00592de3007c 100644 --- a/receiver/kubeletstatsreceiver/metadata.yaml +++ b/receiver/kubeletstatsreceiver/metadata.yaml @@ -69,12 +69,12 @@ resource_attributes: description: "Glusterfs volume path" enabled: true type: string - csi.volume.handle: - description: "CSI volume handle" + container.csi.volume.id: + description: "Container Storage Interface volume ID" enabled: true type: string - csi.driver: - description: "CSI driver" + container.csi.plugin.name: + description: "Container Storage Interface plugin name" enabled: true type: string