logstash-core 5.0.0.alpha4.snapshot3-java → 5.0.0.alpha5.snapshot1-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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash/agent.rb +6 -2
  3. data/lib/logstash/api/app_helpers.rb +15 -0
  4. data/lib/logstash/api/command_factory.rb +3 -1
  5. data/lib/logstash/api/commands/base.rb +3 -5
  6. data/lib/logstash/api/commands/default_metadata.rb +27 -0
  7. data/lib/logstash/api/commands/hot_threads_reporter.rb +61 -0
  8. data/lib/logstash/api/commands/node.rb +9 -63
  9. data/lib/logstash/api/commands/stats.rb +5 -61
  10. data/lib/logstash/api/commands/system/basicinfo_command.rb +3 -6
  11. data/lib/logstash/api/modules/base.rb +3 -1
  12. data/lib/logstash/api/modules/node.rb +8 -18
  13. data/lib/logstash/api/modules/node_stats.rb +5 -41
  14. data/lib/logstash/api/modules/stats.rb +13 -33
  15. data/lib/logstash/build.rb +6 -0
  16. data/lib/logstash/environment.rb +9 -0
  17. data/lib/logstash/filter_delegator.rb +1 -1
  18. data/lib/logstash/instrument/metric.rb +7 -6
  19. data/lib/logstash/instrument/metric_type/base.rb +1 -4
  20. data/lib/logstash/instrument/namespaced_metric.rb +1 -1
  21. data/lib/logstash/instrument/null_metric.rb +6 -1
  22. data/lib/logstash/output_delegator.rb +2 -0
  23. data/lib/logstash/pipeline.rb +62 -93
  24. data/lib/logstash/pipeline_reporter.rb +14 -13
  25. data/lib/logstash/plugin.rb +8 -2
  26. data/lib/logstash/runner.rb +7 -1
  27. data/lib/logstash/settings.rb +17 -7
  28. data/lib/logstash/util/wrapped_synchronous_queue.rb +220 -0
  29. data/lib/logstash/version.rb +1 -1
  30. data/lib/logstash/webserver.rb +4 -0
  31. data/lib/logstash-core/version.rb +1 -1
  32. data/locales/en.yml +4 -0
  33. data/logstash-core.gemspec +2 -2
  34. data/spec/api/lib/api/node_spec.rb +0 -1
  35. data/spec/api/lib/api/node_stats_spec.rb +36 -34
  36. data/spec/api/lib/api/support/resource_dsl_methods.rb +15 -0
  37. data/spec/api/spec_helper.rb +5 -2
  38. data/spec/logstash/inputs/metrics_spec.rb +1 -1
  39. data/spec/logstash/instrument/metric_type/counter_spec.rb +1 -6
  40. data/spec/logstash/instrument/metric_type/gauge_spec.rb +1 -4
  41. data/spec/logstash/instrument/namespaced_metric_spec.rb +61 -2
  42. data/spec/logstash/instrument/null_metric_spec.rb +7 -9
  43. data/spec/logstash/pipeline_spec.rb +7 -7
  44. data/spec/logstash/plugin_spec.rb +73 -0
  45. data/spec/logstash/settings/string_spec.rb +21 -0
  46. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +70 -22
  47. data/spec/support/shared_examples.rb +98 -0
  48. metadata +11 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c90549a9a03e8d32ee0eb8146780ad53609abc84
4
- data.tar.gz: 14e872af82cfa7cb8dbfc1b5bbce6e8fcd4e8031
3
+ metadata.gz: 31b35e84fcbac8fa8ccb7ac01aac834645c04084
4
+ data.tar.gz: 3c5d884562c45235f897279458b3e0ee8a840d4b
5
5
  SHA512:
6
- metadata.gz: c666d73e6f87dd8de677888232066d807a2878105a40c023ad0a9d9f221eb9fea16ddf8694a3cd692c816ae92537c23a034e54162c71505990b53ba7a710b7d8
7
- data.tar.gz: 45d360a8b9896e2ff744d0e84efce8126c33d5c4c6ce1d71a8fdbf89a61ee6940a2a80843cb7613d3eaa8baab677bf7c717009ac93a7c55b559678c840cc37f1
6
+ metadata.gz: 2355f8393a9f37222e45f7698fdb2b3cf10be0a52cfb132a3bbaf546dadf11e05f4c2b8f60a216409b5bed7b49eba79803270dbac561217a0e36ac107e2348b2
7
+ data.tar.gz: 5642f18d54cfb80d5b159575f1ba59b652ec2d57606a5609bda4644740367d7f82187718728c9ccc6854d944291855ec48f54d66b957e3e6e736c52d9c2b9339
@@ -20,7 +20,7 @@ LogStash::Environment.load_locale!
20
20
  class LogStash::Agent
21
21
  STARTED_AT = Time.now.freeze
22
22
 
23
- attr_reader :metric, :node_name, :pipelines, :settings
23
+ attr_reader :metric, :node_name, :pipelines, :settings, :webserver
24
24
  attr_accessor :logger
25
25
 
26
26
  # initialize method for LogStash::Agent
@@ -184,7 +184,11 @@ class LogStash::Agent
184
184
  begin
185
185
  LogStash::Pipeline.new(config, settings, metric)
186
186
  rescue => e
187
- @logger.error("fetched an invalid config", :config => config, :reason => e.message)
187
+ if @logger.debug?
188
+ @logger.error("fetched an invalid config", :config => config, :reason => e.message, :backtrace => e.backtrace)
189
+ else
190
+ @logger.error("fetched an invalid config", :config => config, :reason => e.message)
191
+ end
188
192
  return
189
193
  end
190
194
  end
@@ -5,8 +5,15 @@ module LogStash::Api::AppHelpers
5
5
 
6
6
  def respond_with(data, options={})
7
7
  as = options.fetch(:as, :json)
8
+ filter = options.fetch(:filter, "")
8
9
  pretty = params.has_key?("pretty")
10
+
9
11
  if as == :json
12
+ selected_fields = extract_fields(filter.to_s.strip)
13
+ data.select! { |k,v| selected_fields.include?(k) } unless selected_fields.empty?
14
+ unless options.include?(:exclude_default_metadata)
15
+ data = default_metadata.merge(data)
16
+ end
10
17
  content_type "application/json"
11
18
  LogStash::Json.dump(data, {:pretty => pretty})
12
19
  else
@@ -15,9 +22,17 @@ module LogStash::Api::AppHelpers
15
22
  end
16
23
  end
17
24
 
25
+ def extract_fields(filter_string)
26
+ (filter_string.empty? ? [] : filter_string.split(",").map { |s| s.strip.to_sym })
27
+ end
28
+
18
29
  def as_boolean(string)
19
30
  return true if string == true || string =~ (/(true|t|yes|y|1)$/i)
20
31
  return false if string == false || string.blank? || string =~ (/(false|f|no|n|0)$/i)
21
32
  raise ArgumentError.new("invalid value for Boolean: \"#{string}\"")
22
33
  end
34
+
35
+ def default_metadata
36
+ @factory.build(:default_metadata).all
37
+ end
23
38
  end
@@ -4,6 +4,7 @@ require "logstash/api/commands/system/basicinfo_command"
4
4
  require "logstash/api/commands/system/plugins_command"
5
5
  require "logstash/api/commands/stats"
6
6
  require "logstash/api/commands/node"
7
+ require "logstash/api/commands/default_metadata"
7
8
 
8
9
 
9
10
  module LogStash
@@ -17,7 +18,8 @@ module LogStash
17
18
  :system_basic_info => ::LogStash::Api::Commands::System::BasicInfo,
18
19
  :plugins_command => ::LogStash::Api::Commands::System::Plugins,
19
20
  :stats => ::LogStash::Api::Commands::Stats,
20
- :node => ::LogStash::Api::Commands::Node
21
+ :node => ::LogStash::Api::Commands::Node,
22
+ :default_metadata => ::LogStash::Api::Commands::DefaultMetadata
21
23
  }
22
24
  end
23
25
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module LogStash
2
4
  module Api
3
5
  module Commands
@@ -8,14 +10,10 @@ module LogStash
8
10
  @service = service
9
11
  end
10
12
 
11
- def hostname
12
- service.agent.node_name
13
- end
14
-
15
13
  def uptime
16
14
  service.agent.uptime
17
15
  end
18
-
16
+
19
17
  def started_at
20
18
  (LogStash::Agent::STARTED_AT.to_f * 1000.0).to_i
21
19
  end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ require "logstash/api/commands/base"
4
+
5
+ module LogStash
6
+ module Api
7
+ module Commands
8
+ class DefaultMetadata < Commands::Base
9
+ def all
10
+ {:host => host, :version => version, :http_address => http_address}
11
+ end
12
+
13
+ def host
14
+ Socket.gethostname
15
+ end
16
+
17
+ def version
18
+ LOGSTASH_CORE_VERSION
19
+ end
20
+
21
+ def http_address
22
+ service.agent.webserver.address
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ class HotThreadsReport
4
+ HOT_THREADS_STACK_TRACES_SIZE_DEFAULT = 10.freeze
5
+
6
+ def initialize(cmd, options)
7
+ @cmd = cmd
8
+ filter = { :stacktrace_size => options.fetch(:stacktrace_size, HOT_THREADS_STACK_TRACES_SIZE_DEFAULT) }
9
+ jr_dump = JRMonitor.threads.generate(filter)
10
+ @thread_dump = ::LogStash::Util::ThreadDump.new(options.merge(:dump => jr_dump))
11
+ end
12
+
13
+ def to_s
14
+ hash = to_hash[:hot_threads]
15
+ report = "#{I18n.t("logstash.web_api.hot_threads.title", :hostname => hash[:hostname], :time => hash[:time], :top_count => @thread_dump.top_count )} \n"
16
+ report << '=' * 80
17
+ report << "\n"
18
+ hash[:threads].each do |thread|
19
+ thread_report = ""
20
+ thread_report = "#{I18n.t("logstash.web_api.
21
+ hot_threads.thread_title", :percent_of_cpu_time => thread[:percent_of_cpu_time], :thread_state => thread[:state], :thread_name => thread[:name])} \n"
22
+ thread_report = "#{thread[:percent_of_cpu_time]} % of of cpu usage by #{thread[:state]} thread named '#{thread[:name]}'\n"
23
+ thread_report << "#{thread[:path]}\n" if thread[:path]
24
+ thread[:traces].each do |trace|
25
+ thread_report << "\t#{trace}\n"
26
+ end
27
+ report << thread_report
28
+ report << '-' * 80
29
+ report << "\n"
30
+ end
31
+ report
32
+ end
33
+
34
+ def to_hash
35
+ hash = { :time => Time.now.iso8601, :busiest_threads => @thread_dump.top_count, :threads => [] }
36
+ @thread_dump.each do |thread_name, _hash|
37
+ thread_name, thread_path = _hash["thread.name"].split(": ")
38
+ thread = { :name => thread_name,
39
+ :percent_of_cpu_time => cpu_time_as_percent(_hash),
40
+ :state => _hash["thread.state"]
41
+ }
42
+ thread[:path] = thread_path if thread_path
43
+ traces = []
44
+ _hash["thread.stacktrace"].each do |trace|
45
+ traces << trace
46
+ end
47
+ thread[:traces] = traces unless traces.empty?
48
+ hash[:threads] << thread
49
+ end
50
+ { :hot_threads => hash }
51
+ end
52
+
53
+ def cpu_time_as_percent(hash)
54
+ (((cpu_time(hash) / @cmd.uptime * 1.0)*10000).to_i)/100.0
55
+ end
56
+
57
+ def cpu_time(hash)
58
+ hash["cpu.time"] / 1000000.0
59
+ end
60
+
61
+ end
@@ -1,17 +1,22 @@
1
+ # encoding: utf-8
1
2
  require "logstash/api/commands/base"
3
+ require_relative "hot_threads_reporter"
2
4
 
3
5
  module LogStash
4
6
  module Api
5
7
  module Commands
6
8
  class Node < Commands::Base
7
- def all
8
- {
9
+
10
+ def all(selected_fields=[])
11
+ payload = {
9
12
  :pipeline => pipeline,
10
13
  :os => os,
11
14
  :jvm => jvm
12
- }
15
+ }
16
+ payload.select! { |k,v| selected_fields.include?(k) } unless selected_fields.empty?
17
+ payload
13
18
  end
14
-
19
+
15
20
  def pipeline
16
21
  extract_metrics(
17
22
  [:stats, :pipelines, :main, :config],
@@ -51,65 +56,6 @@ module LogStash
51
56
  HotThreadsReport.new(self, options)
52
57
  end
53
58
 
54
- class HotThreadsReport
55
- HOT_THREADS_STACK_TRACES_SIZE_DEFAULT = 10.freeze
56
-
57
- def initialize(cmd, options)
58
- @cmd = cmd
59
- filter = { :stacktrace_size => options.fetch(:stacktrace_size, HOT_THREADS_STACK_TRACES_SIZE_DEFAULT) }
60
- jr_dump = JRMonitor.threads.generate(filter)
61
- @thread_dump = ::LogStash::Util::ThreadDump.new(options.merge(:dump => jr_dump))
62
- end
63
-
64
- def to_s
65
- hash = to_hash
66
- report = "#{I18n.t("logstash.web_api.hot_threads.title", :hostname => hash[:hostname], :time => hash[:time], :top_count => @thread_dump.top_count )} \n"
67
- report << '=' * 80
68
- report << "\n"
69
- hash[:threads].each do |thread|
70
- thread_report = ""
71
- thread_report = "#{I18n.t("logstash.web_api.
72
- hot_threads.thread_title", :percent_of_cpu_time => thread[:percent_of_cpu_time], :thread_state => thread[:state], :thread_name => thread[:name])} \n"
73
- thread_report = "#{thread[:percent_of_cpu_time]} % of of cpu usage by #{thread[:state]} thread named '#{thread[:name]}'\n"
74
- thread_report << "#{thread[:path]}\n" if thread[:path]
75
- thread[:traces].each do |trace|
76
- thread_report << "\t#{trace}\n"
77
- end
78
- report << thread_report
79
- report << '-' * 80
80
- report << "\n"
81
- end
82
- report
83
- end
84
-
85
- def to_hash
86
- hash = { :hostname => @cmd.hostname, :time => Time.now.iso8601, :busiest_threads => @thread_dump.top_count, :threads => [] }
87
- @thread_dump.each do |thread_name, _hash|
88
- thread_name, thread_path = _hash["thread.name"].split(": ")
89
- thread = { :name => thread_name,
90
- :percent_of_cpu_time => cpu_time_as_percent(_hash),
91
- :state => _hash["thread.state"]
92
- }
93
- thread[:path] = thread_path if thread_path
94
- traces = []
95
- _hash["thread.stacktrace"].each do |trace|
96
- traces << trace
97
- end
98
- thread[:traces] = traces unless traces.empty?
99
- hash[:threads] << thread
100
- end
101
- hash
102
- end
103
-
104
- def cpu_time_as_percent(hash)
105
- (((cpu_time(hash) / @cmd.uptime * 1.0)*10000).to_i)/100.0
106
- end
107
-
108
- def cpu_time(hash)
109
- hash["cpu.time"] / 1000000.0
110
- end
111
-
112
- end
113
59
  end
114
60
  end
115
61
  end
@@ -1,5 +1,7 @@
1
+ # encoding: utf-8
1
2
  require "logstash/api/commands/base"
2
3
  require 'logstash/util/thread_dump'
4
+ require_relative "hot_threads_reporter"
3
5
 
4
6
  module LogStash
5
7
  module Api
@@ -11,7 +13,8 @@ module LogStash
11
13
  [:jvm, :threads],
12
14
  :count,
13
15
  :peak_count
14
- )
16
+ ),
17
+ :mem => memory
15
18
  }
16
19
  end
17
20
 
@@ -60,65 +63,6 @@ module LogStash
60
63
  HotThreadsReport.new(self, options)
61
64
  end
62
65
 
63
- class HotThreadsReport
64
- HOT_THREADS_STACK_TRACES_SIZE_DEFAULT = 10.freeze
65
-
66
- def initialize(cmd, options)
67
- @cmd = cmd
68
- filter = { :stacktrace_size => options.fetch(:stacktrace_size, HOT_THREADS_STACK_TRACES_SIZE_DEFAULT) }
69
- jr_dump = JRMonitor.threads.generate(filter)
70
- @thread_dump = ::LogStash::Util::ThreadDump.new(options.merge(:dump => jr_dump))
71
- end
72
-
73
- def to_s
74
- hash = to_hash
75
- report = "#{I18n.t("logstash.web_api.hot_threads.title", :hostname => hash[:hostname], :time => hash[:time], :top_count => @thread_dump.top_count )} \n"
76
- report << '=' * 80
77
- report << "\n"
78
- hash[:threads].each do |thread|
79
- thread_report = ""
80
- thread_report = "#{I18n.t("logstash.web_api.
81
- hot_threads.thread_title", :percent_of_cpu_time => thread[:percent_of_cpu_time], :thread_state => thread[:state], :thread_name => thread[:name])} \n"
82
- thread_report = "#{thread[:percent_of_cpu_time]} % of of cpu usage by #{thread[:state]} thread named '#{thread[:name]}'\n"
83
- thread_report << "#{thread[:path]}\n" if thread[:path]
84
- thread[:traces].each do |trace|
85
- thread_report << "\t#{trace}\n"
86
- end
87
- report << thread_report
88
- report << '-' * 80
89
- report << "\n"
90
- end
91
- report
92
- end
93
-
94
- def to_hash
95
- hash = { :hostname => @cmd.hostname, :time => Time.now.iso8601, :busiest_threads => @thread_dump.top_count, :threads => [] }
96
- @thread_dump.each do |thread_name, _hash|
97
- thread_name, thread_path = _hash["thread.name"].split(": ")
98
- thread = { :name => thread_name,
99
- :percent_of_cpu_time => cpu_time_as_percent(_hash),
100
- :state => _hash["thread.state"]
101
- }
102
- thread[:path] = thread_path if thread_path
103
- traces = []
104
- _hash["thread.stacktrace"].each do |trace|
105
- traces << trace
106
- end
107
- thread[:traces] = traces unless traces.empty?
108
- hash[:threads] << thread
109
- end
110
- hash
111
- end
112
-
113
- def cpu_time_as_percent(hash)
114
- (((cpu_time(hash) / @cmd.uptime * 1.0)*10000).to_i)/100.0
115
- end
116
-
117
- def cpu_time(hash)
118
- hash["cpu.time"] / 1000000.0
119
- end
120
- end # class HotThreadsReport
121
-
122
66
  module PluginsStats
123
67
  module_function
124
68
 
@@ -138,7 +82,7 @@ module LogStash
138
82
 
139
83
  {
140
84
  :events => stats[:events],
141
- :pipeline => {
85
+ :plugins => {
142
86
  :inputs => plugin_stats(stats, :inputs),
143
87
  :filters => plugin_stats(stats, :filters),
144
88
  :outputs => plugin_stats(stats, :outputs)
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'logstash/api/commands/base'
3
3
  require "logstash/util/duration_formatter"
4
+ require 'logstash/build'
4
5
 
5
6
  module LogStash
6
7
  module Api
@@ -9,12 +10,8 @@ module LogStash
9
10
  class BasicInfo < Commands::Base
10
11
 
11
12
  def run
12
- {
13
- "hostname" => hostname,
14
- "version" => {
15
- "number" => LOGSTASH_VERSION
16
- }
17
- }
13
+ # Just merge this stuff with the defaults
14
+ BUILD_INFO
18
15
  end
19
16
  end
20
17
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require "logstash/api/app_helpers"
2
3
  require "logstash/api/command_factory"
3
4
 
@@ -15,7 +16,7 @@ module LogStash
15
16
  set :raise_errors, true
16
17
  set :show_exceptions, false
17
18
 
18
- attr_reader :factory
19
+ attr_reader :factory, :agent
19
20
 
20
21
  include LogStash::Util::Loggable
21
22
 
@@ -23,6 +24,7 @@ module LogStash
23
24
 
24
25
  def initialize(app=nil, agent)
25
26
  super(app)
27
+ @agent = agent
26
28
  @factory = ::LogStash::Api::CommandFactory.new(LogStash::Api::Service.new(agent))
27
29
  end
28
30
 
@@ -8,23 +8,7 @@ module LogStash
8
8
  def node
9
9
  factory.build(:node)
10
10
  end
11
-
12
- get "/" do
13
- respond_with node.all
14
- end
15
-
16
- get "/os" do
17
- respond_with :os => node.os
18
- end
19
-
20
- get "/jvm" do
21
- respond_with :jvm => node.jvm
22
- end
23
11
 
24
- get "/pipeline" do
25
- respond_with :pipeline => node.pipeline
26
- end
27
-
28
12
  get "/hot_threads" do
29
13
  ignore_idle_threads = params["ignore_idle_threads"] || true
30
14
 
@@ -35,8 +19,14 @@ module LogStash
35
19
  options[:threads] = params["threads"].to_i if params.has_key?("threads")
36
20
 
37
21
  as = options[:human] ? :string : :json
38
- respond_with({:hot_threads => node.hot_threads(options)}, {:as => as})
39
- end
22
+ respond_with(node.hot_threads(options), {:as => as})
23
+ end
24
+
25
+ get "/?:filter?" do
26
+ selected_fields = extract_fields(params["filter"].to_s.strip)
27
+ respond_with node.all(selected_fields)
28
+ end
29
+
40
30
  end
41
31
  end
42
32
  end
@@ -3,55 +3,19 @@ module LogStash
3
3
  module Api
4
4
  module Modules
5
5
  class NodeStats < ::LogStash::Api::Modules::Base
6
- #set :environment, :test
7
- #set :dump_errors, true
8
- #set :raise_errors, true
9
- #set :logging, Logger.new(STDERR)
10
-
11
-
6
+
12
7
  before do
13
8
  @stats = factory.build(:stats)
14
9
  end
15
10
 
16
- # Global _stats resource where all information is
17
- # retrieved and show
18
- get "/" do
11
+ get "/?:filter?" do
19
12
  payload = {
20
- :events => events_payload,
21
13
  :jvm => jvm_payload,
22
14
  :process => process_payload,
23
- :mem => mem_payload
15
+ :mem => mem_payload,
16
+ :pipeline => pipeline_payload
24
17
  }
25
-
26
- respond_with payload
27
- end
28
-
29
- # Show all events stats information
30
- # (for ingested, emitted, dropped)
31
- # - #events since startup
32
- # - #data (bytes) since startup
33
- # - events/s
34
- # - bytes/s
35
- # - dropped events/s
36
- # - events in the pipeline
37
- get "/events" do
38
- respond_with({ :events => events_payload })
39
- end
40
-
41
- get "/jvm" do
42
- respond_with :jvm => jvm_payload
43
- end
44
-
45
- get "/process" do
46
- respond_with :process => process_payload
47
- end
48
-
49
- get "/mem" do
50
- respond_with :mem => mem_payload
51
- end
52
-
53
- get "/pipeline" do
54
- respond_with :pipeline => pipeline_payload
18
+ respond_with(payload, {:filter => params["filter"]})
55
19
  end
56
20
 
57
21
  private
@@ -8,39 +8,6 @@ module LogStash
8
8
  factory.build(:stats)
9
9
  end
10
10
 
11
- # Global _stats resource where all information is
12
- # retrieved and show
13
- get "/" do
14
- payload = {
15
- :events => stats_command.events,
16
- :jvm => { :memory => stats_command.memory }
17
- }
18
- respond_with payload
19
- end
20
-
21
-
22
- # return hot threads information
23
- get "/jvm" do
24
- jvm_payload = {
25
- :timestamp => stats_command.started_at,
26
- :uptime_in_millis => stats_command.uptime,
27
- :mem => stats_command.memory
28
- }
29
- respond_with({:jvm => jvm_payload})
30
- end
31
-
32
- # Show all events stats information
33
- # (for ingested, emitted, dropped)
34
- # - #events since startup
35
- # - #data (bytes) since startup
36
- # - events/s
37
- # - bytes/s
38
- # - dropped events/s
39
- # - events in the pipeline
40
- get "/events" do
41
- respond_with({ :events => stats_command.events })
42
- end
43
-
44
11
  # return hot threads information
45
12
  get "/jvm/hot_threads" do
46
13
  top_threads_count = params["threads"] || 3
@@ -57,6 +24,19 @@ module LogStash
57
24
  get "/jvm/memory" do
58
25
  respond_with({ :memory => stats_command.memory })
59
26
  end
27
+
28
+ get "/?:filter?" do
29
+ payload = {
30
+ :events => stats_command.events,
31
+ :jvm => {
32
+ :timestamp => stats_command.started_at,
33
+ :uptime_in_millis => stats_command.uptime,
34
+ :memory => stats_command.memory
35
+ }
36
+ }
37
+ respond_with(payload, {:filter => params["filter"]})
38
+ end
39
+
60
40
  end
61
41
  end
62
42
  end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ # DO NOT EDIT
4
+ # this file acts as a placeholder for build information when executing
5
+ # logstash in dev mode (outside of a package build)
6
+ BUILD_INFO = {}
@@ -3,12 +3,21 @@ require "logstash/errors"
3
3
  require "logstash/config/cpu_core_strategy"
4
4
  require "logstash/settings"
5
5
  require "socket"
6
+ require "stud/temporary"
6
7
 
7
8
  module LogStash
9
+ # In the event that we're requiring this file without bootstrap/environment.rb
10
+ if !defined?(LogStash::Environment::LOGSTASH_HOME)
11
+ module Environment
12
+ LOGSTASH_HOME = Stud::Temporary.directory("logstash-home")
13
+ Dir.mkdir(::File.join(LOGSTASH_HOME, "data"))
14
+ end
15
+ end
8
16
 
9
17
  [
10
18
  Setting::String.new("node.name", Socket.gethostname),
11
19
  Setting::String.new("path.config", nil, false),
20
+ Setting::WritableDirectory.new("path.data", ::File.join(LogStash::Environment::LOGSTASH_HOME, "data")),
12
21
  Setting::String.new("config.string", nil, false),
13
22
  Setting::Boolean.new("config.test_and_exit", false),
14
23
  Setting::Boolean.new("config.reload.automatic", false),
@@ -22,7 +22,7 @@ module LogStash
22
22
 
23
23
  # Scope the metrics to the plugin
24
24
  namespaced_metric = metric.namespace(@filter.plugin_unique_name.to_sym)
25
- @filter.metric = metric
25
+ @filter.metric = namespaced_metric
26
26
 
27
27
  @metric_events = namespaced_metric.namespace(:events)
28
28
  namespaced_metric.gauge(:name, config_name)
@@ -18,22 +18,22 @@ module LogStash module Instrument
18
18
  end
19
19
 
20
20
  def increment(namespace, key, value = 1)
21
- validate_key!(key)
21
+ self.class.validate_key!(key)
22
22
  collector.push(namespace, key, :counter, :increment, value)
23
23
  end
24
24
 
25
25
  def decrement(namespace, key, value = 1)
26
- validate_key!(key)
26
+ self.class.validate_key!(key)
27
27
  collector.push(namespace, key, :counter, :decrement, value)
28
28
  end
29
29
 
30
30
  def gauge(namespace, key, value)
31
- validate_key!(key)
31
+ self.class.validate_key!(key)
32
32
  collector.push(namespace, key, :gauge, :set, value)
33
33
  end
34
34
 
35
35
  def time(namespace, key)
36
- validate_key!(key)
36
+ self.class.validate_key!(key)
37
37
 
38
38
  if block_given?
39
39
  timer = TimedExecution.new(self, namespace, key)
@@ -46,6 +46,7 @@ module LogStash module Instrument
46
46
  end
47
47
 
48
48
  def report_time(namespace, key, duration)
49
+ self.class.validate_key!(key)
49
50
  collector.push(namespace, key, :counter, :increment, duration)
50
51
  end
51
52
 
@@ -69,11 +70,11 @@ module LogStash module Instrument
69
70
  NamespacedMetric.new(self, name)
70
71
  end
71
72
 
72
- private
73
- def validate_key!(key)
73
+ def self.validate_key!(key)
74
74
  raise MetricNoKeyProvided if key.nil? || key.empty?
75
75
  end
76
76
 
77
+ private
77
78
  # Allow to calculate the execution of a block of code.
78
79
  # This class support 2 differents syntax a block or the return of
79
80
  # the object itself, but in the later case the metric wont be recorded