Skip to content

[k8sattributesprocessor]: Fall back to only container within a pod if no k8s.container.name/container.id attribute is present in resource #34189

Closed
@bacherfl

Description

@bacherfl

Component(s)

processor/k8sattributes

Is your feature request related to a problem? Please describe.

Currently, the k8sattributes processor requires either the k8s.container.name or container.id attribute to be present in the resource attributes to attach container level attributes, as described in the readme.
This makes sense for pods with multiple containers, as otherwise it would not be possible to correctly associate the resource to the correct container.
For pods containing only one container however, this requirement can likely be dropped, and the container level attributes from the only container can automatically be attached for resources coming from a matching pod. This could potentially make things a bit simpler for users, as the requirement of providing the container name or id as attributes for the resource seemed to have caused some confusion in the past (e.g. #32104 (comment))

Describe the solution you'd like

If a matching pod is found for an incoming resource, and the pod only consists of one container, automatically attach the container level attributes if they are part of the extraction rules, also when the k8s.container.name and container.id are not provided resource attributes.

Describe alternatives you've considered

Attaching the k8s.container.name or container.id attribute to the resource sent to the collector will also ensure the container level attributes are attached correctly, but this is a requirement that may easily be missed by users.

Additional context

If this is something we agree to add, I'm happy to work on the implementation. In the meantime I will work on a PoC to validate the suggested solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestnever staleIssues marked with this label will be never staled and automatically removedprocessor/k8sattributesk8s Attributes processor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions