logstash-core 2.3.0.snapshot5-java → 2.3.1-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 +23 -6
- data/lib/logstash/config/config_ast.rb +1 -1
- data/lib/logstash/config/loader.rb +12 -5
- data/lib/logstash/config/mixin.rb +37 -14
- data/lib/logstash/output_delegator.rb +1 -1
- data/lib/logstash/pipeline.rb +21 -11
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +11 -1
- data/logstash-core.gemspec +1 -1
- data/spec/logstash/agent_spec.rb +91 -1
- data/spec/logstash/config/config_ast_spec.rb +33 -0
- data/spec/logstash/config/mixin_spec.rb +9 -1
- data/spec/logstash/runner_spec.rb +0 -2
- metadata +28 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52cd049d11110ae1bf45c3b3f6d229c25db02ba2
|
4
|
+
data.tar.gz: d70f266b703fa586e19b6aa825b772e5952e84cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a55ef0b2328c183a12d7fb43b589618bfd1a8067b0a840fde1361e3b84d61496d9cc6e8d98e565fc54d69e17b1298618c0b6c7aeeb316084a57f2968caec5449
|
7
|
+
data.tar.gz: d379e03d87365b09351322249dfa3b6761cf63e57282af75c4864974b3e50bef52f0e9fec49e30f41bcc4e14807d40a4e1805ca2792235779ce58a49db72af44
|
data/lib/logstash/agent.rb
CHANGED
@@ -11,7 +11,7 @@ require "logstash/pipeline"
|
|
11
11
|
|
12
12
|
class LogStash::Agent < Clamp::Command
|
13
13
|
|
14
|
-
attr_reader :pipelines
|
14
|
+
attr_reader :pipelines, :config_loader
|
15
15
|
|
16
16
|
DEFAULT_INPUT = "input { stdin { type => stdin } }"
|
17
17
|
DEFAULT_OUTPUT = "output { stdout { codec => rubydebug } }"
|
@@ -58,6 +58,10 @@ class LogStash::Agent < Clamp::Command
|
|
58
58
|
option "--verbose", :flag, I18n.t("logstash.agent.flag.verbose")
|
59
59
|
option "--debug", :flag, I18n.t("logstash.agent.flag.debug")
|
60
60
|
|
61
|
+
option ["--debug-config"], :flag,
|
62
|
+
I18n.t("logstash.runner.flag.debug_config"),
|
63
|
+
:attribute_name => :debug_config, :default => false
|
64
|
+
|
61
65
|
option ["-V", "--version"], :flag,
|
62
66
|
I18n.t("logstash.agent.flag.version")
|
63
67
|
|
@@ -83,6 +87,10 @@ class LogStash::Agent < Clamp::Command
|
|
83
87
|
I18n.t("logstash.agent.flag.reload_interval"),
|
84
88
|
:attribute_name => :reload_interval, :default => 3, &:to_i
|
85
89
|
|
90
|
+
option ["--allow-env"], :flag,
|
91
|
+
I18n.t("logstash.agent.flag.allow-env"),
|
92
|
+
:attribute_name => :allow_env, :default => false
|
93
|
+
|
86
94
|
def initialize(*params)
|
87
95
|
super(*params)
|
88
96
|
@logger = Cabin::Channel.get(LogStash)
|
@@ -104,6 +112,11 @@ class LogStash::Agent < Clamp::Command
|
|
104
112
|
@pipeline_settings[:pipeline_batch_delay] = validate_positive_integer(pipeline_batch_delay_value)
|
105
113
|
end
|
106
114
|
|
115
|
+
def debug_config=(debug_config)
|
116
|
+
@config_loader.debug_config = debug_config
|
117
|
+
@debug_config = true
|
118
|
+
end
|
119
|
+
|
107
120
|
def validate_positive_integer(str_arg)
|
108
121
|
int_arg = str_arg.to_i
|
109
122
|
if str_arg !~ /^\d+$/ || int_arg < 1
|
@@ -166,19 +179,23 @@ class LogStash::Agent < Clamp::Command
|
|
166
179
|
if config_test?
|
167
180
|
config_loader = LogStash::Config::Loader.new(@logger)
|
168
181
|
config_str = config_loader.format_config(config_path, config_string)
|
169
|
-
|
170
|
-
|
182
|
+
begin
|
183
|
+
# currently the best strategy to validate the configuration
|
184
|
+
# is creating a pipeline instance and checking for exceptions
|
185
|
+
LogStash::Pipeline.new(config_str)
|
171
186
|
@logger.terminal "Configuration OK"
|
172
187
|
return 0
|
173
|
-
|
174
|
-
@logger.fatal I18n.t("logstash.
|
188
|
+
rescue => e
|
189
|
+
@logger.fatal I18n.t("logstash.agent.invalid-configuration", :error => e.message)
|
175
190
|
return 1
|
176
191
|
end
|
177
192
|
end
|
178
193
|
|
179
194
|
register_pipeline("main", @pipeline_settings.merge({
|
180
195
|
:config_string => config_string,
|
181
|
-
:config_path => config_path
|
196
|
+
:config_path => config_path,
|
197
|
+
:debug_config => debug_config?,
|
198
|
+
:allow_env => allow_env?
|
182
199
|
}))
|
183
200
|
|
184
201
|
sigint_id = trap_sigint()
|
@@ -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,11 @@
|
|
1
1
|
require "logstash/config/defaults"
|
2
2
|
|
3
3
|
module LogStash; module Config; class Loader
|
4
|
-
|
4
|
+
attr_accessor :debug_config
|
5
|
+
|
6
|
+
def initialize(logger, debug_config=false)
|
5
7
|
@logger = logger
|
8
|
+
@debug_config = debug_config
|
6
9
|
end
|
7
10
|
|
8
11
|
def format_config(config_path, config_string)
|
@@ -69,14 +72,18 @@ module LogStash; module Config; class Loader
|
|
69
72
|
encoding_issue_files << file
|
70
73
|
end
|
71
74
|
config << cfg + "\n"
|
72
|
-
|
73
|
-
|
75
|
+
if @debug_config
|
76
|
+
@logger.debug? && @logger.debug("\nThe following is the content of a file", :config_file => file.to_s)
|
77
|
+
@logger.debug? && @logger.debug("\n" + cfg + "\n\n")
|
78
|
+
end
|
74
79
|
end
|
75
80
|
if encoding_issue_files.any?
|
76
81
|
fail("The following config files contains non-ascii characters but are not UTF-8 encoded #{encoding_issue_files}")
|
77
82
|
end
|
78
|
-
|
79
|
-
|
83
|
+
if @debug_config
|
84
|
+
@logger.debug? && @logger.debug("\nThe following is the merged configuration")
|
85
|
+
@logger.debug? && @logger.debug("\n" + config + "\n\n")
|
86
|
+
end
|
80
87
|
return config
|
81
88
|
end # def load_config
|
82
89
|
|
@@ -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.agent.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
|
data/lib/logstash/pipeline.rb
CHANGED
@@ -26,7 +26,9 @@ module LogStash; class Pipeline
|
|
26
26
|
:pipeline_batch_size => 125,
|
27
27
|
:pipeline_batch_delay => 5, # in milliseconds
|
28
28
|
:flush_interval => 5, # in seconds
|
29
|
-
:flush_timeout_interval => 60 # in seconds
|
29
|
+
:flush_timeout_interval => 60, # in seconds
|
30
|
+
:debug_config => false,
|
31
|
+
:allow_env => false
|
30
32
|
}
|
31
33
|
MAX_INFLIGHT_WARN_THRESHOLD = 10_000
|
32
34
|
|
@@ -34,15 +36,6 @@ module LogStash; class Pipeline
|
|
34
36
|
"LogStash::Inputs::Stdin"
|
35
37
|
]
|
36
38
|
|
37
|
-
def self.validate_config(config_str, settings = {})
|
38
|
-
begin
|
39
|
-
# There should be a better way to test this
|
40
|
-
self.new(config_str, settings)
|
41
|
-
rescue => e
|
42
|
-
e.message
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
39
|
def initialize(config_str, settings = {})
|
47
40
|
@config_str = config_str
|
48
41
|
@original_settings = settings
|
@@ -51,6 +44,7 @@ module LogStash; class Pipeline
|
|
51
44
|
@settings = DEFAULT_SETTINGS.clone
|
52
45
|
settings.each {|setting, value| configure(setting, value) }
|
53
46
|
@reporter = LogStash::PipelineReporter.new(@logger, self)
|
47
|
+
@allow_env = settings[:allow_env]
|
54
48
|
|
55
49
|
@inputs = nil
|
56
50
|
@filters = nil
|
@@ -69,7 +63,9 @@ module LogStash; class Pipeline
|
|
69
63
|
code = @config.compile
|
70
64
|
# The config code is hard to represent as a log message...
|
71
65
|
# So just print it.
|
72
|
-
|
66
|
+
if @settings[:debug_config]
|
67
|
+
@logger.debug? && @logger.debug("Compiled pipeline code:\n#{code}")
|
68
|
+
end
|
73
69
|
begin
|
74
70
|
eval(code)
|
75
71
|
rescue => e
|
@@ -411,6 +407,7 @@ module LogStash; class Pipeline
|
|
411
407
|
|
412
408
|
def plugin(plugin_type, name, *args)
|
413
409
|
args << {} if args.empty?
|
410
|
+
args.first.merge!(LogStash::Config::Mixin::ALLOW_ENV_FLAG => @allow_env)
|
414
411
|
|
415
412
|
klass = LogStash::Plugin.lookup(plugin_type, name)
|
416
413
|
|
@@ -497,4 +494,17 @@ module LogStash; class Pipeline
|
|
497
494
|
end
|
498
495
|
end
|
499
496
|
|
497
|
+
# Sometimes we log stuff that will dump the pipeline which may contain
|
498
|
+
# sensitive information (like the raw syntax tree which can contain passwords)
|
499
|
+
# We want to hide most of what's in here
|
500
|
+
def inspect
|
501
|
+
{
|
502
|
+
:pipeline_id => @pipeline_id,
|
503
|
+
:settings => @settings.inspect,
|
504
|
+
:ready => @ready,
|
505
|
+
:running => @running,
|
506
|
+
:flushing => @flushing
|
507
|
+
}
|
508
|
+
end
|
509
|
+
|
500
510
|
end end
|
data/lib/logstash/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -59,6 +59,8 @@ en:
|
|
59
59
|
missing-configuration: >-
|
60
60
|
No configuration file was specified. Perhaps you forgot to provide
|
61
61
|
the '-f yourlogstash.conf' flag?
|
62
|
+
invalid-configuration: >-
|
63
|
+
The given configuration is invalid. Reason: %{error}
|
62
64
|
reload-without-config-path: >-
|
63
65
|
Configuration reloading also requires passing a configuration path with '-f yourlogstash.conf'
|
64
66
|
error: >-
|
@@ -161,6 +163,10 @@ en:
|
|
161
163
|
the empty string for the '-e' flag.
|
162
164
|
configtest: |+
|
163
165
|
Check configuration for valid syntax and then exit.
|
166
|
+
allow-env: |+
|
167
|
+
EXPERIMENTAL. Enables templating of environment variable
|
168
|
+
values. Instances of "${VAR}" in strings will be replaced
|
169
|
+
with the respective environment variable value named "VAR".
|
164
170
|
pipeline-workers: |+
|
165
171
|
Sets the number of pipeline workers to run.
|
166
172
|
filterworkers: |+
|
@@ -207,8 +213,12 @@ en:
|
|
207
213
|
debug: |+
|
208
214
|
Most verbose logging. This causes 'debug'
|
209
215
|
level logs to be emitted.
|
216
|
+
debug-config: |+
|
217
|
+
Print the compiled config ruby code out as a debug log (you must also have --debug enabled).
|
218
|
+
WARNING: This will include any 'password' options passed to plugin configs as plaintext, and may result
|
219
|
+
in plaintext passwords appearing in your logs!
|
210
220
|
unsafe_shutdown: |+
|
211
221
|
Force logstash to exit during shutdown even
|
212
222
|
if there are still inflight events in memory.
|
213
223
|
By default, logstash will refuse to quit until all
|
214
|
-
received events have been pushed to the outputs.
|
224
|
+
received events have been pushed to the outputs.
|
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
|
19
19
|
|
20
|
-
gem.add_runtime_dependency "logstash-core-event
|
20
|
+
gem.add_runtime_dependency "logstash-core-event", "2.3.1"
|
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)
|
data/spec/logstash/agent_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe LogStash::Agent do
|
|
10
10
|
subject { LogStash::Agent.new("", "") }
|
11
11
|
|
12
12
|
before :each do
|
13
|
-
[:log, :info, :warn, :error, :fatal, :debug].each do |level|
|
13
|
+
[:log, :info, :warn, :error, :fatal, :debug, :terminal].each do |level|
|
14
14
|
allow(logger).to receive(level)
|
15
15
|
end
|
16
16
|
[:info?, :warn?, :error?, :fatal?, :debug?].each do |level|
|
@@ -68,6 +68,7 @@ describe LogStash::Agent do
|
|
68
68
|
it "should not reload_state!" do
|
69
69
|
expect(subject).to_not receive(:reload_state!)
|
70
70
|
t = Thread.new { subject.execute }
|
71
|
+
sleep 0.01 until subject.running_pipelines? && subject.pipelines.values.first.ready?
|
71
72
|
sleep 0.1
|
72
73
|
Stud.stop!(t)
|
73
74
|
t.join
|
@@ -189,6 +190,7 @@ describe LogStash::Agent do
|
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
193
|
+
|
192
194
|
describe "#upgrade_pipeline" do
|
193
195
|
let(:pipeline_id) { "main" }
|
194
196
|
let(:pipeline_config) { "input { } filter { } output { }" }
|
@@ -295,6 +297,24 @@ describe LogStash::Agent do
|
|
295
297
|
end
|
296
298
|
end
|
297
299
|
|
300
|
+
describe "--config-test" do
|
301
|
+
let(:cli_args) { ["-t", "-e", pipeline_string] }
|
302
|
+
|
303
|
+
context "with a good configuration" do
|
304
|
+
let(:pipeline_string) { "input { } filter { } output { }" }
|
305
|
+
it "should exit successfuly" do
|
306
|
+
expect(subject.run(cli_args)).to eq(0)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
context "with a bad configuration" do
|
311
|
+
let(:pipeline_string) { "rlwekjhrewlqrkjh" }
|
312
|
+
it "should fail by returning a bad exit code" do
|
313
|
+
expect(subject.run(cli_args)).to eq(1)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
298
318
|
describe "pipeline settings" do
|
299
319
|
let(:pipeline_string) { "input { stdin {} } output { stdout {} }" }
|
300
320
|
let(:main_pipeline_settings) { { :pipeline_id => "main" } }
|
@@ -324,5 +344,75 @@ describe LogStash::Agent do
|
|
324
344
|
end
|
325
345
|
end
|
326
346
|
|
347
|
+
describe "debug_config" do
|
348
|
+
let(:pipeline_string) { "input {} output {}" }
|
349
|
+
let(:pipeline) { double("pipeline") }
|
350
|
+
|
351
|
+
it "should set 'debug_config' to false by default" do
|
352
|
+
expect(LogStash::Pipeline).to receive(:new).and_return(pipeline)
|
353
|
+
args = ["--debug", "-e", pipeline_string]
|
354
|
+
subject.run(args)
|
355
|
+
|
356
|
+
expect(subject.config_loader.debug_config).to be_falsey
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should allow overriding debug_config" do
|
360
|
+
expect(LogStash::Pipeline).to receive(:new).and_return(pipeline)
|
361
|
+
args = ["--debug", "--debug-config", "-e", pipeline_string]
|
362
|
+
subject.run(args)
|
363
|
+
|
364
|
+
expect(subject.config_loader.debug_config).to be_truthy
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
describe "allow_env param passing to pipeline" do
|
369
|
+
let(:pipeline_string) { "input {} output {}" }
|
370
|
+
let(:pipeline) { double("pipeline") }
|
371
|
+
|
372
|
+
it "should set 'allow_env' to false by default" do
|
373
|
+
args = ["-e", pipeline_string]
|
374
|
+
expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, hash_including(:allow_env => false)).and_return(pipeline)
|
375
|
+
subject.run(args)
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should support templating environment variables" do
|
379
|
+
args = ["-e", pipeline_string, "--allow-env"]
|
380
|
+
expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, hash_including(:allow_env => true)).and_return(pipeline)
|
381
|
+
subject.run(args)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
describe "Environment variables in config" do
|
386
|
+
let(:pipeline_id) { "main" }
|
387
|
+
let(:pipeline_config) { "input { generator { message => '${FOO}-bar' } } filter { } output { }" }
|
388
|
+
let(:pipeline_settings) { { :config_string => pipeline_config } }
|
389
|
+
let(:pipeline) { double("pipeline") }
|
390
|
+
|
391
|
+
context "when allow_env is false" do
|
392
|
+
it "does not interpolate environment variables" do
|
393
|
+
expect(subject).to receive(:fetch_config).and_return(pipeline_config)
|
394
|
+
subject.register_pipeline(pipeline_id, pipeline_settings)
|
395
|
+
expect(subject.pipelines[pipeline_id].inputs.first.message).to eq("${FOO}-bar")
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
context "when allow_env is true" do
|
400
|
+
before :each do
|
401
|
+
@foo_content = ENV["FOO"]
|
402
|
+
ENV["FOO"] = "foo"
|
403
|
+
pipeline_settings.merge!(:allow_env => true)
|
404
|
+
end
|
405
|
+
|
406
|
+
after :each do
|
407
|
+
ENV["FOO"] = @foo_content
|
408
|
+
end
|
409
|
+
|
410
|
+
it "doesn't upgrade the state" do
|
411
|
+
expect(subject).to receive(:fetch_config).and_return(pipeline_config)
|
412
|
+
subject.register_pipeline(pipeline_id, pipeline_settings)
|
413
|
+
expect(subject.pipelines[pipeline_id].inputs.first.message).to eq("foo-bar")
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
327
417
|
end
|
328
418
|
|
@@ -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
|
|
@@ -16,7 +16,6 @@ describe LogStash::Runner do
|
|
16
16
|
allow(Cabin::Channel).to receive(:get).with(LogStash).and_return(channel)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
19
|
context "argument parsing" do
|
21
20
|
it "should run agent" do
|
22
21
|
expect(Stud::Task).to receive(:new).once.and_return(nil)
|
@@ -55,5 +54,4 @@ describe LogStash::Runner do
|
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
58
|
-
|
59
57
|
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: 2.3.
|
4
|
+
version: 2.3.1
|
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-07 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: 2.3.
|
19
|
-
name: logstash-core-event
|
18
|
+
version: 2.3.1
|
19
|
+
name: logstash-core-event
|
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: 2.3.
|
26
|
+
version: 2.3.1
|
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
|
@@ -139,7 +139,7 @@ dependencies:
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
requirement: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
|
-
- - <
|
142
|
+
- - "<"
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: 1.5.0
|
145
145
|
name: treetop
|
@@ -147,7 +147,7 @@ dependencies:
|
|
147
147
|
type: :runtime
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - <
|
150
|
+
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 1.5.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
@@ -167,7 +167,7 @@ dependencies:
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
|
-
- - ~>
|
170
|
+
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: 0.5.4
|
173
173
|
name: minitar
|
@@ -175,13 +175,13 @@ dependencies:
|
|
175
175
|
type: :runtime
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - ~>
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 0.5.4
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
|
-
- - ~>
|
184
|
+
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: 1.1.7
|
187
187
|
name: rubyzip
|
@@ -189,13 +189,13 @@ dependencies:
|
|
189
189
|
type: :runtime
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - ~>
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 1.1.7
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
requirement: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
|
-
- - ~>
|
198
|
+
- - "~>"
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: 0.3.5
|
201
201
|
name: thread_safe
|
@@ -203,13 +203,13 @@ dependencies:
|
|
203
203
|
type: :runtime
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- - ~>
|
206
|
+
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: 0.3.5
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
requirement: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
|
-
- - ~>
|
212
|
+
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: 0.3.7
|
215
215
|
name: jrjackson
|
@@ -217,7 +217,7 @@ dependencies:
|
|
217
217
|
type: :runtime
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- - ~>
|
220
|
+
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: 0.3.7
|
223
223
|
description: The core components of logstash, the scalable log and event management tool
|
@@ -321,14 +321,14 @@ require_paths:
|
|
321
321
|
- lib
|
322
322
|
required_ruby_version: !ruby/object:Gem::Requirement
|
323
323
|
requirements:
|
324
|
-
- -
|
324
|
+
- - ">="
|
325
325
|
- !ruby/object:Gem::Version
|
326
326
|
version: '0'
|
327
327
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
328
328
|
requirements:
|
329
|
-
- -
|
329
|
+
- - ">="
|
330
330
|
- !ruby/object:Gem::Version
|
331
|
-
version:
|
331
|
+
version: '0'
|
332
332
|
requirements: []
|
333
333
|
rubyforge_project:
|
334
334
|
rubygems_version: 2.4.8
|