How does the autodiscover feature in *Beat work?


(Jeppler) #1

How does the autodiscover feature in *Beat (MetricBeat, FileBeat etc.) work from a technical perspective?

I am especially interested in how it works on Kubernetes?

As far as I understood it the *Beat, for example MetricBeat will watch pod events and reacts if they meed a predefined condition, such as a specific annotation is present. It will then use the module configuration. The example configuration for MetricBeat in the documentation is:

metricbeat.autodiscover:
  providers:
    - type: kubernetes
      include_annotations: ["prometheus.io.scrape"]
      templates:
        - condition:
            contains:
              kubernetes.annotations.prometheus.io.scrape: "true"
          config:
            - module: prometheus
              metricsets: ["collector"]
              hosts: "${data.host}:{data.port}"

However, what I do not understand is how does the technology to collect the metrics actually work? Is the *Beat accessing the pod and injecting the *Beat executable into the running target container? Or does the autodiscover feature use an exposed HTTP API to collect the metrics and basically just connects to the container via HTTP protocol? Or does it use a completely different approach?