# Metricbeat Docker Module seems to break when used whithin Autodiscover context

**URL:** <https://discuss.elastic.co/t/metricbeat-docker-module-seems-to-break-when-used-whithin-autodiscover-context/192144>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [July 24, 2019, 9:46pm UTC](https://discuss.elastic.co/t/metricbeat-docker-module-seems-to-break-when-used-whithin-autodiscover-context/192144 "2019-07-24T21:46:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmdm](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@rmdm](https://discuss.elastic.co/u/rmdm)\
**Post date:** [July 24, 2019, 9:46pm UTC](https://discuss.elastic.co/t/metricbeat-docker-module-seems-to-break-when-used-whithin-autodiscover-context/192144/1 "2019-07-24T21:46:00Z")

</div>

I'm trying to restrict the set of the containers to collect metrics from, by using autodiscover, exactly like this:

```auto
metricbeat.autodiscover:
  providers:
    - type: docker
      templates:
        - condition:
            equals:
              docker.container.labels.com.docker.stack.namespace: 'logging'
          config:
            - module: docker
              hosts: ["unix:///var/run/docker.sock"]
              period: 10s

output.elasticsearch:
  hosts:
    - "http://elasticsearch-monitoring-1:9200"
    - "http://elasticsearch-monitoring-2:9200"
    - "http://elasticsearch-monitoring-3:9200"

```

The condition seems to work, and in the Discover tab I see only events with the specified label.

However, all the events has the same `container.id` per `host.name` where the beat is running and the number of the events is significantly lagrer than when using docker module without autodiscovery (~200/minute without autodiscovery vs ~8000/minute with it).

Some more details.  
The events seem to be grouped by the timestamp, `host.name` and `event.dataset` fields, and the size of such a group equals to the total number of containers on the specific docker host, even if they do not match the label condition. The events in such a group are not exactly the same, for example, the `event.duration` field looks unique for all events.  
The metricbeat itself is running inside a container with the docker.sock mounted.  
The entire Elastic Stack is of 7.2.0 version.

So, for me it looks like a bug, but maybe docker module is not supposed to be used within the autodiscover context at all? What do you think?

---

<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:** [August 21, 2019, 9:46pm UTC](https://discuss.elastic.co/t/metricbeat-docker-module-seems-to-break-when-used-whithin-autodiscover-context/192144/2 "2019-08-21T21:46:02Z")

</div>

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