logstash-core 5.0.0.alpha2.snapshot2-java → 5.0.0.alpha3-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of logstash-core might be problematic. Click here for more details.

Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash-core/version.rb +1 -1
  3. data/lib/logstash/agent.rb +48 -31
  4. data/lib/logstash/api/{lib/helpers/app_helpers.rb → app_helpers.rb} +0 -0
  5. data/lib/logstash/api/command_factory.rb +34 -0
  6. data/lib/logstash/api/commands/base.rb +25 -0
  7. data/lib/logstash/api/commands/stats.rb +105 -0
  8. data/lib/logstash/api/commands/system/basicinfo_command.rb +23 -0
  9. data/lib/logstash/api/commands/system/plugins_command.rb +35 -0
  10. data/lib/logstash/api/modules/base.rb +43 -0
  11. data/lib/logstash/api/modules/node.rb +24 -0
  12. data/lib/logstash/api/modules/node_stats.rb +59 -0
  13. data/lib/logstash/api/modules/plugins.rb +15 -0
  14. data/lib/logstash/api/modules/root.rb +15 -0
  15. data/lib/logstash/api/modules/stats.rb +63 -0
  16. data/lib/logstash/api/rack_app.rb +33 -0
  17. data/lib/logstash/api/service.rb +73 -0
  18. data/lib/logstash/config/config_ast.rb +23 -18
  19. data/lib/logstash/config/loader.rb +4 -4
  20. data/lib/logstash/config/mixin.rb +10 -21
  21. data/lib/logstash/environment.rb +29 -0
  22. data/lib/logstash/filters/base.rb +2 -2
  23. data/lib/logstash/inputs/base.rb +2 -2
  24. data/lib/logstash/instrument/collector.rb +1 -1
  25. data/lib/logstash/instrument/metric_store.rb +11 -1
  26. data/lib/logstash/instrument/periodic_poller/base.rb +2 -0
  27. data/lib/logstash/instrument/periodic_poller/jvm.rb +47 -2
  28. data/lib/logstash/logging/json.rb +21 -0
  29. data/lib/logstash/output_delegator.rb +2 -2
  30. data/lib/logstash/patches/clamp.rb +69 -0
  31. data/lib/logstash/pipeline.rb +36 -69
  32. data/lib/logstash/plugin.rb +1 -1
  33. data/lib/logstash/runner.rb +171 -146
  34. data/lib/logstash/settings.rb +267 -0
  35. data/lib/logstash/util/decorators.rb +6 -6
  36. data/lib/logstash/util/java_version.rb +1 -10
  37. data/lib/logstash/util/thread_dump.rb +55 -0
  38. data/lib/logstash/util/worker_threads_default_printer.rb +2 -2
  39. data/lib/logstash/version.rb +1 -1
  40. data/lib/logstash/webserver.rb +15 -49
  41. data/locales/en.yml +22 -25
  42. data/logstash-core.gemspec +3 -3
  43. data/spec/api/lib/api/node_spec.rb +2 -2
  44. data/spec/api/lib/api/node_stats_spec.rb +32 -57
  45. data/spec/api/lib/api/plugins_spec.rb +3 -3
  46. data/spec/api/lib/api/root_spec.rb +2 -2
  47. data/spec/api/lib/api/support/resource_dsl_methods.rb +47 -0
  48. data/spec/api/lib/commands/stats.rb +47 -0
  49. data/spec/api/spec_helper.rb +21 -21
  50. data/spec/conditionals_spec.rb +113 -113
  51. data/spec/logstash/agent_spec.rb +85 -68
  52. data/spec/logstash/config/config_ast_spec.rb +4 -2
  53. data/spec/logstash/config/mixin_spec.rb +33 -7
  54. data/spec/logstash/filters/base_spec.rb +16 -16
  55. data/spec/logstash/inputs/base_spec.rb +8 -8
  56. data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +45 -0
  57. data/spec/logstash/output_delegator_spec.rb +2 -0
  58. data/spec/logstash/pipeline_reporter_spec.rb +5 -1
  59. data/spec/logstash/pipeline_spec.rb +75 -30
  60. data/spec/logstash/plugin_spec.rb +2 -2
  61. data/spec/logstash/runner_spec.rb +112 -25
  62. data/spec/logstash/setting_spec.rb +130 -0
  63. data/spec/logstash/settings_spec.rb +62 -0
  64. metadata +37 -43
  65. data/lib/logstash/api/init.ru +0 -31
  66. data/lib/logstash/api/lib/app.rb +0 -40
  67. data/lib/logstash/api/lib/app/command.rb +0 -29
  68. data/lib/logstash/api/lib/app/command_factory.rb +0 -29
  69. data/lib/logstash/api/lib/app/commands/stats/events_command.rb +0 -13
  70. data/lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb +0 -120
  71. data/lib/logstash/api/lib/app/commands/stats/memory_command.rb +0 -25
  72. data/lib/logstash/api/lib/app/commands/system/basicinfo_command.rb +0 -15
  73. data/lib/logstash/api/lib/app/commands/system/plugins_command.rb +0 -28
  74. data/lib/logstash/api/lib/app/modules/node.rb +0 -25
  75. data/lib/logstash/api/lib/app/modules/node_stats.rb +0 -51
  76. data/lib/logstash/api/lib/app/modules/plugins.rb +0 -15
  77. data/lib/logstash/api/lib/app/modules/stats.rb +0 -21
  78. data/lib/logstash/api/lib/app/root.rb +0 -13
  79. data/lib/logstash/api/lib/app/service.rb +0 -61
  80. data/lib/logstash/api/lib/app/stats.rb +0 -56
  81. data/lib/logstash/util/defaults_printer.rb +0 -31
  82. data/spec/api/lib/api/stats_spec.rb +0 -19
  83. data/spec/api/lib/commands/events_spec.rb +0 -17
  84. data/spec/api/lib/commands/jvm_spec.rb +0 -45
  85. data/spec/logstash/util/defaults_printer_spec.rb +0 -50
  86. data/spec/logstash/util/worker_threads_default_printer_spec.rb +0 -45
data/locales/en.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # YAML notes
2
2
  # |- means 'scalar block' useful for formatted text
3
- # > means 'scalar block' but it chomps all newlines. Useful
3
+ # > means 'scalar block' but it chomps all newlines. Useful
4
4
  # for unformatted text.
5
5
  en:
6
6
  oops: |-
@@ -71,16 +71,12 @@ en:
71
71
  non_reloadable_config_reload: >-
72
72
  Unable to reload configuration because it does not support dynamic reloading
73
73
  non_reloadable_config_register: |-
74
- Logstash was not able to load configuration since it does not support
75
- dynamic reloading and -r or --auto-reload flag was enabled
74
+ Logstash is not able to start since configuration auto reloading was enabled but the configuration contains plugins that don't support it. Quitting...
76
75
  web_api:
77
- flag:
78
- http_host: Web API binding host
79
- http_port: Web API http port
80
76
  hot_threads:
81
77
  title: |-
82
78
  ::: {%{hostname}}
83
- Hot threads at %{time}, busiestThreads=%{top_count}:
79
+ Hot threads at %{time}, busiestThreads=%{top_count}:
84
80
  thread_title: |-
85
81
  %{percent_of_cpu_time} % of cpu usage by %{thread_state} thread named '%{thread_name}'
86
82
  runner:
@@ -145,18 +141,18 @@ en:
145
141
  after %{after}
146
142
  invalid_plugin_register: >-
147
143
  Cannot register %{plugin} %{type} plugin.
148
- The error reported is:
144
+ The error reported is:
149
145
  %{error}
150
146
  plugin_path_missing: >-
151
147
  You specified a plugin path that does not exist: %{path}
152
148
  no_plugins_found: |-
153
149
  Could not find any plugins in "%{path}"
154
- I tried to find files matching the following, but found none:
150
+ I tried to find files matching the following, but found none:
155
151
  %{plugin_glob}
156
152
  log_file_failed: |-
157
153
  Failed to open %{path} for writing: %{error}
158
154
 
159
- This is often a permissions issue, or the wrong
155
+ This is often a permissions issue, or the wrong
160
156
  path was specified?
161
157
  flag:
162
158
  # Note: Wrap these at 55 chars so they display nicely when clamp emits
@@ -182,10 +178,8 @@ en:
182
178
  the empty string for the '-e' flag.
183
179
  configtest: |+
184
180
  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".
181
+ http_host: Web API binding host
182
+ http_port: Web API http port
189
183
  pipeline-workers: |+
190
184
  Sets the number of pipeline workers to run.
191
185
  pipeline-batch-size: |+
@@ -193,6 +187,9 @@ en:
193
187
  pipeline-batch-delay: |+
194
188
  When creating pipeline batches, how long to wait while polling
195
189
  for the next event.
190
+ path_settings: |+
191
+ Directory containing logstash.yml file. This can also be
192
+ set through the LS_SETTINGS_DIR environment variable.
196
193
  auto_reload: |+
197
194
  Monitor configuration changes and reload
198
195
  whenever it is changed.
@@ -221,15 +218,12 @@ en:
221
218
  'PATH/logstash/TYPE/NAME.rb' where TYPE is
222
219
  'inputs' 'filters', 'outputs' or 'codecs'
223
220
  and NAME is the name of the plugin.
224
- quiet: |+
225
- Quieter logstash logging. This causes only
226
- errors to be emitted.
227
- verbose: |+
228
- More verbose logging. This causes 'info'
229
- level logs to be emitted.
230
- debug: |+
231
- Most verbose logging. This causes 'debug'
232
- level logs to be emitted.
221
+ log_level: |+
222
+ Set the log level for logstash. Possible values are:
223
+ - quiet => :error
224
+ - verbose => :info
225
+ - debug => :debug
226
+ - warn => :warn
233
227
  unsafe_shutdown: |+
234
228
  Force logstash to exit during shutdown even
235
229
  if there are still inflight events in memory.
@@ -243,7 +237,10 @@ en:
243
237
  it will default to the current hostname.
244
238
  agent: |+
245
239
  Specify an alternate agent plugin name.
246
- debug_config: |+
240
+ config_debug: |+
247
241
  Print the compiled config ruby code out as a debug log (you must also have --debug enabled).
248
242
  WARNING: This will include any 'password' options passed to plugin configs as plaintext, and may result
249
- in plaintext passwords appearing in your logs!
243
+ in plaintext passwords appearing in your logs!
244
+ log_format: |+
245
+ Specify if Logstash should write its own logs in JSON form (one
246
+ event per line) or in plain text (using Ruby's Object#inspect)
@@ -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.alpha2.snapshot2"
20
+ gem.add_runtime_dependency "logstash-core-event-java", "5.0.0.alpha3"
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)
@@ -27,10 +27,10 @@ Gem::Specification.new do |gem|
27
27
  gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license)
28
28
  gem.add_runtime_dependency "concurrent-ruby", "1.0.0"
29
29
  gem.add_runtime_dependency "sinatra", '~> 1.4', '>= 1.4.6'
30
- gem.add_runtime_dependency 'puma', '~> 2.16', '>= 2.16.0'
30
+ gem.add_runtime_dependency 'puma', '~> 2.16'
31
31
  gem.add_runtime_dependency "jruby-openssl", "0.9.16" # >= 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.3.1'
33
+ gem.add_runtime_dependency "jrmonitor", '~> 0.4.2'
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
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/modules/node"
4
+ require "logstash/api/modules/node"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::Node do
7
+ describe LogStash::Api::Modules::Node do
8
8
 
9
9
  include Rack::Test::Methods
10
10
 
@@ -1,68 +1,43 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/modules/node_stats"
4
+ require "logstash/api/modules/node_stats"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::NodeStats do
8
-
7
+ describe LogStash::Api::Modules::NodeStats do
9
8
  include Rack::Test::Methods
9
+ extend ResourceDSLMethods
10
10
 
11
- def app()
11
+ def app() # Used by Rack::Test::Methods
12
12
  described_class
13
13
  end
14
14
 
15
- let(:payload) { LogStash::Json.load(last_response.body) }
16
-
17
- context "#root" do
18
-
19
- before(:all) do
20
- do_request { get "/" }
21
- end
22
-
23
- it "respond OK" do
24
- expect(last_response).to be_ok
25
- end
26
-
27
- ["events", "jvm"].each do |key|
28
- it "contains #{key} information" do
29
- expect(payload).to include(key)
30
- end
31
- end
32
- end
33
-
34
- context "#events" do
35
-
36
- let(:payload) { LogStash::Json.load(last_response.body) }
37
-
38
- before(:all) do
39
- do_request { get "/events" }
40
- end
41
-
42
- it "respond OK" do
43
- expect(last_response).to be_ok
44
- end
45
-
46
- it "contains events information" do
47
- expect(payload).to include("events")
48
- end
49
- end
50
-
51
- context "#jvm" do
52
-
53
- let(:payload) { LogStash::Json.load(last_response.body) }
54
-
55
- before(:all) do
56
- do_request { get "/jvm" }
57
- end
58
-
59
- it "respond OK" do
60
- expect(last_response).to be_ok
61
- end
62
-
63
- it "contains memory information" do
64
- expect(payload).to include("mem")
65
- end
66
- end
67
-
15
+ # DSL describing response structure
16
+ root_structure = {
17
+ "events"=>{
18
+ "in"=>Numeric,
19
+ "filtered"=>Numeric,
20
+ "out"=>Numeric
21
+ },
22
+ "jvm"=>{
23
+ "threads"=>{
24
+ "count"=>Numeric,
25
+ "peak_count"=>Numeric
26
+ }
27
+ },
28
+ "process"=>{
29
+ "peak_open_file_descriptors"=>Numeric,
30
+ "max_file_descriptors"=>Numeric,
31
+ "open_file_descriptors"=>Numeric,
32
+ "mem"=>{
33
+ "total_virtual_in_bytes"=>Numeric
34
+ },
35
+ "cpu"=>{
36
+ "total_in_millis"=>Numeric,
37
+ "percent"=>Numeric
38
+ }
39
+ }
40
+ }
41
+
42
+ test_api_and_resources(root_structure)
68
43
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/modules/plugins"
4
+ require "logstash/api/modules/plugins"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::Plugins do
7
+ describe LogStash::Api::Modules::Plugins do
8
8
 
9
9
  include Rack::Test::Methods
10
10
 
@@ -23,7 +23,7 @@ describe LogStash::Api::Plugins do
23
23
  end
24
24
 
25
25
  it "return valid json content type" do
26
- expect(last_response.content_type).to eq("application/json")
26
+ expect(last_response.content_type).to eq("application/json"), "Did not get json, got #{last_response.content_type} / #{last_response.body}"
27
27
  end
28
28
 
29
29
  context "#schema" do
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/root"
4
+ require "logstash/api/modules/root"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::Root do
7
+ describe LogStash::Api::Modules::Root do
8
8
 
9
9
  include Rack::Test::Methods
10
10
 
@@ -0,0 +1,47 @@
1
+ module ResourceDSLMethods
2
+ # Convert a nested hash to a mapping of key paths to expected classes
3
+ def hash_to_mapping(h, path=[], mapping={})
4
+ h.each do |k,v|
5
+ if v.is_a?(Hash)
6
+ hash_to_mapping(v, path + [k], mapping)
7
+ else
8
+ full_path = path + [k]
9
+ mapping[full_path] = v
10
+ end
11
+ end
12
+ mapping
13
+ end
14
+
15
+ def test_api(expected, path)
16
+ context "GET #{path}" do
17
+ let(:payload) { LogStash::Json.load(last_response.body) }
18
+
19
+ before(:all) do
20
+ do_request { get path }
21
+ end
22
+
23
+ it "should respond OK" do
24
+ expect(last_response).to be_ok
25
+ end
26
+
27
+ hash_to_mapping(expected).each do |path,klass|
28
+ dotted = path.join(".")
29
+
30
+ it "should set '#{dotted}' to be a '#{klass}'" do
31
+ path_value = path.reduce(payload) {|acc,v| acc[v]}
32
+ expect(path_value).to be_a(klass), "could not find '#{dotted}' in #{payload}"
33
+ end
34
+ end
35
+ end
36
+
37
+ yield if block_given? # Add custom expectations
38
+ end
39
+
40
+ def test_api_and_resources(expected)
41
+ test_api(expected, "/")
42
+
43
+ expected.keys.each do |key|
44
+ test_api({key => expected[key]}, "/#{key}")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ require_relative "../../spec_helper"
3
+
4
+ describe LogStash::Api::Commands::Stats do
5
+
6
+ let(:report_method) { :run }
7
+ subject(:report) { do_request { report_class.new.send(report_method) } }
8
+
9
+ let(:report_class) { described_class }
10
+
11
+ describe "#events" do
12
+ let(:report_method) { :events }
13
+
14
+ it "return events information" do
15
+ expect(report.keys).to include(:in, :filtered, :out)
16
+ end
17
+ end
18
+
19
+ describe "#hot_threads" do
20
+ let(:report_method) { :hot_threads }
21
+
22
+ it "should return hot threads information as a string" do
23
+ expect(report.to_s).to be_a(String)
24
+ end
25
+
26
+ it "should return hot threads info as a hash" do
27
+ expect(report.to_hash).to be_a(Hash)
28
+ end
29
+ end
30
+
31
+ describe "memory stats" do
32
+ let(:report_method) { :memory }
33
+
34
+ it "return hot threads information" do
35
+ expect(report).not_to be_empty
36
+ end
37
+
38
+ it "return heap information" do
39
+ expect(report.keys).to include(:heap_used_in_bytes)
40
+ end
41
+
42
+ it "return non heap information" do
43
+ expect(report.keys).to include(:non_heap_used_in_bytes)
44
+ end
45
+
46
+ end
47
+ end
@@ -1,16 +1,18 @@
1
1
  # encoding: utf-8
2
2
  API_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "logstash", "api"))
3
3
 
4
+
5
+
4
6
  require "logstash/devutils/rspec/spec_helper"
5
7
 
8
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
9
+ require "lib/api/support/resource_dsl_methods"
10
+
11
+ require "logstash/settings"
6
12
  require 'rack/test'
7
13
  require 'rspec'
8
14
  require "json"
9
15
 
10
- ENV['RACK_ENV'] = 'test'
11
-
12
- Rack::Builder.parse_file(File.join(API_ROOT, 'init.ru'))
13
-
14
16
  def read_fixture(name)
15
17
  path = File.join(File.dirname(__FILE__), "fixtures", name)
16
18
  File.read(path)
@@ -37,26 +39,24 @@ class LogStashRunner
37
39
  attr_reader :config_str, :agent, :pipeline_settings
38
40
 
39
41
  def initialize
40
- args = [
41
- :logger => Cabin::Channel.get(LogStash),
42
- :auto_reload => false,
43
- :collect_metric => true,
44
- :debug => false,
45
- :node_name => "test_agent",
46
- :web_api_http_port => rand(9600..9700)
47
- ]
48
-
49
42
  @config_str = "input { generator {count => 0} } output { }"
50
- @agent = LogStash::DummyAgent.new(*args)
51
- @pipeline_settings ||= { :pipeline_id => "main",
52
- :config_str => config_str,
53
- :pipeline_batch_size => 1,
54
- :flush_interval => 1,
55
- :pipeline_workers => 1 }
43
+ args = {
44
+ "config.reload.automatic" => false,
45
+ "metric.collect" => true,
46
+ "log.level" => "debug",
47
+ "node.name" => "test_agent",
48
+ "http.port" => rand(9600..9700),
49
+ "config.string" => @config_str,
50
+ "pipeline.batch.size" => 1,
51
+ "pipeline.workers" => 1
52
+ }
53
+ @settings = ::LogStash::SETTINGS.clone.merge(args)
54
+
55
+ @agent = LogStash::DummyAgent.new(@settings)
56
56
  end
57
57
 
58
58
  def start
59
- agent.register_pipeline("main", pipeline_settings)
59
+ agent.register_pipeline("main", @settings)
60
60
  @runner = Thread.new(agent) do |_agent|
61
61
  _agent.execute
62
62
  end
@@ -81,7 +81,7 @@ end
81
81
 
82
82
  ##
83
83
  # Method used to wrap up a request in between of a running
84
- # pipeline, this makes the hole execution model easier and
84
+ # pipeline, this makes the whole execution model easier and
85
85
  # more contained as some threads might go wild.
86
86
  ##
87
87
  def do_request(&block)