logstash-core 5.0.0.alpha2.snapshot2-java → 5.0.0.alpha3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash/agent.rb +48 -31
- data/lib/logstash/api/{lib/helpers/app_helpers.rb → app_helpers.rb} +0 -0
- data/lib/logstash/api/command_factory.rb +34 -0
- data/lib/logstash/api/commands/base.rb +25 -0
- data/lib/logstash/api/commands/stats.rb +105 -0
- data/lib/logstash/api/commands/system/basicinfo_command.rb +23 -0
- data/lib/logstash/api/commands/system/plugins_command.rb +35 -0
- data/lib/logstash/api/modules/base.rb +43 -0
- data/lib/logstash/api/modules/node.rb +24 -0
- data/lib/logstash/api/modules/node_stats.rb +59 -0
- data/lib/logstash/api/modules/plugins.rb +15 -0
- data/lib/logstash/api/modules/root.rb +15 -0
- data/lib/logstash/api/modules/stats.rb +63 -0
- data/lib/logstash/api/rack_app.rb +33 -0
- data/lib/logstash/api/service.rb +73 -0
- data/lib/logstash/config/config_ast.rb +23 -18
- data/lib/logstash/config/loader.rb +4 -4
- data/lib/logstash/config/mixin.rb +10 -21
- data/lib/logstash/environment.rb +29 -0
- data/lib/logstash/filters/base.rb +2 -2
- data/lib/logstash/inputs/base.rb +2 -2
- data/lib/logstash/instrument/collector.rb +1 -1
- data/lib/logstash/instrument/metric_store.rb +11 -1
- data/lib/logstash/instrument/periodic_poller/base.rb +2 -0
- data/lib/logstash/instrument/periodic_poller/jvm.rb +47 -2
- data/lib/logstash/logging/json.rb +21 -0
- data/lib/logstash/output_delegator.rb +2 -2
- data/lib/logstash/patches/clamp.rb +69 -0
- data/lib/logstash/pipeline.rb +36 -69
- data/lib/logstash/plugin.rb +1 -1
- data/lib/logstash/runner.rb +171 -146
- data/lib/logstash/settings.rb +267 -0
- data/lib/logstash/util/decorators.rb +6 -6
- data/lib/logstash/util/java_version.rb +1 -10
- data/lib/logstash/util/thread_dump.rb +55 -0
- data/lib/logstash/util/worker_threads_default_printer.rb +2 -2
- data/lib/logstash/version.rb +1 -1
- data/lib/logstash/webserver.rb +15 -49
- data/locales/en.yml +22 -25
- data/logstash-core.gemspec +3 -3
- data/spec/api/lib/api/node_spec.rb +2 -2
- data/spec/api/lib/api/node_stats_spec.rb +32 -57
- data/spec/api/lib/api/plugins_spec.rb +3 -3
- data/spec/api/lib/api/root_spec.rb +2 -2
- data/spec/api/lib/api/support/resource_dsl_methods.rb +47 -0
- data/spec/api/lib/commands/stats.rb +47 -0
- data/spec/api/spec_helper.rb +21 -21
- data/spec/conditionals_spec.rb +113 -113
- data/spec/logstash/agent_spec.rb +85 -68
- data/spec/logstash/config/config_ast_spec.rb +4 -2
- data/spec/logstash/config/mixin_spec.rb +33 -7
- data/spec/logstash/filters/base_spec.rb +16 -16
- data/spec/logstash/inputs/base_spec.rb +8 -8
- data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +45 -0
- data/spec/logstash/output_delegator_spec.rb +2 -0
- data/spec/logstash/pipeline_reporter_spec.rb +5 -1
- data/spec/logstash/pipeline_spec.rb +75 -30
- data/spec/logstash/plugin_spec.rb +2 -2
- data/spec/logstash/runner_spec.rb +112 -25
- data/spec/logstash/setting_spec.rb +130 -0
- data/spec/logstash/settings_spec.rb +62 -0
- metadata +37 -43
- data/lib/logstash/api/init.ru +0 -31
- data/lib/logstash/api/lib/app.rb +0 -40
- data/lib/logstash/api/lib/app/command.rb +0 -29
- data/lib/logstash/api/lib/app/command_factory.rb +0 -29
- data/lib/logstash/api/lib/app/commands/stats/events_command.rb +0 -13
- data/lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb +0 -120
- data/lib/logstash/api/lib/app/commands/stats/memory_command.rb +0 -25
- data/lib/logstash/api/lib/app/commands/system/basicinfo_command.rb +0 -15
- data/lib/logstash/api/lib/app/commands/system/plugins_command.rb +0 -28
- data/lib/logstash/api/lib/app/modules/node.rb +0 -25
- data/lib/logstash/api/lib/app/modules/node_stats.rb +0 -51
- data/lib/logstash/api/lib/app/modules/plugins.rb +0 -15
- data/lib/logstash/api/lib/app/modules/stats.rb +0 -21
- data/lib/logstash/api/lib/app/root.rb +0 -13
- data/lib/logstash/api/lib/app/service.rb +0 -61
- data/lib/logstash/api/lib/app/stats.rb +0 -56
- data/lib/logstash/util/defaults_printer.rb +0 -31
- data/spec/api/lib/api/stats_spec.rb +0 -19
- data/spec/api/lib/commands/events_spec.rb +0 -17
- data/spec/api/lib/commands/jvm_spec.rb +0 -45
- data/spec/logstash/util/defaults_printer_spec.rb +0 -50
- data/spec/logstash/util/worker_threads_default_printer_spec.rb +0 -45
data/lib/logstash/plugin.rb
CHANGED
data/lib/logstash/runner.rb
CHANGED
@@ -3,7 +3,8 @@ Thread.abort_on_exception = true
|
|
3
3
|
Encoding.default_external = Encoding::UTF_8
|
4
4
|
$DEBUGLIST = (ENV["DEBUG"] || "").split(",")
|
5
5
|
|
6
|
-
require "clamp"
|
6
|
+
require "clamp"
|
7
|
+
require "cabin"
|
7
8
|
require "net/http"
|
8
9
|
require "logstash/environment"
|
9
10
|
|
@@ -12,123 +13,141 @@ LogStash::Environment.load_locale!
|
|
12
13
|
require "logstash/namespace"
|
13
14
|
require "logstash/agent"
|
14
15
|
require "logstash/config/defaults"
|
16
|
+
require "logstash/shutdown_watcher"
|
17
|
+
require "logstash/patches/clamp"
|
18
|
+
require "logstash/settings"
|
19
|
+
|
20
|
+
class LogStash::Runner < Clamp::StrictCommand
|
21
|
+
# The `path.settings` need to be defined in the runner instead of the `logstash-core/lib/logstash/environment.r`
|
22
|
+
# because the `Environment::LOGSTASH_HOME` doesn't exist in the context of the `logstash-core` gem.
|
23
|
+
#
|
24
|
+
# See issues https://github.com/elastic/logstash/issues/5361
|
25
|
+
LogStash::SETTINGS.register(LogStash::Setting::String.new("path.settings", ::File.join(LogStash::Environment::LOGSTASH_HOME, "config")))
|
26
|
+
|
27
|
+
# Node Settings
|
28
|
+
option ["-n", "--node.name"], "NAME",
|
29
|
+
I18n.t("logstash.runner.flag.node_name"),
|
30
|
+
:attribute_name => "node.name",
|
31
|
+
:default => LogStash::SETTINGS.get_default("node.name")
|
15
32
|
|
16
|
-
|
17
|
-
|
18
|
-
option ["-f", "--config"], "CONFIG_PATH",
|
33
|
+
# Config Settings
|
34
|
+
option ["-f", "--path.config"], "CONFIG_PATH",
|
19
35
|
I18n.t("logstash.runner.flag.config"),
|
20
|
-
:attribute_name =>
|
36
|
+
:attribute_name => "path.config"
|
21
37
|
|
22
|
-
option "-e", "CONFIG_STRING",
|
38
|
+
option ["-e", "--config.string"], "CONFIG_STRING",
|
23
39
|
I18n.t("logstash.runner.flag.config-string",
|
24
|
-
|
25
|
-
|
26
|
-
:default =>
|
40
|
+
:default_input => LogStash::Config::Defaults.input,
|
41
|
+
:default_output => LogStash::Config::Defaults.output),
|
42
|
+
:default => LogStash::SETTINGS.get_default("config.string"),
|
43
|
+
:attribute_name => "config.string"
|
27
44
|
|
28
|
-
|
45
|
+
# Pipeline settings
|
46
|
+
option ["-w", "--pipeline.workers"], "COUNT",
|
29
47
|
I18n.t("logstash.runner.flag.pipeline-workers"),
|
30
|
-
:attribute_name =>
|
31
|
-
:default => LogStash::
|
48
|
+
:attribute_name => "pipeline.workers",
|
49
|
+
:default => LogStash::SETTINGS.get_default("pipeline.workers"), &:to_i
|
32
50
|
|
33
|
-
option ["-b", "--pipeline
|
34
|
-
|
35
|
-
|
36
|
-
|
51
|
+
option ["-b", "--pipeline.batch.size"], "SIZE",
|
52
|
+
I18n.t("logstash.runner.flag.pipeline-batch-size"),
|
53
|
+
:attribute_name => "pipeline.batch.size",
|
54
|
+
:default => LogStash::SETTINGS.get_default("pipeline.batch.size"), &:to_i
|
37
55
|
|
38
|
-
option ["-u", "--pipeline
|
39
|
-
|
40
|
-
|
41
|
-
|
56
|
+
option ["-u", "--pipeline.batch.delay"], "DELAY_IN_MS",
|
57
|
+
I18n.t("logstash.runner.flag.pipeline-batch-delay"),
|
58
|
+
:attribute_name => "pipeline.batch.delay",
|
59
|
+
:default => LogStash::SETTINGS.get_default("pipeline.batch.delay"), &:to_i
|
60
|
+
|
61
|
+
option ["--pipeline.unsafe_shutdown"], :flag,
|
62
|
+
I18n.t("logstash.runner.flag.unsafe_shutdown"),
|
63
|
+
:attribute_name => "pipeline.unsafe_shutdown",
|
64
|
+
:default => LogStash::SETTINGS.get_default("pipeline.unsafe_shutdown")
|
42
65
|
|
43
|
-
|
66
|
+
# Plugins Settings
|
67
|
+
option ["-p", "--path.plugins"] , "PATH",
|
68
|
+
I18n.t("logstash.runner.flag.pluginpath"),
|
69
|
+
:multivalued => true, :attribute_name => "path.plugins",
|
70
|
+
:default => LogStash::SETTINGS.get_default("path.plugins")
|
71
|
+
|
72
|
+
# Logging Settings
|
73
|
+
option ["-l", "--path.log"], "FILE",
|
44
74
|
I18n.t("logstash.runner.flag.log"),
|
45
|
-
:attribute_name =>
|
75
|
+
:attribute_name => "path.log"
|
46
76
|
|
47
|
-
|
48
|
-
|
49
|
-
I18n.t("logstash.runner.flag.verbosity"),
|
50
|
-
:attribute_name => :verbosity, :multivalued => true
|
77
|
+
option "--log.level", "LEVEL", I18n.t("logstash.runner.flag.log_level"),
|
78
|
+
:default => LogStash::SETTINGS.get_default("log.level")
|
51
79
|
|
52
|
-
option "--
|
53
|
-
|
54
|
-
|
80
|
+
option "--config.debug", :flag,
|
81
|
+
I18n.t("logstash.runner.flag.config_debug"),
|
82
|
+
:default => LogStash::SETTINGS.get_default("config.debug"),
|
83
|
+
:attribute_name => "config.debug"
|
55
84
|
|
56
|
-
|
57
|
-
|
58
|
-
|
85
|
+
# Other settings
|
86
|
+
option ["-i", "--interactive"], "SHELL",
|
87
|
+
I18n.t("logstash.runner.flag.rubyshell"),
|
88
|
+
:attribute_name => "interactive"
|
59
89
|
|
60
90
|
option ["-V", "--version"], :flag,
|
61
91
|
I18n.t("logstash.runner.flag.version")
|
62
92
|
|
63
|
-
option ["-
|
64
|
-
I18n.t("logstash.runner.flag.pluginpath"),
|
65
|
-
:multivalued => true,
|
66
|
-
:attribute_name => :plugin_paths
|
67
|
-
|
68
|
-
option ["-t", "--configtest"], :flag,
|
93
|
+
option ["-t", "--config.test_and_exit"], :flag,
|
69
94
|
I18n.t("logstash.runner.flag.configtest"),
|
70
|
-
:attribute_name =>
|
95
|
+
:attribute_name => "config.test_and_exit",
|
96
|
+
:default => LogStash::SETTINGS.get_default("config.test_and_exit")
|
71
97
|
|
72
|
-
option "
|
73
|
-
I18n.t("logstash.runner.flag.unsafe_shutdown"),
|
74
|
-
:attribute_name => :unsafe_shutdown,
|
75
|
-
:default => false
|
76
|
-
|
77
|
-
option ["-i", "--interactive"], "SHELL",
|
78
|
-
I18n.t("logstash.runner.flag.rubyshell"),
|
79
|
-
:attribute_name => :ruby_shell
|
80
|
-
|
81
|
-
option ["-n", "--node-name"], "NAME",
|
82
|
-
I18n.t("logstash.runner.flag.node_name"),
|
83
|
-
:attribute_name => :node_name
|
84
|
-
|
85
|
-
option ["-r", "--[no-]auto-reload"], :flag,
|
98
|
+
option ["-r", "--config.reload.automatic"], :flag,
|
86
99
|
I18n.t("logstash.runner.flag.auto_reload"),
|
87
|
-
:attribute_name =>
|
100
|
+
:attribute_name => "config.reload.automatic",
|
101
|
+
:default => LogStash::SETTINGS.get_default("config.reload.automatic")
|
88
102
|
|
89
|
-
option ["--reload
|
103
|
+
option ["--config.reload.interval"], "RELOAD_INTERVAL",
|
90
104
|
I18n.t("logstash.runner.flag.reload_interval"),
|
91
|
-
:attribute_name =>
|
105
|
+
:attribute_name => "config.reload.interval",
|
106
|
+
:default => LogStash::SETTINGS.get_default("config.reload.interval"), &:to_i
|
92
107
|
|
93
|
-
option ["--http
|
94
|
-
I18n.t("logstash.
|
95
|
-
:attribute_name =>
|
108
|
+
option ["--http.host"], "HTTP_HOST",
|
109
|
+
I18n.t("logstash.runner.flag.http_host"),
|
110
|
+
:attribute_name => "http.host",
|
111
|
+
:default => LogStash::SETTINGS.get_default("http.host")
|
96
112
|
|
97
|
-
option ["--http
|
98
|
-
I18n.t("logstash.
|
99
|
-
:attribute_name =>
|
113
|
+
option ["--http.port"], "HTTP_PORT",
|
114
|
+
I18n.t("logstash.runner.flag.http_port"),
|
115
|
+
:attribute_name => "http.port",
|
116
|
+
:default => LogStash::SETTINGS.get_default("http.port"), &:to_i
|
100
117
|
|
101
|
-
option ["--
|
102
|
-
I18n.t("logstash.runner.flag.
|
103
|
-
:attribute_name =>
|
118
|
+
option ["--log.format"], "FORMAT",
|
119
|
+
I18n.t("logstash.runner.flag.log_format"),
|
120
|
+
:attribute_name => "log.format",
|
121
|
+
:default => LogStash::SETTINGS.get_default("log.format")
|
104
122
|
|
105
|
-
|
106
|
-
|
107
|
-
|
123
|
+
option ["--path.settings"], "SETTINGS_DIR",
|
124
|
+
I18n.t("logstash.runner.flag.path_settings"),
|
125
|
+
:attribute_name => "path.settings",
|
126
|
+
:default => LogStash::SETTINGS.get_default("path.settings")
|
108
127
|
|
109
|
-
|
110
|
-
@pipeline_settings[:pipeline_batch_size] = validate_positive_integer(pipeline_batch_size_value)
|
111
|
-
end
|
128
|
+
attr_reader :agent
|
112
129
|
|
113
|
-
def
|
114
|
-
@
|
130
|
+
def initialize(*args)
|
131
|
+
@logger = Cabin::Channel.get(LogStash)
|
132
|
+
@settings = LogStash::SETTINGS
|
133
|
+
super(*args)
|
115
134
|
end
|
116
135
|
|
117
|
-
def
|
118
|
-
|
119
|
-
if str_arg !~ /^\d+$/ || int_arg < 1
|
120
|
-
raise ArgumentError, "Expected a positive integer, got '#{str_arg}'"
|
121
|
-
end
|
136
|
+
def run(args)
|
137
|
+
settings_path = fetch_settings_path(args)
|
122
138
|
|
123
|
-
|
124
|
-
end
|
139
|
+
@settings.set("path.settings", settings_path) if settings_path
|
125
140
|
|
126
|
-
|
141
|
+
begin
|
142
|
+
LogStash::SETTINGS.from_yaml(LogStash::SETTINGS.get("path.settings"))
|
143
|
+
rescue => e
|
144
|
+
@logger.subscribe(STDOUT)
|
145
|
+
@logger.warn("Logstash has a new settings file which defines start up time settings. This file is typically located in $LS_HOME/config or /etc/logstash. If you installed Logstash through a package and are starting it manually please specify the location to this settings file by passing in \"--path.settings=/path/..\" in the command line options")
|
146
|
+
@logger.fatal("Failed to load settings file from \"path.settings\". Aborting...", "path.settings" => LogStash::SETTINGS.get("path.settings"), "exception" => e.class, "message" => e.message)
|
147
|
+
exit(-1)
|
148
|
+
end
|
127
149
|
|
128
|
-
|
129
|
-
@logger = Cabin::Channel.get(LogStash)
|
130
|
-
@pipeline_settings ||= { :pipeline_id => "main" }
|
131
|
-
super(*args)
|
150
|
+
super(*[args])
|
132
151
|
end
|
133
152
|
|
134
153
|
def execute
|
@@ -136,11 +155,11 @@ class LogStash::Runner < Clamp::Command
|
|
136
155
|
require "logstash/util/java_version"
|
137
156
|
require "stud/task"
|
138
157
|
require "cabin" # gem 'cabin'
|
139
|
-
|
158
|
+
require "logstash/logging/json"
|
140
159
|
|
141
160
|
# Configure Logstash logging facility, this need to be done before everything else to
|
142
161
|
# make sure the logger has the correct settings and the log level is correctly defined.
|
143
|
-
configure_logging(
|
162
|
+
configure_logging(setting("path.log"), setting("log.level"))
|
144
163
|
|
145
164
|
LogStash::Util::set_thread_name(self.class.name)
|
146
165
|
|
@@ -149,33 +168,39 @@ class LogStash::Runner < Clamp::Command
|
|
149
168
|
return 1
|
150
169
|
end
|
151
170
|
|
152
|
-
#
|
153
|
-
LogStash::Util::JavaVersion.
|
171
|
+
# Exit on bad java versions
|
172
|
+
java_version = LogStash::Util::JavaVersion.version
|
173
|
+
if LogStash::Util::JavaVersion.bad_java_version?(java_version)
|
174
|
+
$stderr.puts "Java version 1.8.0 or later is required. (You are running: #{java_version})"
|
175
|
+
return 1
|
176
|
+
end
|
154
177
|
|
155
|
-
LogStash::ShutdownWatcher.unsafe_shutdown = unsafe_shutdown
|
178
|
+
LogStash::ShutdownWatcher.unsafe_shutdown = setting("pipeline.unsafe_shutdown")
|
156
179
|
LogStash::ShutdownWatcher.logger = @logger
|
157
180
|
|
158
|
-
|
181
|
+
configure_plugin_paths(setting("path.plugins"))
|
159
182
|
|
160
183
|
if version?
|
161
184
|
show_version
|
162
185
|
return 0
|
163
186
|
end
|
164
187
|
|
165
|
-
return start_shell(
|
188
|
+
return start_shell(setting("interactive"), binding) if setting("interactive")
|
189
|
+
|
190
|
+
@settings.format_settings.each {|line| @logger.info(line) }
|
166
191
|
|
167
|
-
if
|
192
|
+
if setting("config.string").nil? && setting("path.config").nil?
|
168
193
|
fail(I18n.t("logstash.runner.missing-configuration"))
|
169
194
|
end
|
170
195
|
|
171
|
-
if
|
196
|
+
if setting("config.reload.automatic") && setting("path.config").nil?
|
172
197
|
# there's nothing to reload
|
173
198
|
signal_usage_error(I18n.t("logstash.runner.reload-without-config-path"))
|
174
199
|
end
|
175
200
|
|
176
|
-
if
|
177
|
-
config_loader = LogStash::Config::Loader.new(@logger
|
178
|
-
config_str = config_loader.format_config(
|
201
|
+
if setting("config.test_and_exit")
|
202
|
+
config_loader = LogStash::Config::Loader.new(@logger)
|
203
|
+
config_str = config_loader.format_config(setting("path.config"), setting("config.string"))
|
179
204
|
begin
|
180
205
|
LogStash::Pipeline.new(config_str)
|
181
206
|
@logger.terminal "Configuration OK"
|
@@ -186,22 +211,9 @@ class LogStash::Runner < Clamp::Command
|
|
186
211
|
end
|
187
212
|
end
|
188
213
|
|
189
|
-
@agent = create_agent(
|
190
|
-
|
191
|
-
|
192
|
-
:collect_metric => true,
|
193
|
-
:debug => debug?,
|
194
|
-
:node_name => node_name,
|
195
|
-
:debug_config => debug_config?,
|
196
|
-
:web_api_http_host => @web_api_http_host,
|
197
|
-
:web_api_http_port => @web_api_http_port)
|
198
|
-
|
199
|
-
@agent.register_pipeline("main", @pipeline_settings.merge({
|
200
|
-
:config_string => config_string,
|
201
|
-
:config_path => config_path,
|
202
|
-
:debug_config => debug_config?,
|
203
|
-
:allow_env => allow_env?
|
204
|
-
}))
|
214
|
+
@agent = create_agent(@settings)
|
215
|
+
|
216
|
+
@agent.register_pipeline("main", @settings)
|
205
217
|
|
206
218
|
# enable sigint/sigterm before starting the agent
|
207
219
|
# to properly handle a stalled agent
|
@@ -236,10 +248,10 @@ class LogStash::Runner < Clamp::Command
|
|
236
248
|
def show_version
|
237
249
|
show_version_logstash
|
238
250
|
|
239
|
-
if
|
251
|
+
if @logger.debug? || @logger.info?
|
240
252
|
show_version_ruby
|
241
253
|
show_version_java if LogStash::Environment.jruby?
|
242
|
-
show_gems if
|
254
|
+
show_gems if @logger.debug?
|
243
255
|
end
|
244
256
|
end # def show_version
|
245
257
|
|
@@ -265,13 +277,6 @@ class LogStash::Runner < Clamp::Command
|
|
265
277
|
end
|
266
278
|
end # def show_gems
|
267
279
|
|
268
|
-
# Do any start-time configuration.
|
269
|
-
#
|
270
|
-
# Log file stuff, plugin path checking, etc.
|
271
|
-
def configure
|
272
|
-
configure_plugin_paths(plugin_paths)
|
273
|
-
end # def configure
|
274
|
-
|
275
280
|
# add the given paths for ungemified/bare plugins lookups
|
276
281
|
# @param paths [String, Array<String>] plugins path string or list of path strings to add
|
277
282
|
def configure_plugin_paths(paths)
|
@@ -286,32 +291,21 @@ class LogStash::Runner < Clamp::Command
|
|
286
291
|
end
|
287
292
|
|
288
293
|
# Point logging at a specific path.
|
289
|
-
def configure_logging(path)
|
294
|
+
def configure_logging(path, level)
|
290
295
|
@logger = Cabin::Channel.get(LogStash)
|
291
296
|
# Set with the -v (or -vv...) flag
|
292
|
-
|
297
|
+
case level
|
298
|
+
when "quiet"
|
293
299
|
@logger.level = :error
|
294
|
-
|
300
|
+
when "verbose"
|
295
301
|
@logger.level = :info
|
296
|
-
|
302
|
+
when "debug"
|
297
303
|
@logger.level = :debug
|
298
304
|
else
|
299
|
-
|
300
|
-
if verbosity? && verbosity?.any?
|
301
|
-
# this is an array with length of how many times the flag is given
|
302
|
-
if verbosity?.length == 1
|
303
|
-
@logger.warn("The -v flag is deprecated and will be removed in a future release. You should use --verbose instead.")
|
304
|
-
@logger.level = :info
|
305
|
-
else
|
306
|
-
@logger.warn("The -vv flag is deprecated and will be removed in a future release. You should use --debug instead.")
|
307
|
-
@logger.level = :debug
|
308
|
-
end
|
309
|
-
else
|
310
|
-
@logger.level = :warn
|
311
|
-
end
|
305
|
+
@logger.level = :warn
|
312
306
|
end
|
313
307
|
|
314
|
-
if
|
308
|
+
if path
|
315
309
|
# TODO(sissel): Implement file output/rotation in Cabin.
|
316
310
|
# TODO(sissel): Catch exceptions, report sane errors.
|
317
311
|
begin
|
@@ -322,15 +316,24 @@ class LogStash::Runner < Clamp::Command
|
|
322
316
|
:path => path, :error => e))
|
323
317
|
end
|
324
318
|
|
325
|
-
|
326
|
-
|
319
|
+
if setting("log.format") == "json"
|
320
|
+
@logger.subscribe(LogStash::Logging::JSON.new(STDOUT), :level => :fatal)
|
321
|
+
@logger.subscribe(LogStash::Logging::JSON.new(@log_fd))
|
322
|
+
else
|
323
|
+
@logger.subscribe(STDOUT, :level => :fatal)
|
324
|
+
@logger.subscribe(@log_fd)
|
325
|
+
end
|
327
326
|
@logger.terminal "Sending logstash logs to #{path}."
|
328
327
|
else
|
329
|
-
|
328
|
+
if setting("log.format") == "json"
|
329
|
+
@logger.subscribe(LogStash::Logging::JSON.new(STDOUT))
|
330
|
+
else
|
331
|
+
@logger.subscribe(STDOUT)
|
332
|
+
end
|
330
333
|
end
|
331
334
|
|
332
|
-
if
|
333
|
-
@logger.warn("--debug
|
335
|
+
if setting("config.debug") && @logger.level != :debug
|
336
|
+
@logger.warn("--config.debug was specified, but log.level was not set to \'debug\'! No config info will be logged.")
|
334
337
|
end
|
335
338
|
|
336
339
|
# TODO(sissel): redirect stdout/stderr to the log as well
|
@@ -390,4 +393,26 @@ class LogStash::Runner < Clamp::Command
|
|
390
393
|
end
|
391
394
|
end
|
392
395
|
|
393
|
-
|
396
|
+
def setting(key)
|
397
|
+
@settings.get_value(key)
|
398
|
+
end
|
399
|
+
|
400
|
+
# where can I find the logstash.yml file?
|
401
|
+
# 1. look for a "--path.settings path"
|
402
|
+
# 2. look for a "--path.settings=path"
|
403
|
+
# 3. check if the LS_SETTINGS_DIR environment variable is set
|
404
|
+
# 4. return nil if not found
|
405
|
+
def fetch_settings_path(cli_args)
|
406
|
+
if i=cli_args.find_index("--path.settings")
|
407
|
+
cli_args[i+1]
|
408
|
+
elsif settings_arg = cli_args.find {|v| v.match(/--path.settings=/) }
|
409
|
+
match = settings_arg.match(/--path.settings=(.*)/)
|
410
|
+
match[1]
|
411
|
+
elsif ENV['LS_SETTINGS_DIR']
|
412
|
+
ENV['LS_SETTINGS_DIR']
|
413
|
+
else
|
414
|
+
nil
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
end
|