Hints based autodiscover
editHints based autodiscover
editMetricbeat supports autodiscover based on hints from the provider. The hints
system looks for
hints in Kubernetes Pod annotations or Docker labels which have the prefix co.elastic.metrics
. As soon as
the container starts, Metricbeat will check if it contains any hints and launch the proper config for
it. Hints tell Metricbeat how to get metrics for the given container. This is the full list of supported hints:
co.elastic.metrics/module
editMetricbeat module to use to fetch metrics. See Modules for the list of supported modules.
co.elastic.metrics/hosts
editHosts setting to use with the given module. Hosts can include ${data.host}
and ${data.port}
values from the autodiscover event, ie: ${data.host}:80
.
co.elastic.metrics/metricsets
editList of metricsets to use, comma separated. If no metricsets are provided, default metricsets for the module are used.
co.elastic.metrics/period
editThe time interval for metrics retrieval, ie: 10s
co.elastic.metrics/timeout
editMetrics retrieval timeout, default: 3s
co.elastic.metrics/ssl.*
editSSL parameters, as seen in Specify SSL settings.
Kubernetes
editKubernetes autodiscover provider supports hints in Pod annotations. To enable it just set hints.enabled
:
metricbeat.autodiscover: providers: - type: kubernetes hints.enabled: true
This configuration enables the hints
autodiscover for Kubernetes. The hints
system looks for
hints in Kubernetes annotations or Docker labels which have the prefix co.elastic.metrics
.
You can annotate Kubernetes Pods with useful info to spin up Metricbeat modules:
annotations: co.elastic.metrics/module: prometheus co.elastic.metrics/metricsets: collector co.elastic.metrics/hosts: '${data.host}:9090' co.elastic.metrics/period: 1m
The above annotations are used to spin up a Prometheus collector metricset and it polls the
parent container on port 9090
at a 1 minute interval.
Multiple containers
editWhen a Pod has multiple containers, these settings are shared. To set hints specific to a container in the pod you can put the container name in the hint.
When a pod has multiple containers, the settings are shared unless you put the container name in the
hint. For example, these hints configure a common behavior for all containers in the Pod, and sets a specific
hosts
hint for the container called sidecar
.
annotations: co.elastic.metrics/module: apache co.elastic.metrics/hosts: '${data.host}:80' co.elastic.metrics.sidecar/hosts: '${data.host}:8080'
Docker
editDocker autodiscover provider supports hints in labels. To enable it just set hints.enabled
:
metricbeat.autodiscover: providers: - type: docker hints.enabled: true
You can label Docker containers with useful info to spin up Metricbeat modules, for example:
co.elastic.metrics/module: nginx co.elastic.metrics/metricsets: stubstatus co.elastic.metrics/hosts: '${data.host}:80' co.elastic.metrics/period: 10s
The above labels would allow Metricbeat to configure a Prometheus collector to poll port 9090
of the Docker container every 1 minute.