# Metricbeat not collecting kubernetes.namespace field

**URL:** <https://discuss.elastic.co/t/metricbeat-not-collecting-kubernetes-namespace-field/303231>\
**Category:** Metrics\
**Created:** [April 26, 2022, 8:13am UTC](https://discuss.elastic.co/t/metricbeat-not-collecting-kubernetes-namespace-field/303231 "2022-04-26T08:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marone/32/87145_2.png) [@marone](https://discuss.elastic.co/u/marone)\
**Post date:** [April 26, 2022, 8:13am UTC](https://discuss.elastic.co/t/metricbeat-not-collecting-kubernetes-namespace-field/303231/1 "2022-04-26T08:13:16Z")

</div>

Hello, I'm using Elastic 7.15 for observability, I'm trying to collect metrics from each namespace but the field `kubernetes.namespace` is not collected. I added the processor `add_kubernetes_metadata` but still not collecting the namespace field. But it is collecting `kubernetes.pod.name` and other fields but missing some.

I am using docker desktop 4.6.1 (76265).

Here is my conf:

```auto
apiVersion: v1
kind: ConfigMap
metadata:
  name: metricbeat-daemonset-config
  namespace: elk
  labels:
    k8s-app: metricbeat
data:
  metricbeat.yml: |-
    metricbeat.config.modules:
      # Mounted `metricbeat-daemonset-modules` configmap:
      path: ${path.config}/modules.d/*.yml
      # Reload module configs as they change:
      reload.enabled: false

    metricbeat.autodiscover:
      providers:
        - type: kubernetes
          scope: cluster
          node: ${NODE_NAME}
          unique: true
          templates:
            - config:
                - module: kubernetes
                  hosts: ["kube-state-metrics:8080"]
                  period: 10s
                  add_metadata: true
                  metricsets:
                    - state_node
                    - state_deployment
                    - state_daemonset
                    - state_replicaset
                    - state_pod
                    - state_container
                    - state_job
                    - state_cronjob
                    - state_resourcequota
                    - state_statefulset
                    - state_service
                - module: kubernetes
                  metricsets:
                    - apiserver
                  hosts: ["https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"]
                  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
                  ssl.certificate_authorities:
                    - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
                  period: 30s
                # Uncomment this to get k8s events:
                #- module: kubernetes
                # metricsets:
                # - event
        # To enable hints based autodiscover uncomment this:
        #- type: kubernetes
        # node: ${NODE_NAME}
        # hints.enabled: true

    processors:
      - add_cloud_metadata:
      - add_kubernetes_metadata:
          host: ${NODE_NAME}
      - add_docker_metadata:

    cloud.id: ${ELASTIC_CLOUD_ID}
    cloud.auth: ${ELASTIC_CLOUD_AUTH}

    output.elasticsearch:
      hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
      username: ${ELASTICSEARCH_USERNAME}
      password: ${ELASTICSEARCH_PASSWORD}
      ssl.verification_mode: none

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 24, 2022, 8:14am UTC](https://discuss.elastic.co/t/metricbeat-not-collecting-kubernetes-namespace-field/303231/2 "2022-05-24T08:14:02Z")

</div>

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