Skip to content

Commit e916b80

Browse files
committed
Renamed 'allow.legacy.monitoring' to 'xpack.monitoring.allow_legacy_collection' and moved the registering of such setting from core to xpack
1 parent 3d5ab00 commit e916b80

File tree

15 files changed

+77
-22
lines changed

15 files changed

+77
-22
lines changed

config/logstash.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,12 @@
334334
# Default to direct, optionally can be switched to heap to select Java heap space.
335335
# pipeline.buffer.type: direct
336336
#
337-
#
338-
# Flag to allow the legacy internal monitoring (default: false)
339-
# allow.legacy.monitoring: false
340-
#
341337
# ------------ X-Pack Settings (not applicable for OSS build)--------------
342338
#
343339
# X-Pack Monitoring
344340
# https://www.elastic.co/guide/en/logstash/current/monitoring-logstash.html
341+
# Flag to allow the legacy internal monitoring (default: false)
342+
#xpack.monitoring.allow_legacy_collection: false
345343
#xpack.monitoring.enabled: false
346344
#xpack.monitoring.elasticsearch.username: logstash_system
347345
#xpack.monitoring.elasticsearch.password: password

docker/data/logstash/env2yaml/env2yaml.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package main
1717
import (
1818
"errors"
1919
"fmt"
20-
"gopkg.in/yaml.v2"
2120
"io/ioutil"
2221
"log"
2322
"os"
@@ -86,7 +85,7 @@ var validSettings = []string{
8685
"api.auth.basic.password_policy.include.symbol",
8786
"allow_superuser",
8887
"monitoring.cluster_uuid",
89-
"allow.legacy.monitoring",
88+
"xpack.monitoring.allow_legacy_collection",
9089
"xpack.monitoring.enabled",
9190
"xpack.monitoring.collection.interval",
9291
"xpack.monitoring.elasticsearch.hosts",

logstash-core/lib/logstash/api/commands/default_metadata.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def http_address
7171

7272
private
7373
def enabled_xpack_monitoring?
74-
LogStash::SETTINGS.get_value("allow.legacy.monitoring") &&
74+
LogStash::SETTINGS.registered?("xpack.monitoring.allow_legacy_collection") &&
75+
LogStash::SETTINGS.get_value("xpack.monitoring.allow_legacy_collection") &&
7576
LogStash::SETTINGS.registered?("xpack.monitoring.enabled") &&
7677
LogStash::SETTINGS.get("xpack.monitoring.enabled")
7778
end

logstash-core/lib/logstash/environment.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ module Environment
110110
Setting::String.new("keystore.classname", "org.logstash.secret.store.backend.JavaKeyStore"),
111111
Setting::String.new("keystore.file", ::File.join(::File.join(LogStash::Environment::LOGSTASH_HOME, "config"), "logstash.keystore"), false), # will be populated on
112112
Setting::NullableString.new("monitoring.cluster_uuid"),
113-
Setting::String.new("pipeline.buffer.type", "direct", true, ["direct", "heap"]),
114-
Setting::Boolean.new("allow.legacy.monitoring", false)
113+
Setting::String.new("pipeline.buffer.type", "direct", true, ["direct", "heap"])
115114
# post_process
116115
].each {|setting| SETTINGS.register(setting) }
117116

logstash-core/lib/logstash/settings.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def register(setting)
9191
# return a List, so the following type checking before going deep by one layer.
9292
return setting.map { |s| register(s) } if setting.kind_of?(Array) || setting.kind_of?(java.util.List)
9393

94+
# if setting.name == "xpack.monitoring.allow_legacy_collection"
95+
# puts ">>> call stack Compiler#compile_sources"; caller.each { |frame| puts "#{frame}"}
96+
# end
97+
9498
if @settings.key?(setting.name)
9599
raise ArgumentError.new("Setting \"#{setting.name}\" has already been registered as #{setting.inspect}")
96100
else

logstash-core/spec/logstash/api/commands/default_metadata_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ def registerIfNot(setting)
5555
end
5656

5757
it "check monitoring section exist when legacy monitoring is enabled and allowed" do
58-
LogStash::SETTINGS.set_value("allow.legacy.monitoring", true)
58+
LogStash::SETTINGS.set_value("xpack.monitoring.allow_legacy_collection", true)
5959
LogStash::SETTINGS.set_value("xpack.monitoring.enabled", true)
6060
expect(report.keys).to include(
6161
:monitoring
6262
)
6363
end
6464

6565
it "check monitoring section does not appear when legacy monitoring is not allowed but enabled" do
66-
LogStash::SETTINGS.set_value("allow.legacy.monitoring", false)
66+
LogStash::SETTINGS.set_value("xpack.monitoring.allow_legacy_collection", false)
6767
LogStash::SETTINGS.set_value("xpack.monitoring.enabled", true)
6868
expect(report.keys).not_to include(
6969
:monitoring
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.logstash;
2+
3+
import org.apache.logging.log4j.core.AbstractLifeCycle;
4+
import org.apache.logging.log4j.core.Filter;
5+
import org.apache.logging.log4j.core.Layout;
6+
import org.apache.logging.log4j.core.config.Property;
7+
import org.apache.logging.log4j.core.filter.AbstractFilterable;
8+
9+
import java.io.Serializable;
10+
11+
public class JavaClassWithInitialize
12+
// extends AbstractLifeCycle
13+
extends AbstractFilterable
14+
{
15+
private String name;
16+
17+
// protected JavaClassWithInitialize(String name) {
18+
// this.name = name;
19+
// }
20+
//
21+
// protected JavaClassWithInitialize(String name, String surname) {
22+
// this.name = name + surname;
23+
// }
24+
//
25+
// protected JavaClassWithInitialize(String name, String surname, boolean collapse) {
26+
// this.name = name + surname;
27+
// }
28+
29+
// @Deprecated
30+
protected JavaClassWithInitialize(final String name, final Filter filter, final Layout<? extends Serializable> layout) {
31+
this(name, filter, layout, true, Property.EMPTY_ARRAY);
32+
}
33+
34+
// /** @deprecated */
35+
// @Deprecated
36+
// protected JavaClassWithInitialize(final String name, final Filter filter, final Layout<? extends Serializable> layout, final boolean ignoreExceptions) {
37+
// this(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY);
38+
// }
39+
40+
protected JavaClassWithInitialize(final String name, final Filter filter, final Layout<? extends Serializable> layout, final boolean ignoreExceptions, final Property[] properties) {
41+
this.name = name;
42+
}
43+
44+
@Override
45+
public void initialize() {
46+
this.name = "Name added";
47+
}
48+
}

x-pack/lib/monitoring/monitoring.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ def after_agent(runner)
155155
# For versions prior to 6.3 the default value of "xpack.monitoring.enabled" was true
156156
# For versions 6.3+ the default of "xpack.monitoring.enabled" is false.
157157
# To help keep passivity, assume that if "xpack.monitoring.elasticsearch.hosts" has been set that monitoring should be enabled.
158-
# return true if allow.legacy.monitoring=true and xpack.monitoring.enabled=true (explicitly) or xpack.monitoring.elasticsearch.hosts is configured
158+
# 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-
return false unless settings.get_value("allow.legacy.monitoring")
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")
164+
return false unless settings.get_value("xpack.monitoring.allow_legacy_collection")
162165
return settings.get_value("monitoring.enabled") if settings.set?("monitoring.enabled")
163166
return settings.get_value("xpack.monitoring.enabled") if settings.set?("xpack.monitoring.enabled")
164167

@@ -173,10 +176,10 @@ def monitoring_enabled?(settings)
173176
end
174177

175178
def log_warn_if_legacy_is_enabled_and_not_allowed(settings)
176-
allowed = settings.get_value("allow.legacy.monitoring")
179+
allowed = settings.get_value("xpack.monitoring.allow_legacy_collection")
177180
legacy_monitoring_enabled = (settings.get_value("xpack.monitoring.enabled") || settings.get_value("monitoring.enabled"))
178181
if !allowed && legacy_monitoring_enabled
179-
logger.warn("You have enabled legacy internal monitoring. However, starting from version 9.0, this feature is deactivated and behind a feature flag. Set `allow.legacy.monitoring` to `true` to allow access to the feature.")
182+
logger.warn("You have enabled legacy internal monitoring. However, starting from version 9.0, this feature is deactivated and behind a feature flag. Set `xpack.monitoring.allow_legacy_collection` to `true` to allow access to the feature.")
180183
end
181184
end
182185
private :log_warn_if_legacy_is_enabled_and_not_allowed
@@ -270,6 +273,9 @@ def additionals_settings(settings)
270273

271274
private
272275
def register_monitoring_settings(settings, prefix = "")
276+
if prefix == "xpack."
277+
settings.register(LogStash::Setting::Boolean.new("xpack.monitoring.allow_legacy_collection", false))
278+
end
273279
settings.register(LogStash::Setting::Boolean.new("#{prefix}monitoring.enabled", false))
274280
settings.register(LogStash::Setting::ArrayCoercible.new("#{prefix}monitoring.elasticsearch.hosts", String, ["http://localhost:9200"]))
275281
settings.register(LogStash::Setting::TimeValue.new("#{prefix}monitoring.collection.interval", "10s"))

x-pack/qa/integration/management/multiple_pipelines_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"xpack.management.elasticsearch.hosts" => ["http://localhost:9200"],
3434
"xpack.management.elasticsearch.username" => "elastic",
3535
"xpack.management.elasticsearch.password" => elastic_password,
36-
"allow.legacy.monitoring" => true,
36+
"xpack.monitoring.allow_legacy_collection" => true,
3737
"xpack.monitoring.elasticsearch.username" => "elastic",
3838
"xpack.monitoring.elasticsearch.password" => elastic_password
3939

x-pack/qa/integration/monitoring/direct_shipping_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@logstash_service = logstash_with_empty_default("bin/logstash -e '#{config}' -w 1 --pipeline.id #{SecureRandom.hex(8)}", {
1717
:settings => {
18-
"allow.legacy.monitoring" => true,
18+
"xpack.monitoring.allow_legacy_collection" => true,
1919
"monitoring.enabled" => true,
2020
"monitoring.elasticsearch.hosts" => ["http://localhost:9200", "http://localhost:9200"],
2121
"monitoring.collection.interval" => "1s",

0 commit comments

Comments
 (0)