Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/elasticsearch] Translate k8s.*.name resource attributes in ECS mode #36233

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/elasticsearchexporter_ecs-translate-k8s-names.yaml
Original file line number Diff line number Diff line change
@@ -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: elasticsearchexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Translate `k8s.*.name` resource attributes to `kubernetes.*.name` in ECS mode

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36233]

# (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: The resource attributes are `k8s.job.name`, `k8s.cronjob.name`, `k8s.statefulset.name`, `k8s.replicaset.name`, `k8s.daemonset.name`, `k8s.cluster.name`, `k8s.container.name`.

# 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]
7 changes: 7 additions & 0 deletions exporter/elasticsearchexporter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ var resourceAttrsConversionMap = map[string]string{
semconv.AttributeK8SNodeName: "kubernetes.node.name",
semconv.AttributeK8SPodName: "kubernetes.pod.name",
semconv.AttributeK8SPodUID: "kubernetes.pod.uid",
semconv.AttributeK8SJobName: "kubernetes.job.name",
semconv.AttributeK8SCronJobName: "kubernetes.cronjob.name",
semconv.AttributeK8SStatefulSetName: "kubernetes.statefulset.name",
semconv.AttributeK8SReplicaSetName: "kubernetes.replicaset.name",
semconv.AttributeK8SDaemonSetName: "kubernetes.daemonset.name",
ChrsMark marked this conversation as resolved.
Show resolved Hide resolved
semconv.AttributeK8SClusterName: "kubernetes.cluster.name",
carsonip marked this conversation as resolved.
Show resolved Hide resolved
carsonip marked this conversation as resolved.
Show resolved Hide resolved
semconv.AttributeK8SContainerName: "kubernetes.container.name",
}

// resourceAttrsToPreserve contains conventions that should be preserved in ECS mode.
Expand Down
16 changes: 15 additions & 1 deletion exporter/elasticsearchexporter/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ func TestEncodeLogECSMode(t *testing.T) {
"k8s.pod.name": "opentelemetry-pod-autoconf",
"k8s.pod.uid": "275ecb36-5aa8-4c2a-9c47-d8bb681b9aff",
"k8s.deployment.name": "coredns",
semconv.AttributeK8SJobName: "job.name",
semconv.AttributeK8SCronJobName: "cronjob.name",
semconv.AttributeK8SStatefulSetName: "statefulset.name",
semconv.AttributeK8SReplicaSetName: "replicaset.name",
semconv.AttributeK8SDaemonSetName: "daemonset.name",
semconv.AttributeK8SClusterName: "cluster.name",
semconv.AttributeK8SContainerName: "container.name",
})
require.NoError(t, err)

Expand Down Expand Up @@ -444,7 +451,14 @@ func TestEncodeLogECSMode(t *testing.T) {
"kubernetes.node.name": "node-1",
"kubernetes.pod.name": "opentelemetry-pod-autoconf",
"kubernetes.pod.uid": "275ecb36-5aa8-4c2a-9c47-d8bb681b9aff",
"kubernetes.deployment.name": "coredns"
"kubernetes.deployment.name": "coredns",
"kubernetes.job.name": "job.name",
"kubernetes.cronjob.name": "cronjob.name",
"kubernetes.statefulset.name": "statefulset.name",
"kubernetes.replicaset.name": "replicaset.name",
"kubernetes.daemonset.name": "daemonset.name",
"kubernetes.cluster.name": "cluster.name",
carsonip marked this conversation as resolved.
Show resolved Hide resolved
"kubernetes.container.name": "container.name"
}`, buf.String())
}

Expand Down