# Autodiscover and metadata

**URL:** <https://discuss.elastic.co/t/autodiscover-and-metadata/162980>\
**Category:** Beats\
**Tags:** docker, heartbeat\
**Created:** [January 4, 2019, 3:22pm UTC](https://discuss.elastic.co/t/autodiscover-and-metadata/162980 "2019-01-04T15:22:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_cholakian1/32/3612_2.png) [@Andrew\_Cholakian1](https://discuss.elastic.co/u/Andrew_Cholakian1)\
**Post date:** [January 4, 2019, 8:18pm UTC](https://discuss.elastic.co/t/autodiscover-and-metadata/162980/2 "2019-01-04T20:18:45Z")

</div>

That's a great point. Luckily this is possible. I've actually just created a [pull request](https://github.com/elastic/beats/pull/9901) to better document adding those fields. You can interpolate any fields you like with the standard [fields](https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-heartbeat-options.html#monitor-fields) option, which is per-monitor.

For convenience I've included an example below. You may also want to set `fields_under_root: true` in your config if you'd prefer for those fields to be at the root level of your ES documents instead of the `fields` key.

```auto
heartbeat.autodiscover:
  providers:
    - type: docker
      templates:
        - condition:
            contains:
              docker.container.image: redis
          config:
            - type: tcp
              hosts: ["${data.host}:${data.port}"]
              schedule: "@every 1s"
              timeout: 1s
              fields:
                container_id: "${data.docker.container.id}"
                container_image: "${data.docker.container.image}"
                container_name: "${data.docker.container.name}"

```

---

_[View the full topic](https://discuss.elastic.co/t/autodiscover-and-metadata/162980)._
