Skip to content

Commit af3da82

Browse files
authored
feat(helm v5): Make k8sattributes processor as default and deprecate k8s_tagger for k8s metadata enrichment (#4093)
1 parent 978251f commit af3da82

39 files changed

+1021
-544
lines changed

.changelog/4093.changed.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat(k8sattributesprocessor): Make k8sattributes processor as default and deprecate k8s_tagger for k8s metadata enrichment

deploy/helm/sumologic/README.md

Lines changed: 7 additions & 2 deletions
Large diffs are not rendered by default.

deploy/helm/sumologic/conf/instrumentation/otelcol.instrumentation.conf.yaml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ processors:
115115
timeout: 10s
116116

117117
## Tags spans with K8S metadata, basing on the context IP
118+
{{ if .Values.otelcolInstrumentation.useSumoK8sProcessor }}
118119
k8s_tagger:
119120
## When true, only IP is assigned and passed (so it could be tagged on another collector)
120121
passthrough: false
@@ -145,6 +146,57 @@ processors:
145146
labels:
146147
- tag_name: "k8s.pod.label.%s"
147148
key: "*"
149+
{{ else }}
150+
k8sattributes:
151+
wait_for_metadata: {{ .Values.otelcolInstrumentation.waitForMetadata }}
152+
wait_for_metadata_timeout: {{ .Values.otelcolInstrumentation.waitForMetadataTimeout | quote }}
153+
auth_type: "serviceAccount"
154+
extract:
155+
labels:
156+
- key_regex: "(.*)"
157+
tag_name: "k8s.pod.label.$$1"
158+
from: pod
159+
- key_regex: "(.*)"
160+
tag_name: "k8s.namespace.label.$$1"
161+
from: namespace
162+
annotations:
163+
- key_regex: "(.*)"
164+
tag_name: "k8s.pod.annotation.$$1"
165+
from: pod
166+
metadata:
167+
## extract the following well-known metadata fields
168+
- k8s.pod.name
169+
- k8s.pod.uid
170+
- k8s.deployment.name
171+
- k8s.daemonset.name
172+
- k8s.replicaset.name
173+
- k8s.statefulset.name
174+
- k8s.namespace.name
175+
- k8s.node.name
176+
- k8s.container.name
177+
- service.name
178+
- service.namespace
179+
## Has to be false to enrich metadata
180+
passthrough: false
181+
pod_association:
182+
## Mirrors the k8s_tagger default association order (pod_association.go)
183+
## https://github.com/SumoLogic/sumologic-otel-collector/blob/main/pkg/processor/k8sprocessor/pod_association.go#L44
184+
## k8sIPLabelName (k8s.pod.ip) → clientIPLabelName (ip) → connection → host.name (if IP)
185+
## We prepend k8s.pod.uid as the most explicit match, then follow k8s_tagger's order.
186+
## k8s.pod.ip and ip survive gateway hops (forwarded as resource attributes);
187+
## connection uses the TCP source IP and only works for direct pod→collector connections.
188+
- sources:
189+
- from: resource_attribute
190+
name: k8s.pod.uid
191+
- sources:
192+
- from: resource_attribute
193+
name: k8s.pod.ip
194+
- sources:
195+
- from: resource_attribute
196+
name: ip
197+
- sources:
198+
- from: connection
199+
{{ end }}
148200

149201
## The memory_limiter processor is used to prevent out of memory situations on the collector.
150202
memory_limiter:
@@ -179,7 +231,7 @@ service:
179231
pipelines:
180232
traces:
181233
receivers: [jaeger, otlp, otlp/deprecated, zipkin]
182-
processors: [memory_limiter, k8s_tagger, source, resource, batch]
234+
processors: [memory_limiter, {{ if .Values.otelcolInstrumentation.useSumoK8sProcessor }}k8s_tagger{{ else }}k8sattributes{{ end }}, source, resource, batch]
183235
exporters:
184236
{{- if eq .Values.tracesGateway.enabled true }}
185237
- otlphttp/traces
@@ -191,7 +243,7 @@ service:
191243
{{- end }}
192244
metrics:
193245
receivers: [otlp, otlp/deprecated]
194-
processors: [memory_limiter, k8s_tagger, source, resource, batch]
246+
processors: [memory_limiter, {{ if .Values.otelcolInstrumentation.useSumoK8sProcessor }}k8s_tagger{{ else }}k8sattributes{{ end }}, source, resource, batch]
195247
exporters:
196248
- sumologic/metrics
197249
{{- if eq .Values.debug.instrumentation.otelcolInstrumentation.print true }}

deploy/helm/sumologic/conf/logs/otelcol/config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,21 @@ processors:
358358
## Has to be false to enrich metadata
359359
passthrough: false
360360
pod_association:
361+
## Mirrors k8s_tagger's `build_hostname` association (pod_association.go):
362+
## build_hostname combined k8s.pod.name + k8s.namespace.name into a single
363+
## compound key "{podName}.{namespace}" for pod cache lookup.
364+
## k8sattributes two-source match achieves the same uniqueness guarantee:
365+
## both sources must match simultaneously, equivalent to the compound key.
366+
## k8s.pod.uid is prepended as a more precise fallback when set (e.g. via
367+
## the filelog receiver which parses the UID from the log file path).
361368
- sources:
362369
- from: resource_attribute
363370
name: k8s.pod.uid
371+
- sources:
372+
- from: resource_attribute
373+
name: k8s.namespace.name
374+
- from: resource_attribute
375+
name: k8s.pod.name
364376
{{ end }}
365377
{{ end }}
366378

deploy/helm/sumologic/conf/metrics/otelcol/processors.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ filter/drop_unnecessary_metrics:
1818
# drop histograms we've extracted sums and counts from, but don't want the full thing
1919
- (not IsMatch(name, {{ .Values.sumologic.metrics.allowHistogramRegex | quote }})) and (type == METRIC_DATA_TYPE_HISTOGRAM or type == METRIC_DATA_TYPE_EXPONENTIAL_HISTOGRAM or type == METRIC_DATA_TYPE_SUMMARY or IsMatch(name, ".*_bucket"))
2020
{{- end }}
21-
21+
# Exclude k8sattributes pod related metrics which could cause unwanted noise
22+
# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/k8sattributesprocessor/documentation.md#internal-telemetry
23+
- IsMatch(name, "^otelcol[._](k8s[._]pod[._]association|otelsvc_k8s_(pod_added|pod_updated|pod_table_size|pod_deleted|ip_lookup_miss))$")
2224
# Prometheus receiver puts all labels in record-level attributes, and we need them in resource
2325
groupbyattrs:
2426
keys:
@@ -59,13 +61,19 @@ k8sattributes:
5961
wait_for_metadata_timeout: {{ .Values.metadata.metrics.waitForMetadataTimeout | quote }}
6062
auth_type: "serviceAccount"
6163
extract:
64+
{{- if or .Values.metadata.metrics.extractPodLabels .Values.metadata.metrics.extractNodeLabels }}
6265
labels:
66+
{{- if .Values.metadata.metrics.extractPodLabels }}
6367
- key_regex: "(.*)"
6468
tag_name: "pod_labels_$$1"
6569
from: pod
66-
- key_regex: "(.*)"
70+
{{- end }}
71+
{{- if .Values.metadata.metrics.extractNodeLabels }}
72+
- key_regex: "(.*)"
6773
tag_name: "node_labels_$$1"
6874
from: node
75+
{{- end }}
76+
{{- end }}
6977
metadata:
7078
## extract the following well-known metadata fields
7179
- k8s.pod.name
@@ -80,6 +88,13 @@ k8sattributes:
8088
## Has to be false to enrich metadata
8189
passthrough: false
8290
pod_association:
91+
## Mirrors k8s_tagger's `build_hostname` association (pod_association.go):
92+
## build_hostname combined k8s.pod.name + k8s.namespace.name into a single
93+
## compound key "{podName}.{namespace}" for pod cache lookup.
94+
## k8sattributes two-source match achieves the same uniqueness guarantee:
95+
## both sources must match simultaneously, equivalent to the compound key.
96+
## Metrics from OtelOperator scraping always carry pod name + namespace
97+
## (set by the prometheus receiver from target labels), so no uid fallback needed.
8398
- sources:
8499
- from: resource_attribute
85100
name: k8s.pod.name

deploy/helm/sumologic/values.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,14 @@ otelcolInstrumentation:
14201420
## Matching pods will be excluded from Sumo. The logs will still be sent to otelcol.
14211421
excludePodRegex: ""
14221422

1423+
## Use the sumologic k8s processor to add metadata to traces.
1424+
## This is disabled by default, but can be enabled if you want to use the sumologic k8s_tagger processor.
1425+
useSumoK8sProcessor: false
1426+
1427+
## Only used if useSumoK8sProcessor is set to false
1428+
waitForMetadata: true
1429+
waitForMetadataTimeout: 10s
1430+
14231431
## Option to turn autoscaling on for otelcol and specify params for HPA.
14241432
## Autoscaling needs metrics-server to access cpu metrics.
14251433
autoscaling:
@@ -1655,13 +1663,27 @@ metadata:
16551663
metricsLevel: normal
16561664

16571665
## Use the sumologic k8s processor to add metadata to the logs.
1658-
## This is enabled by default, but can be disabled if you want to use the upstream processor.
1659-
useSumoK8sProcessor: true
1666+
## This is disabled by default, but can be enabled if you want to use the sumologic k8s_tagger processor.
1667+
useSumoK8sProcessor: false
16601668

16611669
## Only used if useSumoK8sProcessor is set to false
16621670
waitForMetadata: true
16631671
waitForMetadataTimeout: 10s
16641672

1673+
## Extract pod labels as resource attributes
1674+
## Pod labels include: app, version, tier, component, etc.
1675+
## Default: true
1676+
## Only used if useSumoK8sProcessor is set to false
1677+
extractPodLabels: true
1678+
1679+
## Extract node labels as resource attributes
1680+
## WARNING: Node labels significantly increase metric cardinality
1681+
## Cloud providers add 50-100 labels per node (instance-type, zone, etc.)
1682+
## Example impact: 100 nodes × 50 labels = 5,000+ additional label combinations
1683+
## Default: false
1684+
## Only used if useSumoK8sProcessor is set to false
1685+
extractNodeLabels: false
1686+
16651687
config:
16661688
## Directly alter the OT configuration. The value of this key should be a dictionary, that will
16671689
## be directly merged with the generated configuration, overriding existing values.
@@ -1772,9 +1794,9 @@ metadata:
17721794
## Metrics Level (basic, normal, detailed)
17731795
metricsLevel: normal
17741796

1775-
## Use the sumologic k8s processor to add metadata to the logs.
1776-
## This is enabled by default, but can be disabled if you want to use the upstream processor.
1777-
useSumoK8sProcessor: true
1797+
## Use the k8sattributes processor to add metadata to the logs.
1798+
## This is disabled by default, but can be disabled if you want to use the sumologic k8s_tagger processor.
1799+
useSumoK8sProcessor: false
17781800

17791801
## Only used if useSumoK8sProcessor is set to false
17801802
waitForMetadata: true

tests/helm/metrics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestMetadataMetricsOtelConfigExtraProcessors(t *testing.T) {
124124
"metricstransform",
125125
"groupbyattrs",
126126
"resource",
127-
"k8s_tagger",
127+
"k8sattributes",
128128
"source",
129129
"sumologic",
130130
"filter/1",

tests/helm/testdata/goldenfile/metadata_logs_otc/debug.output.yaml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,34 +155,53 @@ data:
155155
- _sourceName
156156
- _sourceHost
157157
- _collector
158-
k8s_tagger:
158+
k8sattributes:
159+
auth_type: serviceAccount
159160
extract:
160161
annotations:
161-
- key: '*'
162-
tag_name: pod_annotations_%s
163-
delimiter: _
162+
- from: pod
163+
key_regex: (.*)
164+
tag_name: pod_annotations_$$1
165+
- from: namespace
166+
key_regex: (.*)
167+
tag_name: namespace_annotations_$$1
168+
- from: node
169+
key_regex: (.*)
170+
tag_name: node_annotations_$$1
164171
labels:
165-
- key: '*'
166-
tag_name: pod_labels_%s
172+
- from: pod
173+
key_regex: (.*)
174+
tag_name: pod_labels_$$1
175+
- from: namespace
176+
key_regex: (.*)
177+
tag_name: namespace_labels_$$1
178+
- from: node
179+
key_regex: (.*)
180+
tag_name: node_labels_$$1
167181
metadata:
168-
- daemonSetName
169-
- deploymentName
170-
- hostName
171-
- namespace
172-
- nodeName
173-
- podName
174-
- serviceName
175-
- statefulSetName
176-
namespace_annotations:
177-
- key: '*'
178-
tag_name: namespace_annotations_%s
179-
namespace_labels:
180-
- key: '*'
181-
tag_name: namespace_labels_%s
182-
owner_lookup_enabled: true
182+
- k8s.pod.name
183+
- k8s.pod.uid
184+
- k8s.pod.hostname
185+
- k8s.deployment.name
186+
- k8s.daemonset.name
187+
- k8s.replicaset.name
188+
- k8s.statefulset.name
189+
- k8s.namespace.name
190+
- k8s.node.name
191+
- service.name
192+
- service.namespace
183193
passthrough: false
184194
pod_association:
185-
- from: build_hostname
195+
- sources:
196+
- from: resource_attribute
197+
name: k8s.pod.uid
198+
- sources:
199+
- from: resource_attribute
200+
name: k8s.namespace.name
201+
- from: resource_attribute
202+
name: k8s.pod.name
203+
wait_for_metadata: true
204+
wait_for_metadata_timeout: 10s
186205
memory_limiter:
187206
check_interval: 5s
188207
limit_percentage: 90
@@ -298,7 +317,7 @@ data:
298317
- memory_limiter
299318
- filter/include_containers
300319
- groupbyattrs/containers
301-
- k8s_tagger
320+
- k8sattributes
302321
- resource/add_cluster
303322
- resource/set_empty_source_metadata
304323
- resource/containers_copy_node_to_host

tests/helm/testdata/goldenfile/metadata_logs_otc/debug_with_sumologic_mock.output.yaml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,34 +164,53 @@ data:
164164
- _sourceName
165165
- _sourceHost
166166
- _collector
167-
k8s_tagger:
167+
k8sattributes:
168+
auth_type: serviceAccount
168169
extract:
169170
annotations:
170-
- key: '*'
171-
tag_name: pod_annotations_%s
172-
delimiter: _
171+
- from: pod
172+
key_regex: (.*)
173+
tag_name: pod_annotations_$$1
174+
- from: namespace
175+
key_regex: (.*)
176+
tag_name: namespace_annotations_$$1
177+
- from: node
178+
key_regex: (.*)
179+
tag_name: node_annotations_$$1
173180
labels:
174-
- key: '*'
175-
tag_name: pod_labels_%s
181+
- from: pod
182+
key_regex: (.*)
183+
tag_name: pod_labels_$$1
184+
- from: namespace
185+
key_regex: (.*)
186+
tag_name: namespace_labels_$$1
187+
- from: node
188+
key_regex: (.*)
189+
tag_name: node_labels_$$1
176190
metadata:
177-
- daemonSetName
178-
- deploymentName
179-
- hostName
180-
- namespace
181-
- nodeName
182-
- podName
183-
- serviceName
184-
- statefulSetName
185-
namespace_annotations:
186-
- key: '*'
187-
tag_name: namespace_annotations_%s
188-
namespace_labels:
189-
- key: '*'
190-
tag_name: namespace_labels_%s
191-
owner_lookup_enabled: true
191+
- k8s.pod.name
192+
- k8s.pod.uid
193+
- k8s.pod.hostname
194+
- k8s.deployment.name
195+
- k8s.daemonset.name
196+
- k8s.replicaset.name
197+
- k8s.statefulset.name
198+
- k8s.namespace.name
199+
- k8s.node.name
200+
- service.name
201+
- service.namespace
192202
passthrough: false
193203
pod_association:
194-
- from: build_hostname
204+
- sources:
205+
- from: resource_attribute
206+
name: k8s.pod.uid
207+
- sources:
208+
- from: resource_attribute
209+
name: k8s.namespace.name
210+
- from: resource_attribute
211+
name: k8s.pod.name
212+
wait_for_metadata: true
213+
wait_for_metadata_timeout: 10s
195214
memory_limiter:
196215
check_interval: 5s
197216
limit_percentage: 90
@@ -308,7 +327,7 @@ data:
308327
- memory_limiter
309328
- filter/include_containers
310329
- groupbyattrs/containers
311-
- k8s_tagger
330+
- k8sattributes
312331
- resource/add_cluster
313332
- resource/set_empty_source_metadata
314333
- resource/containers_copy_node_to_host

0 commit comments

Comments
 (0)