Skip to content

Commit 20b2db2

Browse files
committed
Fixed filtering rule on root 'xpack.monitoring.'
1 parent e8a2d72 commit 20b2db2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

x-pack/lib/monitoring/monitoring.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ def after_agent(runner)
158158
# return true if xpack.monitoring.allow_legacy_collection=true and xpack.monitoring.enabled=true (explicitly) or xpack.monitoring.elasticsearch.hosts is configured
159159
def monitoring_enabled?(settings)
160160
log_warn_if_legacy_is_enabled_and_not_allowed(settings)
161-
# LogStash::SETTINGS.registered?("xpack.monitoring.allow_legacy_collection") &&
162-
# + LogStash::SETTINGS.get_value("xpack.monitoring.allow_legacy_collection")
163-
# return false if LogStash::SETTINGS.registered?("xpack.monitoring.allow_legacy_collection") && !settings.get_value("xpack.monitoring.allow_legacy_collection")
164161
return false unless settings.get_value("xpack.monitoring.allow_legacy_collection")
165162
return settings.get_value("monitoring.enabled") if settings.set?("monitoring.enabled")
166163
return settings.get_value("xpack.monitoring.enabled") if settings.set?("xpack.monitoring.enabled")
@@ -209,7 +206,8 @@ def generate_pipeline_config(settings)
209206
raise ArgumentError.new("\"xpack.monitoring.enabled\" is configured while also \"monitoring.enabled\"")
210207
end
211208

212-
if any_set?(settings, /^xpack.monitoring/) && any_set?(settings, /^monitoring./)
209+
if any_set?(settings, /^xpack.monitoring/, "xpack.monitoring.allow_legacy_collection") &&
210+
any_set?(settings, /^monitoring./)
213211
raise ArgumentError.new("\"xpack.monitoring.*\" settings can't be configured while using \"monitoring.*\"")
214212
end
215213

@@ -239,8 +237,8 @@ def retrieve_collection_settings(settings, prefix = "")
239237
opt
240238
end
241239

242-
def any_set?(settings, regexp)
243-
!settings.get_subset(regexp).to_hash.keys.select { |k| settings.set?(k)}.empty?
240+
def any_set?(settings, regexp, to_avoid = [])
241+
!settings.get_subset(regexp).to_hash.keys.select{ |k| !to_avoid.include?(k)}.select { |k| settings.set?(k)}.empty?
244242
end
245243
end
246244

0 commit comments

Comments
 (0)