You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @tetianakravchenko, I just looked at this and could reproduce this behaviour as well. From my understanding of the readme, the watch and pull mode should only differ in how the related k8s objects are received, but not in the data structure of the log entries that are exported. Therefore i think it would make sense to ensure that the unstructured objects generated from the watch.Event passed to the unstructuredLogData() function has the same structure as the ones from the pulled objects.
As you correctly pointed out, the structure differs between those two cases, since the objects created from the watch.Events consist of an additional top layer which includes the event type (e.g. ADDED, DELETED, etc.), whereas the pulled objects directly contain the object, see the following examples:
Thus, the GetNamespace() returns an empty value for the first object, as this function internally checks for metadata.namespace, whereas for the object derived from the watch event is located in object.metadata.namespace.
Component(s)
receiver/k8sobjects
What happened?
Description
Kubernetes events, collected using the
watch
mode: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 thepullObjects
as a resulte.GetNamespace()
call return an empty string.another option would be to add
namespace
to theattributes
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:
Expected Result
I expect to see Resource Attribute
k8s.namespace.name
addedActual Result
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
The text was updated successfully, but these errors were encountered: