Promtail - Add Namespace Labels

Is there a way in promtail to add the namespace labels ?
We are currently using Fluentd + Graylog, and fluentd does that.


Hey @fredericpege

Namespace labels from Kubernetes, I presume?
If so, you can use the __meta_kubernetes_namespace label with a relabel config.

HI @dannykopping,
and thanks for the quick reply.
The namespace name itself is already added to the log, by default.
What I need are the namespace labels to be added to the log.
For example, if the namespace has label “code_app=X9”, in fluend, the log gets a label : “namespace_label_code_app=x9”.
I know I keep telling “fluentd this, fluentd that”, and it’s a bit annoying. I’m trying to make fluentd work with loki in the meantime.
I also know that I could set the labels to the pod instead of the namespace, but in my organisation, namespace admins aren’t cluster admin. The namespaces have a set of label (for backup, monitoring, security, ticketing, …). We need those as well as the ones set by namespace admin to their pods.

You can open http://your-promtail-ip:port/targets and inspect all of the available labels from Kubernetes SD that are available for relabelling.

To my knowledge, we don’t export the namespace labels in the way you’re expecting - but perhaps one of my more learned colleagues can weigh in.

Thanks, that helped ! That helped to confirm that currently, this is not possible. :smiley: But, at least, I can move on.
I think this would be an interesting feature to add, imo.

In the meantime, I continue to work on a daemonset fluentd with kubernetes and loki plugins. I’ll push my results somewhere when/if I got something working.

Thanks again.

My pleasure!
Please feel free to raise an issue if you’d like to see this feature added. Also, PRs welcome! :grinning:

I will. Depending on the language, I might be able to help a bit.