The docker module is intended to be used in the host, to collect information from the daemon about all the containers and other resources there, it should be configured in your metricbeat container, not in the hints of specific containers.
The docker module always collects metrics from all the containers. There is no way of getting metrics from a single container. Something you can do is to add a processor that drops all events not coming from an specific container.
For example, something like this would discard all events not coming from the loggingapp container:
Hints in labels (like co.elastic.metrics/module) can be used to monitor specific applications, for example if your application were exposing prometheus metrics, you could get them with a configuration like the following one:
I think I understand the hints thing now in terms of why it didn't work correctly when trying to run the Docker module directly on a container, and how the hints are more designed to be used with other modules such as nginx, etc. that takes specific application metrics from a container, which I will be exploring at some point.
Interestingly after your processor example, it reminded me of another solution I tried to carry out that used a condition on the label, but it didn't work:
The problem with this configuration is similar to the previous cases, the docker module collects metrics from all the running containers. If you use this template, it will start a docker module for each container with these labels, leading to duplicated metrics of all running containers. The docker module is intended to be used in the main configuration, not per container in an autodiscover configuration.
You can though take advantage of this label if you want to discard all the metrics from containers that don't contain it, following with my example, with a condition like this one:
That makes sense as you certainly don't want multiple metricbeat containers running for each container, as eventually there will be a lot of containers/microservices running in our system.
I will try this tomorrow to see if it works then we have the 2 options to work with - either collect metrics for every container, or take advantage of the custom label in conjunction with a condition.
I have tried escaping the / in the label and adding enabled: true and removing the quotes from the boolean true in the label with your solution, but this does not work either. Its not picking up any stats and thus not creating an index in elasticsearch.
I've checked the label is present in the logging app also. To note the metricbeat.modules is the only thing I have in the config apart from the elasticsearch output. Does hints still need to be present when working with this solution?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.