How can I use keystore variables in autodiscover.providers.templates.config section of metricbeat.yml? It looks like broken.
Steps to Reproduce
- Setup Docker for running next services
- Setup Elasticsearch and configure Metricbeat to connect to it
- Run a RabbitMQ service with an username and a password for authorization
- Add QUEUE_USERNAME and QUEUE_PASSWORD to Metricbeat keystore via
metricbeat keystore add with appropriate values
- Add a block like this to metricbeat.yml:
autodiscover:
providers:
- type: docker
templates:
- condition:
# You can use any other way to match the service here
equals:
docker.container.labels.com.docker.swarm.service.name: my_rabbitmq_service
config:
- module: rabbitmq
period: 10s
hosts: ['${data.host}:${data.port}']
username: ${QUEUE_USERNAME}
password: ${QUEUE_PASSWORD}
- Start the beat
Expected:
Metricbeat successfully connected to RabbitMQ service.
But it doesn't.
Interesting additional info:
-
For debugging purposes, you can use "${QUEUE_PASSWORD}" as a value for field output.elasticsearch.hosts of metricbeat.yml and you will see the finish value of QUEUE_PASSWORD variable from the keystore in logs of the beat (in error messages about the connection to Elasticsearch). Therefore the keystore really store the correct value.
-
If you replace ${QUEUE_USERNAME} and ${QUEUE_PASSWORD} by hard-coded values in metricbeat.yml and restart the beat it will work. Therefore Metricbeat can connect to RabbitMQ with required auth and username/password fields of the metricbeat.yml really works.
-
Even if you return the vars back to metricbeat.yml and add 2 Linux env vars QUEUE_USERNAME and QUEUE_PASSWORD and restart the beat it will work too. Therefore environ variables substitution work in the autodiscover.providers.templates.config section. But keystore variables substitution doesn't work.
How can I use keystore variables in
autodiscover.providers.templates.configsection of metricbeat.yml? It looks like broken.Steps to Reproduce
metricbeat keystore addwith appropriate valuesExpected:
Metricbeat successfully connected to RabbitMQ service.
But it doesn't.
Interesting additional info:
For debugging purposes, you can use "
${QUEUE_PASSWORD}" as a value for fieldoutput.elasticsearch.hostsof metricbeat.yml and you will see the finish value ofQUEUE_PASSWORDvariable from the keystore in logs of the beat (in error messages about the connection to Elasticsearch). Therefore the keystore really store the correct value.If you replace
${QUEUE_USERNAME}and${QUEUE_PASSWORD}by hard-coded values in metricbeat.yml and restart the beat it will work. Therefore Metricbeat can connect to RabbitMQ with required auth andusername/passwordfields of the metricbeat.yml really works.Even if you return the vars back to metricbeat.yml and add 2 Linux env vars
QUEUE_USERNAMEandQUEUE_PASSWORDand restart the beat it will work too. Therefore environ variables substitution work in theautodiscover.providers.templates.configsection. But keystore variables substitution doesn't work.