# Adding metadata with autodiscover is not working

**URL:** <https://discuss.elastic.co/t/adding-metadata-with-autodiscover-is-not-working/227942>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [April 14, 2020, 2:52pm UTC](https://discuss.elastic.co/t/adding-metadata-with-autodiscover-is-not-working/227942 "2020-04-14T14:52:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_Albo\_Soria](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_albo_soria/32/46467_2.png) [@Mario\_Albo\_Soria](https://discuss.elastic.co/u/Mario_Albo_Soria)\
**Post date:** [April 14, 2020, 2:52pm UTC](https://discuss.elastic.co/t/adding-metadata-with-autodiscover-is-not-working/227942/1 "2020-04-14T14:52:08Z")

</div>

Hi everybody,  
I'm trying to add docker and host metadata with autodiscover because I need `docker.container.name` and `host.ip` fields to correctly index my logs.  
I'm using autodiscover option because I only need to harvest **kubelet** logs.

Component versions:  
Filebeat 7.6.2  
Logstash 7.1

I have tried this two configurations but it don't seems to append any new field:  
**First config:**

```auto
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config
  labels:
    k8s-app: filebeat
data:
  filebeat.yml: |-
    filebeat.config: 
      spool_size: 512                 
    filebeat.autodiscover:
      providers:
        - type: docker
          processors:
            - add_docker_metadata: ~
            - add_host_metadata:
                netinfo.enabled: true
                cache.ttl: 5m
          templates:
            - condition:
                contains:
                  docker.container.name: kubelet
              config:
                - type: container
                  paths:
                    - /var/lib/docker/containers/${data.docker.container.id}/*.log
                  exclude_lines: ["^\\s+[\\-`('.|_]"]
    output.file:
      path: "/tmp/filebeat"
      filename: filebeat

```

**Second config, very similar to the first one:**

```auto
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config
  labels:
    k8s-app: filebeat
data:
  filebeat.yml: |-
    filebeat.config: 
      spool_size: 512                 
    filebeat.autodiscover:
      providers:
        - type: docker
          templates:
            - condition:
                contains:
                  docker.container.name: kubelet
              config:
                - type: container
                  paths:
                    - /var/lib/docker/containers/${data.docker.container.id}/*.log
                  exclude_lines: ["^\\s+[\\-`('.|_]"]
                  processors:
                    - add_docker_metadata: ~
                    - add_host_metadata: ~
    output.file:
      path: "/tmp/filebeat"
      filename: filebeat

```

There is something that I'm missing or missunderstanding?

**Thanks for your help!**

---

<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 12, 2020, 2:52pm UTC](https://discuss.elastic.co/t/adding-metadata-with-autodiscover-is-not-working/227942/2 "2020-05-12T14:52:12Z")

</div>

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