From 9288260a76596292731fe1c7a4c4c96736d4cc48 Mon Sep 17 00:00:00 2001 From: chrismark Date: Thu, 10 Feb 2022 15:41:22 +0000 Subject: [PATCH 1/2] Add docs about hints and templates autodiscovery priority Signed-off-by: chrismark --- filebeat/docs/autodiscover-hints.asciidoc | 27 +++++++++++++++++++++ heartbeat/docs/autodiscover-hints.asciidoc | 23 ++++++++++++++++++ metricbeat/docs/autodiscover-hints.asciidoc | 22 +++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/filebeat/docs/autodiscover-hints.asciidoc b/filebeat/docs/autodiscover-hints.asciidoc index 78e958106939..ffe3098f90b9 100644 --- a/filebeat/docs/autodiscover-hints.asciidoc +++ b/filebeat/docs/autodiscover-hints.asciidoc @@ -100,6 +100,33 @@ Define an ingest pipeline ID to be added to the {beatname_uc} input/module confi co.elastic.logs/pipeline: custom-pipeline ----- +When hints are used along with templates, then hints will be evaluated only in case +there is no template's condition that resolve to true. For example: + +[source,yaml] +----- +filebeat.autodiscover.providers: + - type: docker + hints.enabled: true + hints.default_config: + type: container + paths: + - /var/lib/docker/containers/${data.container.id}/*.log + templates: + - condition: + equals: + docker.container.labels.type: "pipeline" + config: + - type: container + paths: + - "/var/lib/docker/containers/${data.docker.container.id}/*.log" + pipeline: my-pipeline +----- + +In this example first the condition `docker.container.labels.type: "pipeline"` is evaluated +and if not matched the hints will be processed and if there is again no valid config +the `hints.default_config` will be used. + [float] ==== Kubernetes diff --git a/heartbeat/docs/autodiscover-hints.asciidoc b/heartbeat/docs/autodiscover-hints.asciidoc index 431812a13a69..bcfd1e274b11 100644 --- a/heartbeat/docs/autodiscover-hints.asciidoc +++ b/heartbeat/docs/autodiscover-hints.asciidoc @@ -48,6 +48,29 @@ co.elastic.monitor/processors.drop_fields.fields: "field3" In the above sample the processor definition tagged with `1` would be executed first. +When hints are used along with templates, then hints will be evaluated only in case +there is no template's condition that resolve to true. For example: + +[source,yaml] +----- +heartbeat.autodiscover: + - type: docker + hints.enabled: true + templates: + - condition: + contains: + docker.container.image: redis + config: + - type: tcp + hosts: ["${data.host}:${data.port}"] + schedule: "@every 1s" + timeout: 1s +----- + +In this example first the condition `docker.container.image: redis` is evaluated +and if not matched the hints will be processed and if there is again no valid config +the `hints.default_config` will be used. + [float] ==== Kubernetes diff --git a/metricbeat/docs/autodiscover-hints.asciidoc b/metricbeat/docs/autodiscover-hints.asciidoc index 240296751cbc..fe4a5df2d194 100644 --- a/metricbeat/docs/autodiscover-hints.asciidoc +++ b/metricbeat/docs/autodiscover-hints.asciidoc @@ -96,6 +96,28 @@ co.elastic.logs/processors.add_locale.abbrevation: "PST" In the above sample the processor definition tagged with `1` would be executed first. +When hints are used along with templates, then hints will be evaluated only in case +there is no template's condition that resolve to true. For example: + +[source,yaml] +----- +metricbeat.autodiscover.providers: + - type: kubernetes + hints.enabled: true + templates: + - condition: + contains: + kubernetes.annotations.prometheus.io/scrape: "true" + config: + - module: prometheus + metricsets: ["collector"] + hosts: "${data.host}:${data.port}" +----- + +In this example first the condition `kubernetes.annotations.prometheus.io/scrape: "true"` +is evaluated and if not matched the hints will be processed. + + [float] === Kubernetes From 2b3b6634a5d070f8f10a0ccc8509e743ef584140 Mon Sep 17 00:00:00 2001 From: chrismark Date: Wed, 16 Feb 2022 13:18:41 +0200 Subject: [PATCH 2/2] Fixes Signed-off-by: chrismark --- filebeat/docs/autodiscover-hints.asciidoc | 2 +- heartbeat/docs/autodiscover-hints.asciidoc | 2 +- metricbeat/docs/autodiscover-hints.asciidoc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/filebeat/docs/autodiscover-hints.asciidoc b/filebeat/docs/autodiscover-hints.asciidoc index ffe3098f90b9..3488cca2ba24 100644 --- a/filebeat/docs/autodiscover-hints.asciidoc +++ b/filebeat/docs/autodiscover-hints.asciidoc @@ -101,7 +101,7 @@ co.elastic.logs/pipeline: custom-pipeline ----- When hints are used along with templates, then hints will be evaluated only in case -there is no template's condition that resolve to true. For example: +there is no template's condition that resolves to true. For example: [source,yaml] ----- diff --git a/heartbeat/docs/autodiscover-hints.asciidoc b/heartbeat/docs/autodiscover-hints.asciidoc index bcfd1e274b11..e544c39e92b4 100644 --- a/heartbeat/docs/autodiscover-hints.asciidoc +++ b/heartbeat/docs/autodiscover-hints.asciidoc @@ -49,7 +49,7 @@ co.elastic.monitor/processors.drop_fields.fields: "field3" In the above sample the processor definition tagged with `1` would be executed first. When hints are used along with templates, then hints will be evaluated only in case -there is no template's condition that resolve to true. For example: +there is no template's condition that resolves to true. For example: [source,yaml] ----- diff --git a/metricbeat/docs/autodiscover-hints.asciidoc b/metricbeat/docs/autodiscover-hints.asciidoc index fe4a5df2d194..0250c2174a0a 100644 --- a/metricbeat/docs/autodiscover-hints.asciidoc +++ b/metricbeat/docs/autodiscover-hints.asciidoc @@ -97,7 +97,7 @@ co.elastic.logs/processors.add_locale.abbrevation: "PST" In the above sample the processor definition tagged with `1` would be executed first. When hints are used along with templates, then hints will be evaluated only in case -there is no template's condition that resolve to true. For example: +there is no template's condition that resolves to true. For example: [source,yaml] -----