# Heartbeat using Docker hints

**URL:** <https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [April 13, 2020, 11:43am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768 "2020-04-13T11:43:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nedim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nedim/32/66219_2.png) [@nedim](https://discuss.elastic.co/u/nedim)\
**Post date:** [April 13, 2020, 11:43am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/1 "2020-04-13T11:43:31Z")

</div>

I am trying to setup heartbeat using hints/labels and I am getting the following error

````auto
```
2020-04-11T06:02:38.483Z	WARN	[hints.builder]	hints/monitors.go:195	unable to frame a host from input host: %shost.my.domain.io

ERROR	[autodiscover]	autodiscover/autodiscover.go:204	Auto discover config check failed for config '{
"name": "Prom",
"schedule": "@every 10s",
"type": "http"
}', won't start runner: job err hosts is a mandatory parameter accessing config

````

my docker-compose

```auto
    labels:
      #
      # heartbeat
      #
      co.elastic.monitor/1.name: "Prom"
      co.elastic.monitor/1.type: http
      co.elastic.monitor/1.hosts: ${PROM_HOST}
      co.elastic.monitor/1.schedule: '@every 10s'

```

Heartbeat version 7.6.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:** [April 14, 2020, 1:50am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/2 "2020-04-14T01:50:15Z")

</div>

Have you verified that `${PROM_HOST}` is being set? Also, which version of Heartbeat are you using? Prior to 7.5.0 you would need to set `urls`, not `hosts` for HTTP monitors.

---

<div class="post-metadata">

**Author:** ![nedim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nedim/32/66219_2.png) [@nedim](https://discuss.elastic.co/u/nedim)\
**Post date:** [April 14, 2020, 2:05am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/3 "2020-04-14T02:05:41Z")

</div>

> [@nedim](#):
>
> unable to frame a host from input host: %[shost.my.domain.io](http://shost.my.domain.io)

@Andrew_Cholakian1 Thanks for your reply. I am using version 7.6.2 of Heartbeat. If you see the logs I quoted in this message you can see that the host is not empty. The logs are from the Docker container. In this example it is `host.my.domain.io` and if I change the `${PROM_HOST}` value the change reflects in the Docker logs. Please help. 🙂

---

<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:** [April 16, 2020, 5:26pm UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/4 "2020-04-16T17:26:14Z")

</div>

Thanks for the update. I'm taking a look at this, the root is the code [here](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/3). I'm thinking that the issue is that we check that `${data.port}` is included in the `hosts` field. I'm not sure why we decided to put that in there. If nothing else, we need a better error message.

You could replace `${PROM_HOST}` with `${PROM_HOST}:${data.port}` to work around this and ship a fix. Is there a reason you can't use `${data.host}:${data.port}` by the way?

---

<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:** [April 16, 2020, 8:22pm UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/5 "2020-04-16T20:22:58Z")

</div>

I've opened [https://github.com/elastic/beats/issues/17771](https://github.com/elastic/beats/issues/17771) to investigate / track this. @nedim thanks so much for posting here, let's see what we can do to improve this experience.

---

<div class="post-metadata">

**Author:** ![nedim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nedim/32/66219_2.png) [@nedim](https://discuss.elastic.co/u/nedim)\
**Post date:** [April 16, 2020, 11:21pm UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/6 "2020-04-16T23:21:12Z")

</div>

> [@Andrew\_Cholakian1](#):
>
> Is there a reason you can't use `${data.host}:${data.port}` by the way?

@Andrew_Cholakian1 I do not understand the concept of variables `${data.host}:${data.port}` as they are empty in my case whenever I use them. What am I missing?

I subscribed to the github issue. Thanks.

---

<div class="post-metadata">

**Author:** ![nedim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nedim/32/66219_2.png) [@nedim](https://discuss.elastic.co/u/nedim)\
**Post date:** [April 17, 2020, 2:58am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/7 "2020-04-17T02:58:56Z")

</div>

@Andrew_Cholakian1 if I use data.host in docker-compose.yml like this:

```auto
      co.elastic.monitor/1.name: "Prom"
      co.elastic.monitor/1.type: http
      co.elastic.monitor/1.hosts: "${data.host}:${data.port}"
      co.elastic.monitor/1.schedule: '@every 10s'

```

I get this error

```auto
Invalid interpolation format for "labels" option in service "proxy": "${data.host}:${data.port}"
Invalid interpolation format for "labels" option in service "proxy": "${data.host}:${data.port}"
Invalid interpolation format for "labels" option in service "proxy": "${data.host}:${data.port}"

```

Testing:

```auto
docker-compose -f docker-compose.yml config
ERROR: Invalid interpolation format for "labels" option in service "proxy": "${data.host}:${data.port}"

```

Per this link [https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-autodiscover-hints.html](https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-autodiscover-hints.html)

example is

```auto
LABEL co.elastic.monitor/1.type=tcp co.elastic.monitor/1.hosts='${data.host}:6379' co.elastic.monitor/1.schedule='@every 10s'
LABEL co.elastic.monitor/2.type=icmp co.elastic.monitor/2.hosts='${data.host}' co.elastic.monitor/2.schedule='@every 10s'

```

so my example should work.

Or maybe the example from the documentation is for Dockerfile only and I am using docker-compose which creates the problem?

---

<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:** [April 22, 2020, 1:21am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/8 "2020-04-22T01:21:44Z")

</div>

> [@nedim](#):
>
> Invalid interpolation format for "labels" option in service "proxy": "${data.host}:${data.port}"

That error comes from python, and looks to be coming from docker compose. It seems some escaping may be missing. A google search turned up [Invalid interpolation format for "command" option in service "node-exporter": "^/(sys|proc|dev|host|etc)($|/)" · Issue #4485 · docker/compose · GitHub](https://github.com/docker/compose/issues/4485). I think the solution is to use ` co.elastic.monitor/1.hosts: "$${data.host}:$${data.port}"` in your docker compose file. The `$$` is needed in `compose.yml` AFAICT, but I'm not a docker expert.

---

<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 20, 2020, 1:21am UTC](https://discuss.elastic.co/t/heartbeat-using-docker-hints/227768/9 "2020-05-20T01:21:44Z")

</div>

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