Is there a way to store Kubernetes labels within a JSON message using Promtail

Hi, I’m trying to find a way to store all of the labels on my k8s pods in their logs, without adding loads of labels.

I can add everything as labels using:

- action: labelmap
  regex: __meta_kubernetes_pod_label_(.+)

However, I want to avoid introducing loads of labels that I don’t necessarily need. The pack transform stage looks like it would help; however, it does not accept regex.

If I could do something like the following it would be perfect:

pipeline_stages:
  pack:
    labels:
      - __meta_kubernetes_pod_label_(.+)

Is there any way to do something similar today using promtail?

1 Like

I just found a similar issue from last October, has this been resolved since?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.