Description
Component(s)
receiver/k8sobjects
What happened?
Description
Kubernetes events, collected using the watch
mode:
k8sobjects:
objects:
- name: events
mode: "watch"
group: "events.k8s.io"
exclude_watch_type:
- "DELETED"
are missing the namespace resource.attribute
.
Looking to the code - https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.112.0/receiver/k8sobjectsreceiver/unstructured_to_logdata.go#L58-L60 it seems that it is expected that this attribute is added.
watchObjects
have a different structure comparing to the pullObjects
as a result e.GetNamespace()
call return an empty string.
another option would be to add namespace
to the attributes
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.112.0/receiver/k8sobjectsreceiver/unstructured_to_logdata.go#L36-L40, would it be a preferable way?
Steps to Reproduce
enable k8sobjects:
k8sobjects:
objects:
- name: events
mode: "watch"
group: "events.k8s.io"
exclude_watch_type:
- "DELETED"
Expected Result
I expect to see Resource Attribute k8s.namespace.name
added
Actual Result
ObservedTimestamp: 2024-11-13 15:27:52.068912453 +0000 UTC
Timestamp: 1970-01-01 00:00:00 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Map(...)
Attributes:
-> k8s.resource.name: Str(events)
-> event.domain: Str(k8s)
-> event.name: Str(coredns-7db6d8ff4d-9hzj5.180790b119d77167)
Collector version
0.112.0
Environment information
Environment
OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")
OpenTelemetry Collector configuration
No response
Log output
No response
Additional context
No response