Metricbeat on Kubernetes does not work with conditions

Hi! I want to set up a metricbeat data collection for some pods in my cluster. I already have a working filebeat configuration where I collect logs from certain pods based on autodiscover template conditions. But the same configuration does not work for metricbeat.

I took the YAML of the metricbeat setup from the official site. The relevant part that I edited is this:

apiVersion: v1
kind: ConfigMap
  name: metricbeat-daemonset-config
  namespace: kube-system
    k8s-app: metricbeat
  metricbeat.yml: |-
        - type: kubernetes
          scope: cluster
          node: ${NODE_NAME}
          unique: true
            - condition:
                  kubernetes.labels.test: foo
                - module: kubernetes
                  hosts: ["kube-state-metrics:8080"]
                  period: 10s
                  add_metadata: true
                    - state_node
                    - state_deployment
                    - state_daemonset
                    - state_replicaset
                    - state_pod
                    - state_container
                    - state_job
                    - state_cronjob
                    - state_resourcequota
                    - state_statefulset
                    - state_service

But with this configuration, no metrics are collected at all. When I remove the - condition node, then metrics are collected but from all the pods in the cluster. When the metrics are collected, I can verify that there are in fact documents from metricbeat from a pod with kubernetes.labels.test: foo. I can filter on those fields and they do exist.

But when I change the config again to include the - condition, then the stream of documents stops, including from the pod with the correct label.

Is this a known issue or is there something wrong with my configuration? Thanks

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