openshift/cluster-logging-operator

Support for namespace label selectors

Opened this issue · 3 comments

Hi,

at the moment, the ClusterLogForwarder API can only handle log selection by static namespaces or pod labels. It would be nice if label selectors can be supported for namespaces as well. This would enable much easier log selection when multiple namespaces do not share a common glob expression.

Does kubernetes support listing pods by namespace labels? I've never tried. If not then it makes it much more difficult to support this request.

Also, are you expressing this limitation with the latest release which includes the ability to provide namespace and container globs?

Hi,

I do not think it is supported. But is listing pods by namespace label really necessary as it would just avoid one additional filtering step?

I assume from the question, the current code just lets vector find the correct targets without much pre-processing?

I am aware of the latest version and the globbing feature. While this is useful for some situations, label selection is more flexible and seems in-line with the already implemented API.

In my use case, I have a lot of namespaces I would want to select for log-forwarding, regardless of the applications in them. As they do not have a common naming scheme, globbing is not really helping me here. But I have easier access to the namespace labels (and their modification to fit the use-case).

I assume from the question, the current code just lets vector find the correct targets without much pre-processing?

Currently vector essentially is capable of doing the equivalent of oc get -l which becomes the list of pods from which it reads logs. We couple this with a file glob to further filter out by namespace based on what is spec'd; those files simply are not read. This is the most efficient.

Looking at the available config, it may be possible to accomplish this using this setting. This will require investigation.

Consider trying it yourself by:

  • setting the ClusterLogging.spec.managementState to "Unmanaged'
  • Extracting the config secret
  • Adding the field to the toml
  • Updating the secret
  • restarting the pods with 'oc delete -lcomponent=collector'