diff --git a/.chloggen/k8scluster_add-resource-attributes.yaml b/.chloggen/k8scluster_add-resource-attributes.yaml index d1a11ee71bee..c20ba559824e 100755 --- a/.chloggen/k8scluster_add-resource-attributes.yaml +++ b/.chloggen/k8scluster_add-resource-attributes.yaml @@ -7,7 +7,7 @@ change_type: enhancement component: k8sclusterreceiver # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: "add new disabled os.version, os.description, k8s.container_runtime.version resource attributes" +note: "add new disabled os.description, k8s.container_runtime.version resource attributes" # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. issues: [30342] diff --git a/.chloggen/k8scluster_fix-resource-attributes.yaml b/.chloggen/k8scluster_fix-resource-attributes.yaml new file mode 100755 index 000000000000..0b832eb00ded --- /dev/null +++ b/.chloggen/k8scluster_fix-resource-attributes.yaml @@ -0,0 +1,27 @@ +# 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: k8sclusterreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "add os.type resource attribute" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [30342] + +# (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: + +# 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] diff --git a/receiver/k8sclusterreceiver/documentation.md b/receiver/k8sclusterreceiver/documentation.md index 3f9f0a3974d5..78d0339742a1 100644 --- a/receiver/k8sclusterreceiver/documentation.md +++ b/receiver/k8sclusterreceiver/documentation.md @@ -458,4 +458,4 @@ Current status reason of the pod (1 - Evicted, 2 - NodeAffinity, 3 - NodeLost, 4 | openshift.clusterquota.name | The k8s ClusterResourceQuota name. | Any Str | true | | openshift.clusterquota.uid | The k8s ClusterResourceQuota uid. | Any Str | true | | os.description | The os description used by Kubernetes Node. | Any Str | false | -| os.version | The version of operating system used by Kubernetes Node. | Any Str | false | +| os.type | The os type used by Kubernetes Node. | Any Str | false | diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_config.go b/receiver/k8sclusterreceiver/internal/metadata/generated_config.go index 130bb0f3beca..0ce3c13724b4 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_config.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_config.go @@ -265,7 +265,7 @@ type ResourceAttributesConfig struct { OpenshiftClusterquotaName ResourceAttributeConfig `mapstructure:"openshift.clusterquota.name"` OpenshiftClusterquotaUID ResourceAttributeConfig `mapstructure:"openshift.clusterquota.uid"` OsDescription ResourceAttributeConfig `mapstructure:"os.description"` - OsVersion ResourceAttributeConfig `mapstructure:"os.version"` + OsType ResourceAttributeConfig `mapstructure:"os.type"` } func DefaultResourceAttributesConfig() ResourceAttributesConfig { @@ -378,7 +378,7 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { OsDescription: ResourceAttributeConfig{ Enabled: false, }, - OsVersion: ResourceAttributeConfig{ + OsType: ResourceAttributeConfig{ Enabled: false, }, } diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go b/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go index 0e635af76047..15e165e2ce75 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go @@ -108,7 +108,7 @@ func TestMetricsBuilderConfig(t *testing.T) { OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: true}, OpenshiftClusterquotaUID: ResourceAttributeConfig{Enabled: true}, OsDescription: ResourceAttributeConfig{Enabled: true}, - OsVersion: ResourceAttributeConfig{Enabled: true}, + OsType: ResourceAttributeConfig{Enabled: true}, }, }, }, @@ -198,7 +198,7 @@ func TestMetricsBuilderConfig(t *testing.T) { OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: false}, OpenshiftClusterquotaUID: ResourceAttributeConfig{Enabled: false}, OsDescription: ResourceAttributeConfig{Enabled: false}, - OsVersion: ResourceAttributeConfig{Enabled: false}, + OsType: ResourceAttributeConfig{Enabled: false}, }, }, }, @@ -271,7 +271,7 @@ func TestResourceAttributesConfig(t *testing.T) { OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: true}, OpenshiftClusterquotaUID: ResourceAttributeConfig{Enabled: true}, OsDescription: ResourceAttributeConfig{Enabled: true}, - OsVersion: ResourceAttributeConfig{Enabled: true}, + OsType: ResourceAttributeConfig{Enabled: true}, }, }, { @@ -313,7 +313,7 @@ func TestResourceAttributesConfig(t *testing.T) { OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: false}, OpenshiftClusterquotaUID: ResourceAttributeConfig{Enabled: false}, OsDescription: ResourceAttributeConfig{Enabled: false}, - OsVersion: ResourceAttributeConfig{Enabled: false}, + OsType: ResourceAttributeConfig{Enabled: false}, }, }, } diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go b/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go index 24bb01c94962..18b67c686dbd 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go @@ -270,7 +270,7 @@ func TestMetricsBuilder(t *testing.T) { rb.SetOpenshiftClusterquotaName("openshift.clusterquota.name-val") rb.SetOpenshiftClusterquotaUID("openshift.clusterquota.uid-val") rb.SetOsDescription("os.description-val") - rb.SetOsVersion("os.version-val") + rb.SetOsType("os.type-val") res := rb.Emit() metrics := mb.Emit(WithResource(res)) diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go b/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go index 526006978c51..6002f6e6e053 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go @@ -273,10 +273,10 @@ func (rb *ResourceBuilder) SetOsDescription(val string) { } } -// SetOsVersion sets provided value as "os.version" attribute. -func (rb *ResourceBuilder) SetOsVersion(val string) { - if rb.config.OsVersion.Enabled { - rb.res.Attributes().PutStr("os.version", val) +// SetOsType sets provided value as "os.type" attribute. +func (rb *ResourceBuilder) SetOsType(val string) { + if rb.config.OsType.Enabled { + rb.res.Attributes().PutStr("os.type", val) } } diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go b/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go index 76845a5d6d78..ead39ea2bc2b 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go @@ -49,7 +49,7 @@ func TestResourceBuilder(t *testing.T) { rb.SetOpenshiftClusterquotaName("openshift.clusterquota.name-val") rb.SetOpenshiftClusterquotaUID("openshift.clusterquota.uid-val") rb.SetOsDescription("os.description-val") - rb.SetOsVersion("os.version-val") + rb.SetOsType("os.type-val") res := rb.Emit() assert.Equal(t, 0, rb.Emit().Attributes().Len()) // Second call should return empty Resource @@ -246,10 +246,10 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "os.description-val", val.Str()) } - val, ok = res.Attributes().Get("os.version") + val, ok = res.Attributes().Get("os.type") assert.Equal(t, test == "all_set", ok) if ok { - assert.EqualValues(t, "os.version-val", val.Str()) + assert.EqualValues(t, "os.type-val", val.Str()) } }) } diff --git a/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml b/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml index c3e20af936e7..bd8704d966e3 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml @@ -162,7 +162,7 @@ all_set: enabled: true os.description: enabled: true - os.version: + os.type: enabled: true none_set: metrics: @@ -327,5 +327,5 @@ none_set: enabled: false os.description: enabled: false - os.version: + os.type: enabled: false diff --git a/receiver/k8sclusterreceiver/internal/node/nodes.go b/receiver/k8sclusterreceiver/internal/node/nodes.go index 842442a75468..8c63d3b965a0 100644 --- a/receiver/k8sclusterreceiver/internal/node/nodes.go +++ b/receiver/k8sclusterreceiver/internal/node/nodes.go @@ -37,9 +37,9 @@ func Transform(node *corev1.Node) *corev1.Node { NodeInfo: corev1.NodeSystemInfo{ KubeletVersion: node.Status.NodeInfo.KubeletVersion, KubeProxyVersion: node.Status.NodeInfo.KubeProxyVersion, - KernelVersion: node.Status.NodeInfo.KernelVersion, ContainerRuntimeVersion: node.Status.NodeInfo.ContainerRuntimeVersion, OSImage: node.Status.NodeInfo.OSImage, + OperatingSystem: node.Status.NodeInfo.OperatingSystem, }, }, } @@ -115,7 +115,7 @@ func CustomMetrics(set receiver.CreateSettings, rb *metadata.ResourceBuilder, no rb.SetK8sNodeName(node.Name) rb.SetK8sKubeletVersion(node.Status.NodeInfo.KubeletVersion) rb.SetK8sKubeproxyVersion(node.Status.NodeInfo.KubeProxyVersion) - rb.SetOsVersion(node.Status.NodeInfo.KernelVersion) + rb.SetOsType(node.Status.NodeInfo.OperatingSystem) runtime, version := getContainerRuntimeInfo(node.Status.NodeInfo.ContainerRuntimeVersion) if runtime != "" { diff --git a/receiver/k8sclusterreceiver/internal/node/nodes_test.go b/receiver/k8sclusterreceiver/internal/node/nodes_test.go index a2d242429a1c..5bb613b4abf2 100644 --- a/receiver/k8sclusterreceiver/internal/node/nodes_test.go +++ b/receiver/k8sclusterreceiver/internal/node/nodes_test.go @@ -68,7 +68,7 @@ func TestNodeOptionalMetrics(t *testing.T) { rac.K8sKubeproxyVersion.Enabled = true rac.ContainerRuntime.Enabled = true rac.ContainerRuntimeVersion.Enabled = true - rac.OsVersion.Enabled = true + rac.OsType.Enabled = true rac.OsDescription.Enabled = true rb := metadata.NewResourceBuilder(rac) @@ -256,9 +256,9 @@ func TestTransform(t *testing.T) { NodeInfo: corev1.NodeSystemInfo{ KubeletVersion: "v1.25.3", KubeProxyVersion: "v1.25.3", - KernelVersion: "6.4.12-arch1-1", OSImage: "Ubuntu 22.04.1 LTS", ContainerRuntimeVersion: "containerd://1.6.9", + OperatingSystem: "linux", }, }, } diff --git a/receiver/k8sclusterreceiver/internal/node/testdata/expected_optional.yaml b/receiver/k8sclusterreceiver/internal/node/testdata/expected_optional.yaml index e07408bd45de..9c95a3edf621 100644 --- a/receiver/k8sclusterreceiver/internal/node/testdata/expected_optional.yaml +++ b/receiver/k8sclusterreceiver/internal/node/testdata/expected_optional.yaml @@ -22,9 +22,9 @@ resourceMetrics: - key: os.description value: stringValue: Ubuntu 22.04.1 LTS - - key: os.version + - key: os.type value: - stringValue: "6.4.12-arch1-1" + stringValue: "linux" schemaUrl: https://opentelemetry.io/schemas/1.18.0 scopeMetrics: diff --git a/receiver/k8sclusterreceiver/internal/testutils/objects.go b/receiver/k8sclusterreceiver/internal/testutils/objects.go index 508ab1f9c52d..84bd3983bd24 100644 --- a/receiver/k8sclusterreceiver/internal/testutils/objects.go +++ b/receiver/k8sclusterreceiver/internal/testutils/objects.go @@ -203,9 +203,9 @@ func NewNode(id string) *corev1.Node { NodeInfo: corev1.NodeSystemInfo{ KubeletVersion: "v1.25.3", KubeProxyVersion: "v1.25.3", - KernelVersion: "6.4.12-arch1-1", OSImage: "Ubuntu 22.04.1 LTS", ContainerRuntimeVersion: "containerd://1.6.9", + OperatingSystem: "linux", }, }, } diff --git a/receiver/k8sclusterreceiver/metadata.yaml b/receiver/k8sclusterreceiver/metadata.yaml index 7682608665f6..70fe006ff7c6 100644 --- a/receiver/k8sclusterreceiver/metadata.yaml +++ b/receiver/k8sclusterreceiver/metadata.yaml @@ -172,13 +172,13 @@ resource_attributes: type: string enabled: false - os.version: - description: The version of operating system used by Kubernetes Node. + os.description: + description: The os description used by Kubernetes Node. type: string enabled: false - os.description: - description: The os description used by Kubernetes Node. + os.type: + description: The os type used by Kubernetes Node. type: string enabled: false