How to Run Metricbeat in Docker with Modules to Monitor Other Containers

Hi!

Something like this below should work:

metricbeat.autodiscover:
  providers:
    - type: docker
      labels.dedot: true
      templates:
        - condition:
            contains:
              docker.container.name: elasticsearch # make sure that you use the correct name of the container
          config:
            - module: elasticsearch
              metricsets: ["node", "node_stats"]
              hosts: "${data.host}:${data.port}"

While trying this, you can run Filebeat in debug mode (filebeat -e -d "*") and check what is logged regarding autodiscovery so as to have a clearer view of what is working and what not.