logstash-core 5.0.0.alpha1.snapshot1-java → 5.0.0.alpha1.snapshot2-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 +1 -1
- data/lib/logstash/config/config_ast.rb +1 -1
- data/lib/logstash/config/loader.rb +10 -5
- data/lib/logstash/config/mixin.rb +37 -14
- data/lib/logstash/instrument/periodic_poller/base.rb +2 -2
- data/lib/logstash/output_delegator.rb +1 -1
- data/lib/logstash/pipeline.rb +22 -11
- data/lib/logstash/runner.rb +22 -7
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +10 -0
- data/logstash-core.gemspec +2 -2
- data/spec/logstash/agent_spec.rb +39 -0
- data/spec/logstash/config/config_ast_spec.rb +33 -0
- data/spec/logstash/config/mixin_spec.rb +9 -1
- data/spec/logstash/pipeline_spec.rb +19 -0
- data/spec/logstash/runner_spec.rb +51 -0
- metadata +40 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1897b709706618fc25d95076f5260446a6552313
|
4
|
+
data.tar.gz: ef6d4c66c9f72d39a3bcca7bad86ce1b493b1933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96edfe806e2fe9c0848cbfe10b3aeb780dc67c63e007792126bd6e0f166ece56ed79caab924d4cdbaaeae561400414d3efb7ae56a48378c9a179144f14c642a0
|
7
|
+
data.tar.gz: c8b0b175e21c70203a2978b2c5b1973633694b42c09fb0e72784e1827ad25aee4c245656770f54e060db98190630605e171a130faa3f1b92870c21bfd0046cdf
|
data/lib/logstash/agent.rb
CHANGED
@@ -37,7 +37,7 @@ class LogStash::Agent
|
|
37
37
|
@web_api_http_host = params[:web_api_http_host]
|
38
38
|
@web_api_http_port = params[:web_api_http_port]
|
39
39
|
|
40
|
-
@config_loader = LogStash::Config::Loader.new(@logger)
|
40
|
+
@config_loader = LogStash::Config::Loader.new(@logger, params[:debug_config])
|
41
41
|
@reload_interval = params[:reload_interval] || 3 # seconds
|
42
42
|
@upgrade_mutex = Mutex.new
|
43
43
|
|
@@ -391,7 +391,7 @@ module LogStash; module Config; module AST
|
|
391
391
|
if type == "filter"
|
392
392
|
i = LogStash::Config::AST.defered_conditionals_index += 1
|
393
393
|
source = <<-CODE
|
394
|
-
|
394
|
+
define_singleton_method :cond_func_#{i} do |input_events|
|
395
395
|
result = []
|
396
396
|
input_events.each do |event|
|
397
397
|
events = [event]
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "logstash/config/defaults"
|
2
2
|
|
3
3
|
module LogStash; module Config; class Loader
|
4
|
-
def initialize(logger)
|
4
|
+
def initialize(logger, debug_config=false)
|
5
5
|
@logger = logger
|
6
|
+
@debug_config = debug_config
|
6
7
|
end
|
7
8
|
|
8
9
|
def format_config(config_path, config_string)
|
@@ -69,14 +70,18 @@ module LogStash; module Config; class Loader
|
|
69
70
|
encoding_issue_files << file
|
70
71
|
end
|
71
72
|
config << cfg + "\n"
|
72
|
-
|
73
|
-
|
73
|
+
if @debug_config
|
74
|
+
@logger.debug? && @logger.debug("\nThe following is the content of a file", :config_file => file.to_s)
|
75
|
+
@logger.debug? && @logger.debug("\n" + cfg + "\n\n")
|
76
|
+
end
|
74
77
|
end
|
75
78
|
if encoding_issue_files.any?
|
76
79
|
fail("The following config files contains non-ascii characters but are not UTF-8 encoded #{encoding_issue_files}")
|
77
80
|
end
|
78
|
-
|
79
|
-
|
81
|
+
if @debug_config
|
82
|
+
@logger.debug? && @logger.debug("\nThe following is the merged configuration")
|
83
|
+
@logger.debug? && @logger.debug("\n" + config + "\n\n")
|
84
|
+
end
|
80
85
|
return config
|
81
86
|
end # def load_config
|
82
87
|
|
@@ -38,7 +38,8 @@ module LogStash::Config::Mixin
|
|
38
38
|
PLUGIN_VERSION_1_0_0 = LogStash::Util::PluginVersion.new(1, 0, 0)
|
39
39
|
PLUGIN_VERSION_0_9_0 = LogStash::Util::PluginVersion.new(0, 9, 0)
|
40
40
|
|
41
|
-
|
41
|
+
ALLOW_ENV_FLAG = "__ALLOW_ENV__"
|
42
|
+
ENV_PLACEHOLDER_REGEX = /\$\{(?<name>\w+)(\:(?<default>[^}]*))?\}/
|
42
43
|
|
43
44
|
# This method is called when someone does 'include LogStash::Config'
|
44
45
|
def self.included(base)
|
@@ -47,13 +48,21 @@ module LogStash::Config::Mixin
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def config_init(params)
|
51
|
+
# HACK(talevy): https://github.com/elastic/logstash/issues/4958
|
52
|
+
# Currently, the regular plugins params argument is hijacked
|
53
|
+
# to pass along the `allow_env` configuration variable. This was done as to
|
54
|
+
# not change the method signature of Plugin. This also makes it difficul to
|
55
|
+
# reason about at the same time. ALLOW_ENV_FLAG is a special param that users
|
56
|
+
# are now forbidden to set in their configuration definitions.
|
57
|
+
allow_env = params.delete(LogStash::Config::Mixin::ALLOW_ENV_FLAG) { false }
|
58
|
+
|
50
59
|
# Validation will modify the values inside params if necessary.
|
51
60
|
# For example: converting a string to a number, etc.
|
52
61
|
|
53
62
|
# Keep a copy of the original config params so that we can later
|
54
63
|
# differentiate between explicit configuration and implicit (default)
|
55
64
|
# configuration.
|
56
|
-
|
65
|
+
original_params = params.clone
|
57
66
|
|
58
67
|
# store the plugin type, turns LogStash::Inputs::Base into 'input'
|
59
68
|
@plugin_type = self.class.ancestors.find { |a| a.name =~ /::Base$/ }.config_name
|
@@ -102,22 +111,25 @@ module LogStash::Config::Mixin
|
|
102
111
|
end
|
103
112
|
|
104
113
|
# Resolve environment variables references
|
105
|
-
|
106
|
-
|
107
|
-
value.
|
108
|
-
value
|
109
|
-
|
110
|
-
else
|
111
|
-
if (value.is_a?(Array))
|
112
|
-
value.each_index do |valueArrayIndex|
|
113
|
-
value[valueArrayIndex] = replace_env_placeholders(value[valueArrayIndex])
|
114
|
+
if allow_env
|
115
|
+
params.each do |name, value|
|
116
|
+
if (value.is_a?(Hash))
|
117
|
+
value.each do |valueHashKey, valueHashValue|
|
118
|
+
value[valueHashKey.to_s] = replace_env_placeholders(valueHashValue)
|
114
119
|
end
|
115
120
|
else
|
116
|
-
|
121
|
+
if (value.is_a?(Array))
|
122
|
+
value.each_index do |valueArrayIndex|
|
123
|
+
value[valueArrayIndex] = replace_env_placeholders(value[valueArrayIndex])
|
124
|
+
end
|
125
|
+
else
|
126
|
+
params[name.to_s] = replace_env_placeholders(value)
|
127
|
+
end
|
117
128
|
end
|
118
129
|
end
|
119
130
|
end
|
120
131
|
|
132
|
+
|
121
133
|
if !self.class.validate(params)
|
122
134
|
raise LogStash::ConfigurationError,
|
123
135
|
I18n.t("logstash.runner.configuration.invalid_plugin_settings")
|
@@ -142,6 +154,11 @@ module LogStash::Config::Mixin
|
|
142
154
|
instance_variable_set("@#{key}", value)
|
143
155
|
end
|
144
156
|
|
157
|
+
# now that we know the parameters are valid, we can obfuscate the original copy
|
158
|
+
# of the parameters before storing them as an instance variable
|
159
|
+
self.class.secure_params!(original_params)
|
160
|
+
@original_params = original_params
|
161
|
+
|
145
162
|
@config = params
|
146
163
|
end # def config_init
|
147
164
|
|
@@ -149,7 +166,6 @@ module LogStash::Config::Mixin
|
|
149
166
|
# Process following patterns : $VAR, ${VAR}, ${VAR:defaultValue}
|
150
167
|
def replace_env_placeholders(value)
|
151
168
|
return value unless value.is_a?(String)
|
152
|
-
#raise ArgumentError, "Cannot replace ENV placeholders on non-strings. Got #{value.class}" if !value.is_a?(String)
|
153
169
|
|
154
170
|
value.gsub(ENV_PLACEHOLDER_REGEX) do |placeholder|
|
155
171
|
# Note: Ruby docs claim[1] Regexp.last_match is thread-local and scoped to
|
@@ -163,7 +179,6 @@ module LogStash::Config::Mixin
|
|
163
179
|
if replacement.nil?
|
164
180
|
raise LogStash::ConfigurationError, "Cannot evaluate `#{placeholder}`. Environment variable `#{name}` is not set and there is no default value given."
|
165
181
|
end
|
166
|
-
@logger.info? && @logger.info("Evaluating environment variable placeholder", :placeholder => placeholder, :replacement => replacement)
|
167
182
|
replacement
|
168
183
|
end
|
169
184
|
end # def replace_env_placeholders
|
@@ -537,6 +552,14 @@ module LogStash::Config::Mixin
|
|
537
552
|
return true, result
|
538
553
|
end # def validate_value
|
539
554
|
|
555
|
+
def secure_params!(params)
|
556
|
+
params.each do |key, value|
|
557
|
+
if @config[key][:validate] == :password && !value.is_a?(::LogStash::Util::Password)
|
558
|
+
params[key] = ::LogStash::Util::Password.new(value)
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
540
563
|
def hash_or_array(value)
|
541
564
|
if !value.is_a?(Hash)
|
542
565
|
value = [*value] # coerce scalar to array if necessary
|
@@ -34,14 +34,14 @@ module LogStash module Instrument module PeriodicPoller
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def start
|
37
|
-
logger.debug("PeriodicPoller: Starting",
|
37
|
+
logger.debug("PeriodicPoller: Starting",
|
38
38
|
:polling_interval => @options[:polling_interval],
|
39
39
|
:polling_timeout => @options[:polling_timeout]) if logger.debug?
|
40
40
|
@task.execute
|
41
41
|
end
|
42
42
|
|
43
43
|
def stop
|
44
|
-
logger.debug("PeriodicPoller: Stopping"
|
44
|
+
logger.debug("PeriodicPoller: Stopping")
|
45
45
|
@task.shutdown
|
46
46
|
end
|
47
47
|
|
data/lib/logstash/pipeline.rb
CHANGED
@@ -44,7 +44,9 @@ module LogStash; class Pipeline
|
|
44
44
|
:pipeline_batch_size => 125,
|
45
45
|
:pipeline_batch_delay => 5, # in milliseconds
|
46
46
|
:flush_interval => 5, # in seconds
|
47
|
-
:flush_timeout_interval => 60 # in seconds
|
47
|
+
:flush_timeout_interval => 60, # in seconds
|
48
|
+
:debug_config => false,
|
49
|
+
:allow_env => false
|
48
50
|
}
|
49
51
|
MAX_INFLIGHT_WARN_THRESHOLD = 10_000
|
50
52
|
|
@@ -52,15 +54,6 @@ module LogStash; class Pipeline
|
|
52
54
|
"LogStash::Inputs::Stdin"
|
53
55
|
]
|
54
56
|
|
55
|
-
def self.validate_config(config_str, settings = {})
|
56
|
-
begin
|
57
|
-
# There should be a better way to test this
|
58
|
-
self.new(config_str, settings)
|
59
|
-
rescue => e
|
60
|
-
e.message
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
57
|
def initialize(config_str, settings = {})
|
65
58
|
@config_str = config_str
|
66
59
|
@original_settings = settings
|
@@ -69,6 +62,7 @@ module LogStash; class Pipeline
|
|
69
62
|
@settings = DEFAULT_SETTINGS.clone
|
70
63
|
settings.each {|setting, value| configure(setting, value) }
|
71
64
|
@reporter = LogStash::PipelineReporter.new(@logger, self)
|
65
|
+
@allow_env = settings[:allow_env]
|
72
66
|
|
73
67
|
@inputs = nil
|
74
68
|
@filters = nil
|
@@ -99,7 +93,10 @@ module LogStash; class Pipeline
|
|
99
93
|
|
100
94
|
# The config code is hard to represent as a log message...
|
101
95
|
# So just print it.
|
102
|
-
|
96
|
+
|
97
|
+
if @settings[:debug_config] && logger.debug?
|
98
|
+
logger.debug("Compiled pipeline code", :code => code)
|
99
|
+
end
|
103
100
|
|
104
101
|
begin
|
105
102
|
eval(code)
|
@@ -456,6 +453,7 @@ module LogStash; class Pipeline
|
|
456
453
|
|
457
454
|
def plugin(plugin_type, name, *args)
|
458
455
|
args << {} if args.empty?
|
456
|
+
args.first.merge!(LogStash::Config::Mixin::ALLOW_ENV_FLAG => @allow_env)
|
459
457
|
|
460
458
|
pipeline_scoped_metric = metric.namespace([:stats, :pipelines, pipeline_id.to_s.to_sym, :plugins])
|
461
459
|
|
@@ -555,4 +553,17 @@ module LogStash; class Pipeline
|
|
555
553
|
end
|
556
554
|
end
|
557
555
|
|
556
|
+
# Sometimes we log stuff that will dump the pipeline which may contain
|
557
|
+
# sensitive information (like the raw syntax tree which can contain passwords)
|
558
|
+
# We want to hide most of what's in here
|
559
|
+
def inspect
|
560
|
+
{
|
561
|
+
:pipeline_id => @pipeline_id,
|
562
|
+
:settings => @settings.inspect,
|
563
|
+
:ready => @ready,
|
564
|
+
:running => @running,
|
565
|
+
:flushing => @flushing
|
566
|
+
}
|
567
|
+
end
|
568
|
+
|
558
569
|
end end
|
data/lib/logstash/runner.rb
CHANGED
@@ -53,6 +53,10 @@ class LogStash::Runner < Clamp::Command
|
|
53
53
|
option "--verbose", :flag, I18n.t("logstash.runner.flag.verbose")
|
54
54
|
option "--debug", :flag, I18n.t("logstash.runner.flag.debug")
|
55
55
|
|
56
|
+
option ["--debug-config"], :flag,
|
57
|
+
I18n.t("logstash.runner.flag.debug_config"),
|
58
|
+
:attribute_name => :debug_config, :default => false
|
59
|
+
|
56
60
|
option ["-V", "--version"], :flag,
|
57
61
|
I18n.t("logstash.runner.flag.version")
|
58
62
|
|
@@ -94,6 +98,10 @@ class LogStash::Runner < Clamp::Command
|
|
94
98
|
I18n.t("logstash.web_api.flag.http_port"),
|
95
99
|
:attribute_name => :web_api_http_port, :default => 9600
|
96
100
|
|
101
|
+
option ["--allow-env"], :flag,
|
102
|
+
I18n.t("logstash.runner.flag.allow-env"),
|
103
|
+
:attribute_name => :allow_env, :default => false
|
104
|
+
|
97
105
|
def pipeline_workers=(pipeline_workers_value)
|
98
106
|
@pipeline_settings[:pipeline_workers] = validate_positive_integer(pipeline_workers_value)
|
99
107
|
end
|
@@ -166,14 +174,14 @@ class LogStash::Runner < Clamp::Command
|
|
166
174
|
end
|
167
175
|
|
168
176
|
if config_test?
|
169
|
-
config_loader = LogStash::Config::Loader.new(@logger,
|
177
|
+
config_loader = LogStash::Config::Loader.new(@logger, @debug_config)
|
170
178
|
config_str = config_loader.format_config(config_path, config_string)
|
171
|
-
|
172
|
-
|
179
|
+
begin
|
180
|
+
LogStash::Pipeline.new(config_str)
|
173
181
|
@logger.terminal "Configuration OK"
|
174
182
|
return 0
|
175
|
-
|
176
|
-
@logger.fatal I18n.t("logstash.
|
183
|
+
rescue => e
|
184
|
+
@logger.fatal I18n.t("logstash.runner.invalid-configuration", :error => e.message)
|
177
185
|
return 1
|
178
186
|
end
|
179
187
|
end
|
@@ -184,12 +192,15 @@ class LogStash::Runner < Clamp::Command
|
|
184
192
|
:collect_metric => true,
|
185
193
|
:debug => debug?,
|
186
194
|
:node_name => node_name,
|
195
|
+
:debug_config => debug_config?,
|
187
196
|
:web_api_http_host => @web_api_http_host,
|
188
197
|
:web_api_http_port => @web_api_http_port)
|
189
198
|
|
190
199
|
@agent.register_pipeline("main", @pipeline_settings.merge({
|
191
200
|
:config_string => config_string,
|
192
|
-
:config_path => config_path
|
201
|
+
:config_path => config_path,
|
202
|
+
:debug_config => debug_config?,
|
203
|
+
:allow_env => allow_env?
|
193
204
|
}))
|
194
205
|
|
195
206
|
# enable sigint/sigterm before starting the agent
|
@@ -213,7 +224,7 @@ class LogStash::Runner < Clamp::Command
|
|
213
224
|
show_short_help
|
214
225
|
return 1
|
215
226
|
rescue => e
|
216
|
-
@logger.fatal
|
227
|
+
@logger.fatal(I18n.t("oops"), :error => e, :backtrace => e.backtrace)
|
217
228
|
return 1
|
218
229
|
ensure
|
219
230
|
Stud::untrap("INT", sigint_id) unless sigint_id.nil?
|
@@ -318,6 +329,10 @@ class LogStash::Runner < Clamp::Command
|
|
318
329
|
@logger.subscribe(STDOUT)
|
319
330
|
end
|
320
331
|
|
332
|
+
if debug_config? && @logger.level != :debug
|
333
|
+
@logger.warn("--debug-config was specified, but log level was not set to --debug! No config info will be logged.")
|
334
|
+
end
|
335
|
+
|
321
336
|
# TODO(sissel): redirect stdout/stderr to the log as well
|
322
337
|
# http://jira.codehaus.org/browse/JRUBY-7003
|
323
338
|
end # def configure_logging
|
data/lib/logstash/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -91,6 +91,8 @@ en:
|
|
91
91
|
bin/logstash -i SHELL [--quiet|verbose|debug]
|
92
92
|
bin/logstash -V [--verbose|debug]
|
93
93
|
bin/logstash --help
|
94
|
+
invalid-configuration: >-
|
95
|
+
The given configuration is invalid. Reason: %{error}
|
94
96
|
missing-configuration: >-
|
95
97
|
No configuration file was specified. Perhaps you forgot to provide
|
96
98
|
the '-f yourlogstash.conf' flag?
|
@@ -180,6 +182,10 @@ en:
|
|
180
182
|
the empty string for the '-e' flag.
|
181
183
|
configtest: |+
|
182
184
|
Check configuration for valid syntax and then exit.
|
185
|
+
allow-env: |+
|
186
|
+
EXPERIMENTAL. Enables templating of environment variable
|
187
|
+
values. Instances of "${VAR}" in strings will be replaced
|
188
|
+
with the respective environment variable value named "VAR".
|
183
189
|
pipeline-workers: |+
|
184
190
|
Sets the number of pipeline workers to run.
|
185
191
|
pipeline-batch-size: |+
|
@@ -237,3 +243,7 @@ en:
|
|
237
243
|
it will default to the current hostname.
|
238
244
|
agent: |+
|
239
245
|
Specify an alternate agent plugin name.
|
246
|
+
debug_config: |+
|
247
|
+
Print the compiled config ruby code out as a debug log (you must also have --debug enabled).
|
248
|
+
WARNING: This will include any 'password' options passed to plugin configs as plaintext, and may result
|
249
|
+
in plaintext passwords appearing in your logs!
|
data/logstash-core.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
gem.version = LOGSTASH_CORE_VERSION.gsub(/-/, '.')
|
19
19
|
|
20
|
-
gem.add_runtime_dependency "logstash-core-event-java", "~> 5.0.0.alpha1.
|
20
|
+
gem.add_runtime_dependency "logstash-core-event-java", "~> 5.0.0.alpha1.snapshot2"
|
21
21
|
|
22
22
|
gem.add_runtime_dependency "cabin", "~> 0.8.0" #(Apache 2.0 license)
|
23
23
|
gem.add_runtime_dependency "pry", "~> 0.10.1" #(Ruby license)
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_runtime_dependency 'puma', '~> 2.16', '>= 2.16.0'
|
31
31
|
gem.add_runtime_dependency "jruby-openssl", "0.9.13" # Required to support TLSv1.2
|
32
32
|
gem.add_runtime_dependency "chronic_duration", "0.10.6"
|
33
|
-
gem.add_runtime_dependency "jruby-monitoring", '~> 0.1'
|
33
|
+
gem.add_runtime_dependency "jruby-monitoring", '~> 0.3.1'
|
34
34
|
|
35
35
|
# TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't
|
36
36
|
# investigated what the cause might be. -Jordan
|
data/spec/logstash/agent_spec.rb
CHANGED
@@ -191,6 +191,45 @@ describe LogStash::Agent do
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
+
describe "Environment Variables In Configs" do
|
195
|
+
let(:agent_args) { {
|
196
|
+
:logger => logger,
|
197
|
+
:auto_reload => false,
|
198
|
+
:reload_interval => 0.01
|
199
|
+
} }
|
200
|
+
let(:pipeline_id) { "main" }
|
201
|
+
let(:pipeline_config) { "input { generator { message => '${FOO}-bar' } } filter { } output { }" }
|
202
|
+
let(:pipeline_settings) { {
|
203
|
+
:config_string => pipeline_config,
|
204
|
+
} }
|
205
|
+
|
206
|
+
context "when allow_env is false" do
|
207
|
+
it "does not interpolate environment variables" do
|
208
|
+
expect(subject).to receive(:fetch_config).and_return(pipeline_config)
|
209
|
+
subject.register_pipeline(pipeline_id, pipeline_settings)
|
210
|
+
expect(subject.pipelines[pipeline_id].inputs.first.message).to eq("${FOO}-bar")
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context "when allow_env is true" do
|
215
|
+
before :each do
|
216
|
+
@foo_content = ENV["FOO"]
|
217
|
+
ENV["FOO"] = "foo"
|
218
|
+
pipeline_settings.merge!(:allow_env => true)
|
219
|
+
end
|
220
|
+
|
221
|
+
after :each do
|
222
|
+
ENV["FOO"] = @foo_content
|
223
|
+
end
|
224
|
+
|
225
|
+
it "doesn't upgrade the state" do
|
226
|
+
expect(subject).to receive(:fetch_config).and_return(pipeline_config)
|
227
|
+
subject.register_pipeline(pipeline_id, pipeline_settings)
|
228
|
+
expect(subject.pipelines[pipeline_id].inputs.first.message).to eq("foo-bar")
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
194
233
|
describe "#upgrade_pipeline" do
|
195
234
|
let(:pipeline_id) { "main" }
|
196
235
|
let(:pipeline_config) { "input { } filter { } output { }" }
|
@@ -143,4 +143,37 @@ describe LogStashConfigParser do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
context "when creating two instances of the same configuration" do
|
148
|
+
|
149
|
+
let(:config_string) {
|
150
|
+
"input { generator { } }
|
151
|
+
filter {
|
152
|
+
if [type] == 'test' { filter1 { } }
|
153
|
+
}
|
154
|
+
output {
|
155
|
+
output1 { }
|
156
|
+
}"
|
157
|
+
}
|
158
|
+
|
159
|
+
let(:pipeline_klass) do
|
160
|
+
Class.new do
|
161
|
+
def initialize(config)
|
162
|
+
grammar = LogStashConfigParser.new
|
163
|
+
@config = grammar.parse(config)
|
164
|
+
@code = @config.compile
|
165
|
+
eval(@code)
|
166
|
+
end
|
167
|
+
def plugin(*args);end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe "generated conditional functionals" do
|
172
|
+
it "should be defined at instance level" do
|
173
|
+
instance_1 = pipeline_klass.new(config_string)
|
174
|
+
instance_2 = pipeline_klass.new(config_string)
|
175
|
+
expect(instance_1.method(:cond_func_1).owner).to_not be(instance_2.method(:cond_func_1).owner)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
146
179
|
end
|
@@ -96,6 +96,10 @@ describe LogStash::Config::Mixin do
|
|
96
96
|
clone = subject.class.new(subject.params)
|
97
97
|
expect(clone.password.value).to(be == secret)
|
98
98
|
end
|
99
|
+
|
100
|
+
it "should obfuscate original_params" do
|
101
|
+
expect(subject.original_params['password']).to(be_a(LogStash::Util::Password))
|
102
|
+
end
|
99
103
|
end
|
100
104
|
|
101
105
|
describe "obsolete settings" do
|
@@ -161,6 +165,10 @@ describe LogStash::Config::Mixin do
|
|
161
165
|
config :oneNumber, :validate => :number
|
162
166
|
config :oneArray, :validate => :array
|
163
167
|
config :oneHash, :validate => :hash
|
168
|
+
|
169
|
+
def initialize(params)
|
170
|
+
super(params.merge(LogStash::Config::Mixin::ALLOW_ENV_FLAG => true))
|
171
|
+
end
|
164
172
|
end
|
165
173
|
end
|
166
174
|
|
@@ -213,7 +221,7 @@ describe LogStash::Config::Mixin do
|
|
213
221
|
"oneString" => "${FunString:foo}",
|
214
222
|
"oneBoolean" => "${FunBool:false}",
|
215
223
|
"oneArray" => [ "first array value", "${FunString:foo}" ],
|
216
|
-
"oneHash" => { "key1" => "${FunString:foo}", "key2" => "$FunString is ${FunBool}", "key3" => "${FunBool:false} or ${funbool:false}" }
|
224
|
+
"oneHash" => { "key1" => "${FunString:foo}", "key2" => "${FunString} is ${FunBool}", "key3" => "${FunBool:false} or ${funbool:false}" }
|
217
225
|
)
|
218
226
|
end
|
219
227
|
|
@@ -137,6 +137,25 @@ describe LogStash::Pipeline do
|
|
137
137
|
eos
|
138
138
|
}
|
139
139
|
|
140
|
+
describe "debug compiled" do
|
141
|
+
let(:logger) { double("pipeline logger").as_null_object }
|
142
|
+
|
143
|
+
before do
|
144
|
+
expect(Cabin::Channel).to receive(:get).with(LogStash).and_return(logger).at_least(:once)
|
145
|
+
allow(logger).to receive(:debug?).and_return(true)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should not receive a debug message with the compiled code" do
|
149
|
+
expect(logger).not_to receive(:debug).with(/Compiled pipeline/, anything)
|
150
|
+
pipeline = TestPipeline.new(test_config_with_filters)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should print the compiled code if debug_config is set to true" do
|
154
|
+
expect(logger).to receive(:debug).with(/Compiled pipeline/, anything)
|
155
|
+
pipeline = TestPipeline.new(test_config_with_filters, :debug_config => true)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
140
159
|
context "when there is no command line -w N set" do
|
141
160
|
it "starts one filter thread" do
|
142
161
|
msg = "Defaulting pipeline worker threads to 1 because there are some filters that might not work with multiple worker threads"
|
@@ -16,6 +16,7 @@ describe LogStash::Runner do
|
|
16
16
|
|
17
17
|
before :each do
|
18
18
|
allow(Cabin::Channel).to receive(:get).with(LogStash).and_return(channel)
|
19
|
+
allow(channel).to receive(:subscribe).with(any_args)
|
19
20
|
end
|
20
21
|
|
21
22
|
describe "argument parsing" do
|
@@ -95,6 +96,26 @@ describe LogStash::Runner do
|
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
99
|
+
describe "--config-test" do
|
100
|
+
subject { LogStash::Runner.new("") }
|
101
|
+
let(:args) { ["-t", "-e", pipeline_string] }
|
102
|
+
|
103
|
+
context "with a good configuration" do
|
104
|
+
let(:pipeline_string) { "input { } filter { } output { }" }
|
105
|
+
it "should exit successfuly" do
|
106
|
+
expect(channel).to receive(:terminal)
|
107
|
+
expect(subject.run(args)).to eq(0)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context "with a bad configuration" do
|
112
|
+
let(:pipeline_string) { "rlwekjhrewlqrkjh" }
|
113
|
+
it "should fail by returning a bad exit code" do
|
114
|
+
expect(channel).to receive(:fatal)
|
115
|
+
expect(subject.run(args)).to eq(1)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
98
119
|
describe "pipeline settings" do
|
99
120
|
let(:pipeline_string) { "input { stdin {} } output { stdout {} }" }
|
100
121
|
let(:main_pipeline_settings) { { :pipeline_id => "main" } }
|
@@ -125,5 +146,35 @@ describe LogStash::Runner do
|
|
125
146
|
subject.run("bin/logstash", args)
|
126
147
|
end
|
127
148
|
end
|
149
|
+
|
150
|
+
describe "debug_config" do
|
151
|
+
it "should set 'debug_config' to false by default" do
|
152
|
+
expect(LogStash::Config::Loader).to receive(:new).with(anything, false).and_call_original
|
153
|
+
expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, hash_including(:debug_config => false)).and_return(pipeline)
|
154
|
+
args = ["--debug", "-e", pipeline_string]
|
155
|
+
subject.run("bin/logstash", args)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should allow overriding debug_config" do
|
159
|
+
expect(LogStash::Config::Loader).to receive(:new).with(anything, true).and_call_original
|
160
|
+
expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, hash_including(:debug_config => true)).and_return(pipeline)
|
161
|
+
args = ["--debug", "--debug-config", "-e", pipeline_string]
|
162
|
+
subject.run("bin/logstash", args)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "when configuring environment variable support" do
|
167
|
+
it "should set 'allow_env' to false by default" do
|
168
|
+
args = ["-e", pipeline_string]
|
169
|
+
expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, hash_including(:allow_env => false)).and_return(pipeline)
|
170
|
+
subject.run("bin/logstash", args)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should support templating environment variables" do
|
174
|
+
args = ["-e", pipeline_string, "--allow-env"]
|
175
|
+
expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, hash_including(:allow_env => true)).and_return(pipeline)
|
176
|
+
subject.run("bin/logstash", args)
|
177
|
+
end
|
178
|
+
end
|
128
179
|
end
|
129
180
|
end
|
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.alpha1.
|
4
|
+
version: 5.0.0.alpha1.snapshot2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - ~>
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 5.0.0.alpha1.
|
18
|
+
version: 5.0.0.alpha1.snapshot2
|
19
19
|
name: logstash-core-event-java
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.0.0.alpha1.
|
26
|
+
version: 5.0.0.alpha1.snapshot2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- - ~>
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.8.0
|
33
33
|
name: cabin
|
@@ -35,13 +35,13 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.8.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ~>
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 0.10.1
|
47
47
|
name: pry
|
@@ -49,13 +49,13 @@ dependencies:
|
|
49
49
|
type: :runtime
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.10.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - ~>
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 0.0.19
|
61
61
|
name: stud
|
@@ -63,13 +63,13 @@ dependencies:
|
|
63
63
|
type: :runtime
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.0.19
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 0.6.5
|
75
75
|
name: clamp
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
type: :runtime
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.6.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -97,7 +97,7 @@ dependencies:
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - ~>
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: 0.8.3
|
103
103
|
name: gems
|
@@ -105,7 +105,7 @@ dependencies:
|
|
105
105
|
type: :runtime
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.8.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
@@ -125,10 +125,10 @@ dependencies:
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - ~>
|
128
|
+
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '1.4'
|
131
|
-
- -
|
131
|
+
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: 1.4.6
|
134
134
|
name: sinatra
|
@@ -136,19 +136,19 @@ dependencies:
|
|
136
136
|
type: :runtime
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
|
-
- - ~>
|
139
|
+
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '1.4'
|
142
|
-
- -
|
142
|
+
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: 1.4.6
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
requirement: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
|
-
- - ~>
|
148
|
+
- - "~>"
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '2.16'
|
151
|
-
- -
|
151
|
+
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: 2.16.0
|
154
154
|
name: puma
|
@@ -156,10 +156,10 @@ dependencies:
|
|
156
156
|
type: :runtime
|
157
157
|
version_requirements: !ruby/object:Gem::Requirement
|
158
158
|
requirements:
|
159
|
-
- - ~>
|
159
|
+
- - "~>"
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '2.16'
|
162
|
-
- -
|
162
|
+
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: 2.16.0
|
165
165
|
- !ruby/object:Gem::Dependency
|
@@ -193,21 +193,21 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
194
|
requirement: !ruby/object:Gem::Requirement
|
195
195
|
requirements:
|
196
|
-
- - ~>
|
196
|
+
- - "~>"
|
197
197
|
- !ruby/object:Gem::Version
|
198
|
-
version:
|
198
|
+
version: 0.3.1
|
199
199
|
name: jruby-monitoring
|
200
200
|
prerelease: false
|
201
201
|
type: :runtime
|
202
202
|
version_requirements: !ruby/object:Gem::Requirement
|
203
203
|
requirements:
|
204
|
-
- - ~>
|
204
|
+
- - "~>"
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
version:
|
206
|
+
version: 0.3.1
|
207
207
|
- !ruby/object:Gem::Dependency
|
208
208
|
requirement: !ruby/object:Gem::Requirement
|
209
209
|
requirements:
|
210
|
-
- - <
|
210
|
+
- - "<"
|
211
211
|
- !ruby/object:Gem::Version
|
212
212
|
version: 1.5.0
|
213
213
|
name: treetop
|
@@ -215,7 +215,7 @@ dependencies:
|
|
215
215
|
type: :runtime
|
216
216
|
version_requirements: !ruby/object:Gem::Requirement
|
217
217
|
requirements:
|
218
|
-
- - <
|
218
|
+
- - "<"
|
219
219
|
- !ruby/object:Gem::Version
|
220
220
|
version: 1.5.0
|
221
221
|
- !ruby/object:Gem::Dependency
|
@@ -235,7 +235,7 @@ dependencies:
|
|
235
235
|
- !ruby/object:Gem::Dependency
|
236
236
|
requirement: !ruby/object:Gem::Requirement
|
237
237
|
requirements:
|
238
|
-
- - ~>
|
238
|
+
- - "~>"
|
239
239
|
- !ruby/object:Gem::Version
|
240
240
|
version: 0.5.4
|
241
241
|
name: minitar
|
@@ -243,13 +243,13 @@ dependencies:
|
|
243
243
|
type: :runtime
|
244
244
|
version_requirements: !ruby/object:Gem::Requirement
|
245
245
|
requirements:
|
246
|
-
- - ~>
|
246
|
+
- - "~>"
|
247
247
|
- !ruby/object:Gem::Version
|
248
248
|
version: 0.5.4
|
249
249
|
- !ruby/object:Gem::Dependency
|
250
250
|
requirement: !ruby/object:Gem::Requirement
|
251
251
|
requirements:
|
252
|
-
- - ~>
|
252
|
+
- - "~>"
|
253
253
|
- !ruby/object:Gem::Version
|
254
254
|
version: 1.1.7
|
255
255
|
name: rubyzip
|
@@ -257,13 +257,13 @@ dependencies:
|
|
257
257
|
type: :runtime
|
258
258
|
version_requirements: !ruby/object:Gem::Requirement
|
259
259
|
requirements:
|
260
|
-
- - ~>
|
260
|
+
- - "~>"
|
261
261
|
- !ruby/object:Gem::Version
|
262
262
|
version: 1.1.7
|
263
263
|
- !ruby/object:Gem::Dependency
|
264
264
|
requirement: !ruby/object:Gem::Requirement
|
265
265
|
requirements:
|
266
|
-
- - ~>
|
266
|
+
- - "~>"
|
267
267
|
- !ruby/object:Gem::Version
|
268
268
|
version: 0.3.5
|
269
269
|
name: thread_safe
|
@@ -271,13 +271,13 @@ dependencies:
|
|
271
271
|
type: :runtime
|
272
272
|
version_requirements: !ruby/object:Gem::Requirement
|
273
273
|
requirements:
|
274
|
-
- - ~>
|
274
|
+
- - "~>"
|
275
275
|
- !ruby/object:Gem::Version
|
276
276
|
version: 0.3.5
|
277
277
|
- !ruby/object:Gem::Dependency
|
278
278
|
requirement: !ruby/object:Gem::Requirement
|
279
279
|
requirements:
|
280
|
-
- - ~>
|
280
|
+
- - "~>"
|
281
281
|
- !ruby/object:Gem::Version
|
282
282
|
version: 0.3.7
|
283
283
|
name: jrjackson
|
@@ -285,7 +285,7 @@ dependencies:
|
|
285
285
|
type: :runtime
|
286
286
|
version_requirements: !ruby/object:Gem::Requirement
|
287
287
|
requirements:
|
288
|
-
- - ~>
|
288
|
+
- - "~>"
|
289
289
|
- !ruby/object:Gem::Version
|
290
290
|
version: 0.3.7
|
291
291
|
description: The core components of logstash, the scalable log and event management tool
|
@@ -445,12 +445,12 @@ require_paths:
|
|
445
445
|
- lib
|
446
446
|
required_ruby_version: !ruby/object:Gem::Requirement
|
447
447
|
requirements:
|
448
|
-
- -
|
448
|
+
- - ">="
|
449
449
|
- !ruby/object:Gem::Version
|
450
450
|
version: '0'
|
451
451
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
452
452
|
requirements:
|
453
|
-
- -
|
453
|
+
- - ">"
|
454
454
|
- !ruby/object:Gem::Version
|
455
455
|
version: 1.3.1
|
456
456
|
requirements: []
|