Heartbeat autodiscover not working: protocol not available

I was trying Heartbeat autodiscover on my Windows. Here is my heartbeast.yml:

heartbeat.autodiscover:
  providers:
    - type: docker
      templates:
        - condition:
            contains:
              docker.container.image: api
          config:
            - type: tcp
              hosts: ["tcp://localhost:2375"]
              schedule: "@every 10s"

Here is the output of .\heartbeat.exe -v -e:

2021-02-01T13:05:56.097+0800    INFO    instance/beat.go:456    heartbeat stopped.
2021-02-01T13:05:56.099+0800    ERROR   instance/beat.go:951    Exiting: error in autodiscover provider settings: error setting up docker autodiscover provider: protocol not available
Exiting: error in autodiscover provider settings: error setting up docker autodiscover provider: protocol not available

Version:

heartbeat version 7.9.2 (amd64), libbeat 7.9.2 [2ab907f5ccecf9fd82fe37105082e89fd871f684 built 2020-09-22 22:24:50 +0000 UTC]

@jsoriano thoughts on this error? I think this would be up your alley.

I think that docker autodiscover tries to connect by default to unix:///var/run/docker.sock. Unix sockets are only supported in recent versions of Windows, what is problably causing this protocol not available error.

In Windows, the npipe should be used instead, something like this:

heartbeat.autodiscover:
  providers:
    - type: docker
      host: 'npipe://./pipe/docker_engine'
      ...

Of if the docker daemon is listening in localhost:2375:

heartbeat.autodiscover:
  providers:
    - type: docker
      host: 'tcp://localhost:2375'
      ...
1 Like

I did make the autodiscover works by the below config (notice the 4 slashes):

heartbeat.autodiscover:
  providers:
    - type: docker
      host: 'npipe:////./pipe/docker_engine'

However the data doesn't seems quite right, see below:

Any idea why the name isn't the container name, and why are they reporting [i/o timeout]?

I found a solution.
For the name, you have to set the name and id under config.
For the timeout problem, I use localhost instead of data.host.
Here is the setting that I use:

heartbeat.autodiscover:
  providers:
    - type: docker
      host: 'npipe:////./pipe/docker_engine'
      templates:
        - config:
            - type: tcp
              id: "${data.docker.container.id}"
              name: "${data.docker.container.name}"
              hosts: [ "localhost:${data.port}" ]
              schedule: "@every 10s"
              timeout: 1s