Docker discovery hosts not resolving

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?

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

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.

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

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