logging-operator icon indicating copy to clipboard operation
logging-operator copied to clipboard

Ability to select namespaces by labels

Open velothump opened this issue 5 years ago • 8 comments

Is your feature request related to a problem? Please describe. We'd like to be able to define a ClusterFlow that defines an entire subset of namespaces which are labeled. This would allow teams to have a single ClusterFlow instead of potential hundreds of Flows.

velothump avatar Jun 05 '20 21:06 velothump

As of 3.0 you should already be able to do this! Let us know if it doesn't work for you for some reason. See the clusterflow example here: https://banzaicloud.com/docs/one-eye/logging-operator/log-routing/#match-statement

pepov avatar Jun 07 '20 14:06 pepov

Hi @pepov, looks like you can list namespaces and and label selectors for pods. Not use label selectors for namespaces, or is that incorrect?

velothump avatar Jun 07 '20 19:06 velothump

yes, I misinterpreted the issue statement, sorry

pepov avatar Jun 07 '20 20:06 pepov

The problem with this approach that there are no namespace labels metadata in the log lines. So in the current architecture, it would be really hard to maintain information about the namespaces and making routing decisions based on namespace metadata. I understand the requirement and it is something I would be glad to see in the future but It would be extremely expensive to implement. In the meantime, you can use all namespaces and have dedicated labels for such purposes. (I know this is a best-effort workaround but I have no other better solution yet)

tarokkk avatar Jun 09 '20 15:06 tarokkk

Thank you, we're looking at mutating them into the pod labels for now.

velothump avatar Jul 01 '20 15:07 velothump

Bumping-up.

I'm also looking for this feature

sureshgoli25 avatar Feb 17 '23 10:02 sureshgoli25

The correct solution is to mutate the namespace labels to the pod labels. This is because it would require extra RBAC priveleges to query that information and I can't think of a proper way to do it correctly. By that I mean how do you figure out what were the labels on a namespace based on a kubernetes log line that was written in the past?

Let me know if someone has a good idea for a correct implementation.

pepov avatar Apr 16 '23 07:04 pepov

This is now possible using https://kube-logging.dev/docs/whats-new/#kubernetes-namespace-labels-and-annotations although it requires a few updates in the label router plugin

pepov avatar Mar 28 '24 08:03 pepov

I see that a pre-release of 4.7 has now appeared - but doesn't include any fixes for this issue. Is the plan still to get this into 4.7 when it releases properly?

jeremych1000 avatar May 31 '24 11:05 jeremych1000

Unfortunately it didn't made it to this release

pepov avatar Jun 06 '24 14:06 pepov

FYI I've started to implement and test this:

  • https://github.com/kube-logging/fluent-plugin-label-router/pull/21
  • https://github.com/kube-logging/logging-operator/pull/1757

pepov avatar Jun 07 '24 14:06 pepov

the new label router will be available with fluentd image v1.16-4.8 and the whole thing will be part of the 4.8 release scheduled Juli 2nd, but I'm also going to tag a dev image from master soon.

pepov avatar Jun 14 '24 11:06 pepov