From a1e47566a6600118e93a50f3ed6d205706610721 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 18 Feb 2023 11:16:20 -0500 Subject: [PATCH 1/6] Enable setting condition on Prometheus Collector --- packages/prometheus/changelog.yml | 6 +++++- .../data_stream/collector/agent/stream/stream.yml.hbs | 4 +--- packages/prometheus/manifest.yml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/prometheus/changelog.yml b/packages/prometheus/changelog.yml index f0307232092..40858bec976 100644 --- a/packages/prometheus/changelog.yml +++ b/packages/prometheus/changelog.yml @@ -1,4 +1,8 @@ -# newer versions go on top +- version: "1.2.0" + changes: + - description: Enable setting condition on Prometheus Collector + type: enhancement + link: https://github.com/elastic/integrations/pull/5317 - version: "1.1.0" changes: - description: Remove "integration" from the package name diff --git a/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs b/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs index 29ba98997b6..5af839e8a23 100644 --- a/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs +++ b/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs @@ -26,9 +26,7 @@ ssl.certificate_authorities: use_types: {{use_types}} username: {{username}} password: {{password}} -{{#if leaderelection}} -condition: ${kubernetes_leaderelection.leader} == true -{{/if}} +condition: {{ condition }} {{#if query}} {{query}} {{/if}} diff --git a/packages/prometheus/manifest.yml b/packages/prometheus/manifest.yml index 672012454de..549be6d272f 100644 --- a/packages/prometheus/manifest.yml +++ b/packages/prometheus/manifest.yml @@ -1,7 +1,7 @@ format_version: 1.0.0 name: prometheus title: Prometheus -version: 1.1.0 +version: 1.2.0 license: basic description: Collect metrics from Prometheus servers with Elastic Agent. type: integration From 2869fa6d40244158c7fd7d77ec1944a2acc434a8 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 18 Feb 2023 11:33:05 -0500 Subject: [PATCH 2/6] Fixed missed update of manifest --- packages/prometheus/data_stream/collector/manifest.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/prometheus/data_stream/collector/manifest.yml b/packages/prometheus/data_stream/collector/manifest.yml index d7644d88c2a..fae82f75c34 100644 --- a/packages/prometheus/data_stream/collector/manifest.yml +++ b/packages/prometheus/data_stream/collector/manifest.yml @@ -39,14 +39,13 @@ streams: required: true show_user: true default: true - - name: leaderelection - type: bool - title: Leader Election - description: Enable leaderelection between a set of Elastic Agents running on Kubernetes + - name: condition + title: Condition + description: Condition to filter when to apply this datastream + type: text multi: false required: true show_user: true - default: false - name: bearer_token_file type: text title: 'HTTP config options: bearer_token_file' From a6c21722202ec0e92b4a336df6792ecc9acc5ffa Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 18 Feb 2023 13:14:20 -0500 Subject: [PATCH 3/6] exclude condition if null --- .../data_stream/collector/agent/stream/stream.yml.hbs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs b/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs index 5af839e8a23..6ead756a576 100644 --- a/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs +++ b/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs @@ -26,7 +26,9 @@ ssl.certificate_authorities: use_types: {{use_types}} username: {{username}} password: {{password}} +{{#if condition }} condition: {{ condition }} +{{/if}} {{#if query}} {{query}} {{/if}} From a0a671171eb09911510f2befcc4ddfdfa673ef97 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 18 Feb 2023 13:33:48 -0500 Subject: [PATCH 4/6] Re-add lost change to condition required --- packages/prometheus/data_stream/collector/manifest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prometheus/data_stream/collector/manifest.yml b/packages/prometheus/data_stream/collector/manifest.yml index fae82f75c34..c9a85cf33f6 100644 --- a/packages/prometheus/data_stream/collector/manifest.yml +++ b/packages/prometheus/data_stream/collector/manifest.yml @@ -44,7 +44,7 @@ streams: description: Condition to filter when to apply this datastream type: text multi: false - required: true + required: false show_user: true - name: bearer_token_file type: text From f6e4ed02482b3916b686fe65850bf85d38b90627 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 20 Feb 2023 19:04:18 -0500 Subject: [PATCH 5/6] Re-add leaderelection with condition --- .../data_stream/collector/agent/stream/stream.yml.hbs | 8 ++++++++ packages/prometheus/data_stream/collector/manifest.yml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs b/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs index 6ead756a576..78160445d27 100644 --- a/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs +++ b/packages/prometheus/data_stream/collector/agent/stream/stream.yml.hbs @@ -26,9 +26,17 @@ ssl.certificate_authorities: use_types: {{use_types}} username: {{username}} password: {{password}} +{{#if leaderelection }} +{{#if condition }} +condition: ${kubernetes_leaderelection.leader} == true and {{ condition }} +{{ else }} +condition: ${kubernetes_leaderelection.leader} == true +{{/if}} +{{ else }} {{#if condition }} condition: {{ condition }} {{/if}} +{{/if}} {{#if query}} {{query}} {{/if}} diff --git a/packages/prometheus/data_stream/collector/manifest.yml b/packages/prometheus/data_stream/collector/manifest.yml index c9a85cf33f6..c73d93ed240 100644 --- a/packages/prometheus/data_stream/collector/manifest.yml +++ b/packages/prometheus/data_stream/collector/manifest.yml @@ -39,6 +39,14 @@ streams: required: true show_user: true default: true + - name: leaderelection + type: bool + title: Leader Election + description: Enable leaderelection between a set of Elastic Agents running on Kubernetes + multi: false + required: false + show_user: true + default: false - name: condition title: Condition description: Condition to filter when to apply this datastream From 93ff8fb7d9003f4dcedde9397925b1f1baa8a499 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 Feb 2023 06:39:21 -0500 Subject: [PATCH 6/6] Fix leaderelection required --- packages/prometheus/data_stream/collector/manifest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prometheus/data_stream/collector/manifest.yml b/packages/prometheus/data_stream/collector/manifest.yml index c73d93ed240..0b02e0882f5 100644 --- a/packages/prometheus/data_stream/collector/manifest.yml +++ b/packages/prometheus/data_stream/collector/manifest.yml @@ -44,7 +44,7 @@ streams: title: Leader Election description: Enable leaderelection between a set of Elastic Agents running on Kubernetes multi: false - required: false + required: true show_user: true default: false - name: condition