From c0e0abafe05981f845da3dac07a6a0bb33512bf4 Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 14 Nov 2024 10:12:58 +0100 Subject: [PATCH] Fixed filtering rule on root 'xpack.monitoring.' --- x-pack/lib/monitoring/monitoring.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/x-pack/lib/monitoring/monitoring.rb b/x-pack/lib/monitoring/monitoring.rb index 5e0d913ff98..bdc6d51f11d 100644 --- a/x-pack/lib/monitoring/monitoring.rb +++ b/x-pack/lib/monitoring/monitoring.rb @@ -158,9 +158,6 @@ def after_agent(runner) # return true if xpack.monitoring.allow_legacy_collection=true and xpack.monitoring.enabled=true (explicitly) or xpack.monitoring.elasticsearch.hosts is configured def monitoring_enabled?(settings) log_warn_if_legacy_is_enabled_and_not_allowed(settings) - # LogStash::SETTINGS.registered?("xpack.monitoring.allow_legacy_collection") && - # + LogStash::SETTINGS.get_value("xpack.monitoring.allow_legacy_collection") - # return false if LogStash::SETTINGS.registered?("xpack.monitoring.allow_legacy_collection") && !settings.get_value("xpack.monitoring.allow_legacy_collection") return false unless settings.get_value("xpack.monitoring.allow_legacy_collection") return settings.get_value("monitoring.enabled") if settings.set?("monitoring.enabled") return settings.get_value("xpack.monitoring.enabled") if settings.set?("xpack.monitoring.enabled") @@ -209,7 +206,8 @@ def generate_pipeline_config(settings) raise ArgumentError.new("\"xpack.monitoring.enabled\" is configured while also \"monitoring.enabled\"") end - if any_set?(settings, /^xpack.monitoring/) && any_set?(settings, /^monitoring./) + if any_set?(settings, /^xpack.monitoring/, "xpack.monitoring.allow_legacy_collection") && + any_set?(settings, /^monitoring./) raise ArgumentError.new("\"xpack.monitoring.*\" settings can't be configured while using \"monitoring.*\"") end @@ -239,8 +237,8 @@ def retrieve_collection_settings(settings, prefix = "") opt end - def any_set?(settings, regexp) - !settings.get_subset(regexp).to_hash.keys.select { |k| settings.set?(k)}.empty? + def any_set?(settings, regexp, to_avoid = []) + !settings.get_subset(regexp).to_hash.keys.select{ |k| !to_avoid.include?(k)}.select { |k| settings.set?(k)}.empty? end end