# Docker discovery hosts not resolving

**URL:** <https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [September 4, 2018, 1:23am UTC](https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125 "2018-09-04T01:23:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![memelet](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@memelet](https://discuss.elastic.co/u/memelet)\
**Post date:** [September 4, 2018, 1:23am UTC](https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125/1 "2018-09-04T01:23:32Z")

</div>

I have the label on containers

`co.elastic.metrics/hosts: '${data.host}:5001'`

And hints enabled in metricbeat.yml

```
  metricbeat_autodiscover:
    providers:
      - type: docker
        hints.enabled: true
        templates:
        - condition:
            contains:
              docker.container.labels.app-kind: mono-server
          config:
            - module: jolokia
              metricsets: [jmx]
              namespace: monoserver
              period: 20s

```

When the autodiscover condition fires I get this error

`2018-09-04T01:16:38.091Z DEBUG [autodiscover] autodiscover/autodiscover.go:140 Failed to create runner with config &{{<nil> } <nil> 0xc4203579e0}: 1 error: 1 error: host parsing failed for jolokia-jmx: error parsing URL: empty host`

But if I explicitly set hosts in the config the value in metricbeat.yml it is resolved

```
  metricbeat_autodiscover:
    providers:
      - type: docker
        hints.enabled: true
        templates:
        - condition:
            contains:
              docker.container.labels.app-kind: mono-server
          config:
            - module: jolokia
              metricsets: [jmx]
              hosts: '${data.host}:5001'
              namespace: monoserver
              period: 20s

```

Am I missing a step?

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [September 4, 2018, 10:19am UTC](https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125/2 "2018-09-04T10:19:42Z")

</div>

Hi @memelet,

Templates override whatever you get by hints, so if you define a template hints will be ignored. You can go with your second example (removing the hint) or do:

`co.elastic.metrics/hosts: '${data.host}:5001'`  
`co.elastic.metrics/module: jolokia`  
`co.elastic.metrics/metricsets: jmx`

Best regards

---

<div class="post-metadata">

**Author:** ![memelet](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@memelet](https://discuss.elastic.co/u/memelet)\
**Post date:** [September 4, 2018, 2:31pm UTC](https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125/3 "2018-09-04T14:31:47Z")

</div>

So I need to specify **all** of the below in the hint?

`co.elastic.metrics/hosts: '${data.host}:5001'`  
`co.elastic.metrics/module: jolokia`  
`co.elastic.metrics/metricsets: jmx`

Because I had the first line in the hint and second two in the template and that did not work.

My objective is to keep (at least) the port in the hint since that is part of the deployment configuration.

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [September 5, 2018, 11:00pm UTC](https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125/4 "2018-09-05T23:00:59Z")

</div>

You cannot combine hints and templates, if a template match the hints will be ignored. This is a safety mechanism to always allow the operator to override some behaviors.

In this specific case, I think you could avoid passing the `metricsets` one, as Metricbeat will use the default metricset if none is provided

---

<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:** [October 3, 2018, 11:01pm UTC](https://discuss.elastic.co/t/docker-discovery-hosts-not-resolving/147125/5 "2018-10-03T23:01:19Z")

</div>

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