# Docker module on metricbeat

**URL:** <https://discuss.elastic.co/t/docker-module-on-metricbeat/127908>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [April 13, 2018, 6:15am UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908 "2018-04-13T06:15:44Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 13, 2018, 6:15am UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/1 "2018-04-13T06:15:45Z")

</div>

The docker module on metric beat shows error when I try to put it in the conf file.  
Please let me know if i m wrong with the configuration for the docker module,

This is the error I m getting when I try to run with the docker module:

> 2018/04/13 05:36:53.954728 beat.go:346: CRIT Exiting: 7 errors: host parsing failed for docker-container: error parsing URL: empty host; host parsing failed for docker-cpu: error parsing URL: empty host; host parsing failed for docker-diskio: error parsing URL: empty host; host parsing failed for docker-healthcheck: error parsing URL: empty host; host parsing failed for docker-info: error parsing URL: empty host; host parsing failed for docker-memory: error parsing URL: empty host; host parsing failed for docker-network: error parsing URL: empty host  
> Exiting: 7 errors: host parsing failed for docker-container: error parsing URL: empty host; host parsing failed for docker-cpu: error parsing URL: empty host; host parsing failed for docker-diskio: error parsing URL: empty host; host parsing failed for docker-healthcheck: error parsing URL: empty host; host parsing failed for docker-info: error parsing URL: empty host; host parsing failed for docker-memory: error parsing URL: empty host; host parsing failed for docker-network: error parsing URL: empty host

This is the module part which I added on the conf file:

```auto
- module: docker
  metricsets: ["container", "cpu", "diskio", "healthcheck", "info", "memory", "network"]
  hosts: ["nceapttls13:///var/run/docker.sock"]
  enabled: true
  period: 10s

  # To connect to Docker over TLS you must specify a client and CA certificate.
  ssl:
    certificate_authority: "/etc/pki/root/ca.pem"
    certificate: "/etc/pki/client/cert.pem"
    key: "/etc/pki/client/cert.key"

```

Please let me know where m I going wrong.

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [April 13, 2018, 3:42pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/2 "2018-04-13T15:42:45Z")

</div>

> [@Gaurav\_Agarwal](#):
>
> hosts: ["nceapttls13:///var/run/docker.sock"]

> [@Gaurav\_Agarwal](#):
>
> error parsing URL: empty host

Try changing the URL to `hosts: ["unix:///var/run/docker.sock"]` (which is the default, IIRC).

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 7:04am UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/3 "2018-04-17T07:04:11Z")

</div>

Still did not work  
Is it that we have to activate the module or something or just by putting the module in the yml file is enough.

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [April 17, 2018, 12:48pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/4 "2018-04-17T12:48:02Z")

</div>

> [@Gaurav\_Agarwal](#):
>
> Still did not work

Was there an error when you ran it? Did config test pass (`metricbeat test config -e -d "*"`)? Did the module test pass (`metricbeat test modules docker -e -d "*"`)?

> [@Gaurav\_Agarwal](#):
>
> Is it that we have to activate the module or something or just by putting the module in the yml file is enough.

There are two ways to specify the modules that will run -- put it in metricbeat.yml or put it into the modules.d directory. See [Configuring Metricbeat » Specify which modules to run](https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-metricbeat.html).

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 1:05pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/5 "2018-04-17T13:05:40Z")

</div>

my metricbeat is running on docker as a container  
also i m using version 5.6.8  
could you give the commands to test whether metric beat is running or not on docker

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 1:07pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/6 "2018-04-17T13:07:08Z")

</div>

**2018/04/17 13:05:45.973230 metrics.go:39: INFO Non-zero metrics in the last 30s: fetches.docker-cpu.events=3 fetches.docker-cpu.failures=3 fetches.docker-diskio.events=3 fetches.docker-diskio.failures=3 fetches.docker-healthcheck.events=3 fetches.docker-healthcheck.failures=3 fetches.docker-info.events=3 fetches.docker-info.failures=3 fetches.docker-memory.events=3 fetches.docker-memory.failures=3 fetches.docker-network.events=3 fetches.docker-network.failures=3** fetches.system-cpu.events=3 fetches.system-cpu.success=3 fetches.system-filesystem.events=105 fetches.system-filesystem.success=3 fetches.system-fsstat.events=3 fetches.system-fsstat.success=3 fetches.system-load.events=3 fetches.system-load.success=3 fetches.system-memory.events=3 fetches.system-memory.success=3 fetches.system-network.events=6 fetches.system-network.success=3 fetches.system-process.events=3 fetches.system-process.success=3 fetches.system-socket.success=60 libbeat.es.call\_count.PublishEvents=3 libbeat.es.publish.read\_bytes=1447 libbeat.es.publish.write\_bytes=69736 libbeat.es.published\_and\_acked\_events=144 libbeat.publisher.messages\_in\_worker\_queues=144 libbeat.publisher.published\_events=144

This is the logs which i get This clearly shows that everything with respect to docker is failing

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [April 17, 2018, 1:24pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/7 "2018-04-17T13:24:06Z")

</div>

You should be able to execute the test command with:

`docker exec -it <metricbeat_container_id_or_name> /usr/share/metricbeat/metricbeat test modules docker -e -d "*"`

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 1:32pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/8 "2018-04-17T13:32:52Z")

</div>

What does the "\*" refer to as in will it be as it is or we need to put the host address in it

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [April 17, 2018, 1:37pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/10 "2018-04-17T13:37:18Z")

</div>

> [@Gaurav\_Agarwal](#):
>
> What does the "\*" refer to

`-d "*"` causes it to log all debug.

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 1:37pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/11 "2018-04-17T13:37:57Z")

</div>

it is not happening for whatever reason I am not able to understand

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 1:42pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/12 "2018-04-17T13:42:46Z")

</div>

Should I post my yml file here  
In which i tried including the docker module

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [April 17, 2018, 1:43pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/13 "2018-04-17T13:43:28Z")

</div>

> [@Gaurav\_Agarwal](#):
>
> when I execute it it dosent show anything

Nothing at all? It should have at least gave some debug output or an error.

As an alternative way to collect information about why it's failing to communicate to Docker, you can enable debug [logging](https://www.elastic.co/guide/en/beats/metricbeat/6.2/configuration-logging.html) in your metricbeat.yml config file.

```auto
logging.level: debug
logging.selectors: ['*']

```

Another thing I noticed is that you are using a unix socket AND you have uncommented the `ssl` options. I think you can leave the ssl options commented out when using a unix socket. Similar to this [example](https://www.elastic.co/guide/en/beats/metricbeat/6.2/metricbeat-module-docker.html#_example_configuration_5).

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 1:53pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/14 "2018-04-17T13:53:50Z")

</div>

nothing it is showing

---

<div class="post-metadata">

**Author:** ![Gaurav\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gaurav\_Agarwal](https://discuss.elastic.co/u/Gaurav_Agarwal)\
**Post date:** [April 17, 2018, 2:01pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/15 "2018-04-17T14:01:12Z")

</div>

> [@andrewkroh](#):
>
> logging.level: debug  
> logging.selectors: ['\*']

Even after applying this it shows nothing boss

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [April 17, 2018, 7:00pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/16 "2018-04-17T19:00:34Z")

</div>

If you are running Metricbeat inside of a container then did you mount /var/lib/docker.sock inside of the container so that Metricbeat can access it?

If so, then does the Metricbeat process have the appropriate permissions to read/write to the socket?

I did a quick test with docker-compose to see if everything was working OK with the docker module. Here's the config I used in case it helps.

```auto
# Dockerfile
FROM docker.elastic.co/beats/metricbeat:6.2.3
COPY metricbeat.yml /usr/share/metricbeat/metricbeat.yml
USER root
RUN chown root /usr/share/metricbeat/metricbeat.yml

```

```auto
# docker-compose.yml
---
version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.3
    environment: ['http.host=0.0.0.0', 'transport.host=127.0.0.1']
    ports: ['127.0.0.1:9200:9200']

  kibana:
    image: docker.elastic.co/kibana/kibana:6.2.3
    container_name: kibana
    ports: ['127.0.0.1:5601:5601']
    depends_on: ['elasticsearch']

  metricbeat:
    build: .
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    command: -e 
    depends_on: ['elasticsearch']
    # So that metricbeat has permission to access the Docker socket.
    user: root

```

```auto
# metricbeat.yml
metricbeat.modules:
- module: docker
  metricsets: ["container", "cpu", "diskio", "healthcheck", "info", "memory", "network"]
  hosts: ["unix:///var/run/docker.sock"]
  period: 10s

output.elasticsearch:
  hosts: ["elasticsearch:9200"]

```

```auto
$ docker-compose run
# Wait for things to start.

# See if events are present.
$ curl http://localhost:9200/_cat/indices/metricbeat*?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open metricbeat-6.2.3-2018.04.17 GGotq8MUT9m88xMMFpX1pg 5 1 398 0 812kb 812kb

# To see some of the raw events.
$ curl http://localhost:9200/metricbeat-*/_search?pretty

```

---

<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 15, 2018, 7:01pm UTC](https://discuss.elastic.co/t/docker-module-on-metricbeat/127908/17 "2018-05-15T19:01:08Z")

</div>

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