Skip to content

[k8sattributes] key_regex should work even if tag_name is not present #45719

@ChrsMark

Description

@ChrsMark

ref:

// KeyRegex is a regular expression used to extract a Key that matches the regex.
// Out of Key or KeyRegex, only one option is expected to be configured at a time.
KeyRegex string `mapstructure:"key_regex"`

In the docstring it is mentioned the following:

// When not specified, a default tag name will be used of the format:
//   - k8s.pod.annotations.<annotation key>  (or k8s.pod.annotation.<annotation key> when processor.k8sattributes.EmitV1K8sConventions is enabled)
//   - k8s.pod.labels.<label key>  (or k8s.pod.label.<label key> when processor.k8sattributes.EmitV1K8sConventions is enabled)

This means that the following works as expected:

labels:
  - key: app
    from: pod

and extracts the label as k8s.pod.labels.app: nginx

We should support the same for the key_regex option too:

        labels:
          - key_regex: (.*)
            from: pod

The above does not seem to work as expected: it should catch all labels and extract them using k8s.pod.labels.<label key> pattern)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Workable

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions