vectordotdev / vector

A high-performance observability data pipeline.
https://vector.dev
Mozilla Public License 2.0
17.45k stars 1.52k forks source link

extra_namespace_label_selector not work when write two namespaces #20903

Closed therus000 closed 1 month ago

therus000 commented 1 month ago

A note for the community

Problem

I tried to use this config for selecting only logs from namespace's that i need it works when i write one label namespace when i select multi. It not work, no error's but not sending logs i tried like this

"extra_namespace_label_selector: "kubernetes.io/metadata.name=opensearch-operator,kubernetes.io/metadata.name=kyverno"

and like this

extra_namespace_label_selector: kubernetes.io/metadata.name=opensearch-operator,kubernetes.io/metadata.name=kyverno

and like this

extra_namespace_label_selector: kubernetes.io/metadata.name=opensearch-operator, kubernetes.io/metadata.name=kyverno

nothing works not logs

Configuration

sources:
      kubernetes_logs:
        type: kubernetes_logs
        extra_namespace_label_selector: "kubernetes.io/metadata.name=opensearch-operator,kubernetes.io/metadata.name=kyverno"
        # extra_label_selector: "app.kubernetes.io/name=vector"
        pod_annotation_fields:
          pod_namespace: "kubernetes.namespace_name"
          pod_labels:    "kubernetes.labels"
          pod_node_name: "kubernetes.host"
        max_line_bytes: 1048576

Version

0.39.0-debian

Debug Output

No response

Example Data

No response

Additional Context

No response

References

No response

jszwedko commented 1 month ago

Hi @therus000 ,

As https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors mentions, the label selectors are joined with &&. That is, each selector has to be true. In your case I think you want to select namespaces where any one of them are true. In that case, consider using the "set based" syntax mentioned here: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#set-based-requirement

I'll close this out since I think it was just a misunderstanding of how selectors work, but feel free to open a GitHub Discussion (or Discord post) if you still have trouble accomplishing what you want.