logstash-core 5.0.2-java → 5.1.1.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.
- checksums.yaml +4 -4
- data/gemspec_jars.rb +9 -0
- data/lib/logstash-core/logstash-core.jar +0 -0
- data/lib/logstash-core/logstash-core.rb +22 -0
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash-core_jars.rb +20 -0
- data/lib/logstash/agent.rb +65 -14
- data/lib/logstash/api/commands/default_metadata.rb +2 -1
- data/lib/logstash/api/commands/stats.rb +3 -2
- data/lib/logstash/config/file.rb +0 -1
- data/lib/logstash/config/loader.rb +1 -0
- data/lib/logstash/config/mixin.rb +2 -6
- data/lib/logstash/environment.rb +25 -2
- data/lib/logstash/event_dispatcher.rb +40 -0
- data/lib/logstash/filter_delegator.rb +1 -1
- data/lib/logstash/filters/base.rb +10 -2
- data/lib/logstash/instrument/metric_store.rb +0 -1
- data/lib/logstash/instrument/metric_type/base.rb +0 -1
- data/lib/logstash/instrument/namespaced_null_metric.rb +54 -0
- data/lib/logstash/instrument/null_metric.rb +55 -46
- data/lib/logstash/instrument/periodic_poller/jvm.rb +26 -3
- data/lib/logstash/instrument/periodic_poller/load_average.rb +47 -0
- data/lib/logstash/instrument/snapshot.rb +0 -1
- data/lib/logstash/java_integration.rb +0 -1
- data/lib/logstash/logging/logger.rb +37 -4
- data/lib/logstash/outputs/base.rb +1 -1
- data/lib/logstash/patches.rb +1 -0
- data/lib/logstash/patches/exception_to_json.rb +5 -0
- data/lib/logstash/pipeline.rb +50 -17
- data/lib/logstash/plugin.rb +14 -48
- data/lib/logstash/plugins/hooks_registry.rb +57 -0
- data/lib/logstash/plugins/registry.rb +208 -45
- data/lib/logstash/runner.rb +10 -5
- data/lib/logstash/settings.rb +101 -9
- data/lib/logstash/universal_plugin.rb +13 -0
- data/lib/logstash/util/byte_value.rb +60 -0
- data/lib/logstash/util/loggable.rb +14 -2
- data/lib/logstash/util/safe_uri.rb +1 -0
- data/lib/logstash/util/time_value.rb +70 -0
- data/lib/logstash/util/wrapped_acked_queue.rb +347 -0
- data/lib/logstash/util/wrapped_synchronous_queue.rb +17 -33
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +1 -1
- data/logstash-core.gemspec +13 -18
- data/spec/api/lib/api/node_stats_spec.rb +3 -1
- data/spec/api/lib/api/support/resource_dsl_methods.rb +14 -6
- data/spec/api/spec_helper.rb +1 -0
- data/spec/conditionals_spec.rb +3 -2
- data/spec/logstash/agent_spec.rb +142 -62
- data/spec/logstash/environment_spec.rb +38 -0
- data/spec/logstash/event_dispatcher_spec.rb +76 -0
- data/spec/logstash/filter_delegator_spec.rb +2 -1
- data/spec/logstash/instrument/namespaced_null_metric_spec.rb +33 -0
- data/spec/logstash/instrument/null_metric_spec.rb +9 -5
- data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +40 -0
- data/spec/logstash/instrument/periodic_poller/load_average_spec.rb +91 -0
- data/spec/logstash/output_delegator_spec.rb +2 -1
- data/spec/logstash/patches_spec.rb +15 -4
- data/spec/logstash/pipeline_pq_file_spec.rb +131 -0
- data/spec/logstash/pipeline_spec.rb +21 -17
- data/spec/logstash/plugin_spec.rb +4 -16
- data/spec/logstash/plugins/hooks_registry_spec.rb +60 -0
- data/spec/logstash/plugins/registry_spec.rb +22 -14
- data/spec/logstash/settings/bytes_spec.rb +53 -0
- data/spec/logstash/settings/time_value_spec.rb +31 -0
- data/spec/logstash/settings/writable_directory_spec.rb +125 -0
- data/spec/logstash/settings_spec.rb +39 -0
- data/spec/logstash/util/byte_value_spec.rb +33 -0
- data/spec/logstash/util/time_value_spec.rb +59 -0
- data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +2 -2
- data/spec/logstash/webserver_spec.rb +4 -7
- data/spec/support/helpers.rb +8 -0
- data/spec/support/mocks_classes.rb +61 -31
- metadata +73 -20
- data/lib/jars.rb +0 -7
- data/lib/logstash/config/registry.rb +0 -13
- data/lib/logstash/inputs/metrics.rb +0 -47
- data/spec/logstash/inputs/metrics_spec.rb +0 -51
- data/vendor/jars/com/fasterxml/jackson/core/jackson-core/2.7.4/jackson-core-2.7.4.jar +0 -0
- data/vendor/jars/com/fasterxml/jackson/core/jackson-databind/2.7.4/jackson-databind-2.7.4.jar +0 -0
- data/vendor/jars/org/apache/logging/log4j/log4j-1.2-api/2.6.2/log4j-1.2-api-2.6.2.jar +0 -0
- data/vendor/jars/org/apache/logging/log4j/log4j-api/2.6.2/log4j-api-2.6.2.jar +0 -0
- data/vendor/jars/org/apache/logging/log4j/log4j-core/2.6.2/log4j-core-2.6.2.jar +0 -0
- data/vendor/jars/org/logstash/logstash-core/5.0.2/logstash-core-5.0.2.jar +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1c528ad65660126cc95b61d32483ba720122505
|
|
4
|
+
data.tar.gz: ed0b7dbcd0d18786caa99f1eacc6b44cf6def997
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acd07b85def1d3754b60f147c5403a7cb624e0bee8a812dfffe7e6dc09ecb2b651d8a689f243a2efaec965b1a3b4a42eafe1f9d442dfa5626e9cc9ae3713ef90
|
|
7
|
+
data.tar.gz: 410e63863b1679c7c6be251b3a08f278cb990f77fc26e0fc2236e79a87eeb7a154553ded30876cf3983aa4d4b2c654592c9a889b4cffa8fb8978822f193a9716
|
data/gemspec_jars.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file is generated by Gradle as part of the build process. It extracts the build.gradle
|
|
2
|
+
# runtime dependencies to generate this gemspec dependencies file to be eval'ed by the gemspec
|
|
3
|
+
# for the jar-dependencies requirements.
|
|
4
|
+
|
|
5
|
+
gem.requirements << "jar org.apache.logging.log4j:log4j-1.2-api, 2.6.2"
|
|
6
|
+
gem.requirements << "jar org.apache.logging.log4j:log4j-api, 2.6.2"
|
|
7
|
+
gem.requirements << "jar org.apache.logging.log4j:log4j-core, 2.6.2"
|
|
8
|
+
gem.requirements << "jar com.fasterxml.jackson.core:jackson-core, 2.7.4"
|
|
9
|
+
gem.requirements << "jar com.fasterxml.jackson.core:jackson-databind, 2.7.4"
|
|
Binary file
|
|
@@ -1,3 +1,25 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require "java"
|
|
4
|
+
|
|
2
5
|
module LogStash
|
|
3
6
|
end
|
|
7
|
+
|
|
8
|
+
require "logstash-core_jars"
|
|
9
|
+
|
|
10
|
+
# local dev setup
|
|
11
|
+
classes_dir = File.expand_path("../../../build/classes/main", __FILE__)
|
|
12
|
+
resources_dir = File.expand_path("../../../build/resources/main", __FILE__)
|
|
13
|
+
|
|
14
|
+
if File.directory?(classes_dir) && File.directory?(resources_dir)
|
|
15
|
+
# if in local dev setup, add target to classpath
|
|
16
|
+
$CLASSPATH << classes_dir unless $CLASSPATH.include?(classes_dir)
|
|
17
|
+
$CLASSPATH << resources_dir unless $CLASSPATH.include?(resources_dir)
|
|
18
|
+
else
|
|
19
|
+
# otherwise use included jar
|
|
20
|
+
begin
|
|
21
|
+
require "logstash-core/logstash-core.jar"
|
|
22
|
+
rescue Exception => e
|
|
23
|
+
raise("Error loading logstash-core/logstash-core.jar file, cause: #{e.message}")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# this is a generated file, to avoid over-writing it just delete this comment
|
|
2
|
+
begin
|
|
3
|
+
require 'jar_dependencies'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
require 'org/apache/logging/log4j/log4j-core/2.6.2/log4j-core-2.6.2.jar'
|
|
6
|
+
require 'org/apache/logging/log4j/log4j-api/2.6.2/log4j-api-2.6.2.jar'
|
|
7
|
+
require 'com/fasterxml/jackson/core/jackson-core/2.7.4/jackson-core-2.7.4.jar'
|
|
8
|
+
require 'org/apache/logging/log4j/log4j-1.2-api/2.6.2/log4j-1.2-api-2.6.2.jar'
|
|
9
|
+
require 'com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar'
|
|
10
|
+
require 'com/fasterxml/jackson/core/jackson-databind/2.7.4/jackson-databind-2.7.4.jar'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if defined? Jars
|
|
14
|
+
require_jar( 'org.apache.logging.log4j', 'log4j-core', '2.6.2' )
|
|
15
|
+
require_jar( 'org.apache.logging.log4j', 'log4j-api', '2.6.2' )
|
|
16
|
+
require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.7.4' )
|
|
17
|
+
require_jar( 'org.apache.logging.log4j', 'log4j-1.2-api', '2.6.2' )
|
|
18
|
+
require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.7.0' )
|
|
19
|
+
require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.7.4' )
|
|
20
|
+
end
|
data/lib/logstash/agent.rb
CHANGED
|
@@ -9,6 +9,7 @@ require "logstash/instrument/collector"
|
|
|
9
9
|
require "logstash/instrument/metric"
|
|
10
10
|
require "logstash/pipeline"
|
|
11
11
|
require "logstash/webserver"
|
|
12
|
+
require "logstash/event_dispatcher"
|
|
12
13
|
require "stud/trap"
|
|
13
14
|
require "logstash/config/loader"
|
|
14
15
|
require "uri"
|
|
@@ -21,12 +22,12 @@ class LogStash::Agent
|
|
|
21
22
|
include LogStash::Util::Loggable
|
|
22
23
|
STARTED_AT = Time.now.freeze
|
|
23
24
|
|
|
24
|
-
attr_reader :metric, :
|
|
25
|
+
attr_reader :metric, :name, :pipelines, :settings, :webserver, :dispatcher
|
|
25
26
|
attr_accessor :logger
|
|
26
27
|
|
|
27
28
|
# initialize method for LogStash::Agent
|
|
28
29
|
# @param params [Hash] potential parameters are:
|
|
29
|
-
# :
|
|
30
|
+
# :name [String] - identifier for the agent
|
|
30
31
|
# :auto_reload [Boolean] - enable reloading of pipelines
|
|
31
32
|
# :reload_interval [Integer] - reload pipelines every X seconds
|
|
32
33
|
def initialize(settings = LogStash::SETTINGS)
|
|
@@ -35,10 +36,12 @@ class LogStash::Agent
|
|
|
35
36
|
@auto_reload = setting("config.reload.automatic")
|
|
36
37
|
|
|
37
38
|
@pipelines = {}
|
|
38
|
-
@
|
|
39
|
+
@name = setting("node.name")
|
|
39
40
|
@http_host = setting("http.host")
|
|
40
41
|
@http_port = setting("http.port")
|
|
41
42
|
@http_environment = setting("http.environment")
|
|
43
|
+
# Generate / load the persistent uuid
|
|
44
|
+
id
|
|
42
45
|
|
|
43
46
|
@config_loader = LogStash::Config::Loader.new(@logger)
|
|
44
47
|
@reload_interval = setting("config.reload.interval")
|
|
@@ -50,6 +53,10 @@ class LogStash::Agent
|
|
|
50
53
|
configure_metrics_collectors
|
|
51
54
|
|
|
52
55
|
@reload_metric = metric.namespace([:stats, :pipelines])
|
|
56
|
+
|
|
57
|
+
@dispatcher = LogStash::EventDispatcher.new(self)
|
|
58
|
+
LogStash::PLUGIN_REGISTRY.hooks.register_emitter(self.class, dispatcher)
|
|
59
|
+
dispatcher.fire(:after_initialize)
|
|
53
60
|
end
|
|
54
61
|
|
|
55
62
|
def execute
|
|
@@ -97,7 +104,8 @@ class LogStash::Agent
|
|
|
97
104
|
|
|
98
105
|
def reload_state!
|
|
99
106
|
@upgrade_mutex.synchronize do
|
|
100
|
-
@pipelines.each do |pipeline_id,
|
|
107
|
+
@pipelines.each do |pipeline_id, pipeline|
|
|
108
|
+
next if pipeline.settings.get("config.reload.automatic") == false
|
|
101
109
|
begin
|
|
102
110
|
reload_pipeline!(pipeline_id)
|
|
103
111
|
rescue => e
|
|
@@ -130,8 +138,42 @@ class LogStash::Agent
|
|
|
130
138
|
shutdown_pipelines
|
|
131
139
|
end
|
|
132
140
|
|
|
133
|
-
def
|
|
134
|
-
@
|
|
141
|
+
def id
|
|
142
|
+
return @id if @id
|
|
143
|
+
|
|
144
|
+
uuid = nil
|
|
145
|
+
if ::File.exists?(id_path)
|
|
146
|
+
begin
|
|
147
|
+
uuid = ::File.open(id_path) {|f| f.each_line.first.chomp }
|
|
148
|
+
rescue => e
|
|
149
|
+
logger.warn("Could not open persistent UUID file!",
|
|
150
|
+
:path => id_path,
|
|
151
|
+
:error => e.message,
|
|
152
|
+
:class => e.class.name)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
if !uuid
|
|
157
|
+
uuid = SecureRandom.uuid
|
|
158
|
+
logger.info("No persistent UUID file found. Generating new UUID",
|
|
159
|
+
:uuid => uuid,
|
|
160
|
+
:path => id_path)
|
|
161
|
+
begin
|
|
162
|
+
::File.open(id_path, 'w') {|f| f.write(uuid) }
|
|
163
|
+
rescue => e
|
|
164
|
+
logger.warn("Could not write persistent UUID file! Will use ephemeral UUID",
|
|
165
|
+
:uuid => uuid,
|
|
166
|
+
:path => id_path,
|
|
167
|
+
:error => e.message,
|
|
168
|
+
:class => e.class.name)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
@id = uuid
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def id_path
|
|
176
|
+
@id_path ||= ::File.join(settings.get("path.data"), "uuid")
|
|
135
177
|
end
|
|
136
178
|
|
|
137
179
|
def running_pipelines?
|
|
@@ -161,7 +203,7 @@ class LogStash::Agent
|
|
|
161
203
|
@logger.debug("Agent: Configuring metric collection")
|
|
162
204
|
LogStash::Instrument::Metric.new(@collector)
|
|
163
205
|
else
|
|
164
|
-
LogStash::Instrument::NullMetric.new
|
|
206
|
+
LogStash::Instrument::NullMetric.new(@collector)
|
|
165
207
|
end
|
|
166
208
|
|
|
167
209
|
|
|
@@ -244,12 +286,12 @@ class LogStash::Agent
|
|
|
244
286
|
return unless pipeline.is_a?(LogStash::Pipeline)
|
|
245
287
|
return if pipeline.ready?
|
|
246
288
|
@logger.debug("starting pipeline", :id => id)
|
|
247
|
-
Thread.new do
|
|
289
|
+
t = Thread.new do
|
|
248
290
|
LogStash::Util.set_thread_name("pipeline.#{id}")
|
|
249
291
|
begin
|
|
250
292
|
pipeline.run
|
|
251
293
|
rescue => e
|
|
252
|
-
@reload_metric.namespace([id.to_sym, :reloads]) do |n|
|
|
294
|
+
@reload_metric.namespace([id.to_sym, :reloads]).tap do |n|
|
|
253
295
|
n.increment(:failures)
|
|
254
296
|
n.gauge(:last_error, { :message => e.message, :backtrace => e.backtrace})
|
|
255
297
|
n.gauge(:last_failure_timestamp, LogStash::Timestamp.now)
|
|
@@ -257,7 +299,15 @@ class LogStash::Agent
|
|
|
257
299
|
@logger.error("Pipeline aborted due to error", :exception => e, :backtrace => e.backtrace)
|
|
258
300
|
end
|
|
259
301
|
end
|
|
260
|
-
|
|
302
|
+
while true do
|
|
303
|
+
if !t.alive?
|
|
304
|
+
return false
|
|
305
|
+
elsif pipeline.ready?
|
|
306
|
+
return true
|
|
307
|
+
else
|
|
308
|
+
sleep 0.01
|
|
309
|
+
end
|
|
310
|
+
end
|
|
261
311
|
end
|
|
262
312
|
|
|
263
313
|
def stop_pipeline(id)
|
|
@@ -289,10 +339,11 @@ class LogStash::Agent
|
|
|
289
339
|
stop_pipeline(pipeline_id)
|
|
290
340
|
reset_pipeline_metrics(pipeline_id)
|
|
291
341
|
@pipelines[pipeline_id] = new_pipeline
|
|
292
|
-
start_pipeline(pipeline_id)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
342
|
+
if start_pipeline(pipeline_id) # pipeline started successfuly
|
|
343
|
+
@reload_metric.namespace([pipeline_id.to_sym, :reloads]).tap do |n|
|
|
344
|
+
n.increment(:successes)
|
|
345
|
+
n.gauge(:last_success_timestamp, LogStash::Timestamp.now)
|
|
346
|
+
end
|
|
296
347
|
end
|
|
297
348
|
end
|
|
298
349
|
|
|
@@ -7,7 +7,8 @@ module LogStash
|
|
|
7
7
|
module Commands
|
|
8
8
|
class DefaultMetadata < Commands::Base
|
|
9
9
|
def all
|
|
10
|
-
{:host => host, :version => version, :http_address => http_address
|
|
10
|
+
{:host => host, :version => version, :http_address => http_address,
|
|
11
|
+
:id => service.agent.id, :name => service.agent.name}
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def host
|
|
@@ -15,7 +15,8 @@ module LogStash
|
|
|
15
15
|
:peak_count
|
|
16
16
|
),
|
|
17
17
|
:mem => memory,
|
|
18
|
-
:gc => gc
|
|
18
|
+
:gc => gc,
|
|
19
|
+
:uptime_in_millis => service.get_shallow(:jvm, :uptime_in_millis)
|
|
19
20
|
}
|
|
20
21
|
end
|
|
21
22
|
|
|
@@ -26,7 +27,7 @@ module LogStash
|
|
|
26
27
|
:peak_open_file_descriptors,
|
|
27
28
|
:max_file_descriptors,
|
|
28
29
|
[:mem, [:total_virtual_in_bytes]],
|
|
29
|
-
[:cpu, [:total_in_millis, :percent]]
|
|
30
|
+
[:cpu, [:total_in_millis, :percent, :load_average]]
|
|
30
31
|
)
|
|
31
32
|
end
|
|
32
33
|
|
data/lib/logstash/config/file.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
require "logstash/namespace"
|
|
3
|
-
require "logstash/config/registry"
|
|
4
3
|
require "logstash/plugins/registry"
|
|
5
4
|
require "logstash/logging"
|
|
6
5
|
require "logstash/util/password"
|
|
@@ -73,6 +72,7 @@ module LogStash::Config::Mixin
|
|
|
73
72
|
"in the future. #{extra} If you have any questions " +
|
|
74
73
|
"about this, please visit the #logstash channel " +
|
|
75
74
|
"on freenode irc.", :name => name, :plugin => self)
|
|
75
|
+
|
|
76
76
|
end
|
|
77
77
|
if opts && opts[:obsolete]
|
|
78
78
|
extra = opts[:obsolete].is_a?(String) ? opts[:obsolete] : ""
|
|
@@ -181,11 +181,7 @@ module LogStash::Config::Mixin
|
|
|
181
181
|
# If no name given (nil), return the current name.
|
|
182
182
|
def config_name(name = nil)
|
|
183
183
|
@config_name = name if !name.nil?
|
|
184
|
-
|
|
185
|
-
if self.respond_to?("plugin_type")
|
|
186
|
-
declare_plugin(self.plugin_type, @config_name)
|
|
187
|
-
end
|
|
188
|
-
return @config_name
|
|
184
|
+
@config_name
|
|
189
185
|
end
|
|
190
186
|
alias_method :config_plugin, :config_name
|
|
191
187
|
|
data/lib/logstash/environment.rb
CHANGED
|
@@ -23,7 +23,7 @@ module LogStash
|
|
|
23
23
|
Setting::Boolean.new("config.test_and_exit", false),
|
|
24
24
|
Setting::Boolean.new("config.reload.automatic", false),
|
|
25
25
|
Setting::Numeric.new("config.reload.interval", 3), # in seconds
|
|
26
|
-
Setting::Boolean.new("metric.collect", true)
|
|
26
|
+
Setting::Boolean.new("metric.collect", true),
|
|
27
27
|
Setting::String.new("pipeline.id", "main"),
|
|
28
28
|
Setting::PositiveInteger.new("pipeline.workers", LogStash::Config::CpuCoreStrategy.maximum),
|
|
29
29
|
Setting::PositiveInteger.new("pipeline.output.workers", 1),
|
|
@@ -40,14 +40,33 @@ module LogStash
|
|
|
40
40
|
Setting::String.new("http.host", "127.0.0.1"),
|
|
41
41
|
Setting::PortRange.new("http.port", 9600..9700),
|
|
42
42
|
Setting::String.new("http.environment", "production"),
|
|
43
|
+
Setting::String.new("queue.type", "memory", true, ["persisted", "memory", "memory_acked"]),
|
|
44
|
+
Setting::Bytes.new("queue.page_capacity", "250mb"),
|
|
45
|
+
Setting::Bytes.new("queue.max_bytes", "1024mb"),
|
|
46
|
+
Setting::Numeric.new("queue.max_events", 0), # 0 is unlimited
|
|
47
|
+
Setting::Numeric.new("queue.checkpoint.acks", 1024), # 0 is unlimited
|
|
48
|
+
Setting::Numeric.new("queue.checkpoint.writes", 1024), # 0 is unlimited
|
|
49
|
+
Setting::Numeric.new("queue.checkpoint.interval", 1000), # 0 is no time-based checkpointing
|
|
50
|
+
Setting::TimeValue.new("slowlog.threshold.warn", "-1"),
|
|
51
|
+
Setting::TimeValue.new("slowlog.threshold.info", "-1"),
|
|
52
|
+
Setting::TimeValue.new("slowlog.threshold.debug", "-1"),
|
|
53
|
+
Setting::TimeValue.new("slowlog.threshold.trace", "-1")
|
|
43
54
|
].each {|setting| SETTINGS.register(setting) }
|
|
44
55
|
|
|
56
|
+
# Compute the default queue path based on `path.data`
|
|
57
|
+
default_queue_file_path = ::File.join(SETTINGS.get("path.data"), "queue")
|
|
58
|
+
SETTINGS.register Setting::WritableDirectory.new("path.queue", default_queue_file_path)
|
|
59
|
+
|
|
45
60
|
module Environment
|
|
46
61
|
extend self
|
|
47
62
|
|
|
48
63
|
LOGSTASH_CORE = ::File.expand_path(::File.join(::File.dirname(__FILE__), "..", ".."))
|
|
49
64
|
LOGSTASH_ENV = (ENV["LS_ENV"] || 'production').to_s.freeze
|
|
50
65
|
|
|
66
|
+
LINUX_OS_RE = /linux/
|
|
67
|
+
WINDOW_OS_RE = /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
|
68
|
+
MACOS_OS_RE = /darwin/
|
|
69
|
+
|
|
51
70
|
def env
|
|
52
71
|
LOGSTASH_ENV
|
|
53
72
|
end
|
|
@@ -110,7 +129,11 @@ module LogStash
|
|
|
110
129
|
end
|
|
111
130
|
|
|
112
131
|
def windows?
|
|
113
|
-
::
|
|
132
|
+
RbConfig::CONFIG['host_os'] =~ WINDOW_OS_RE
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def linux?
|
|
136
|
+
RbConfig::CONFIG['host_os'] =~ LINUX_OS_RE
|
|
114
137
|
end
|
|
115
138
|
|
|
116
139
|
def locales_path(path)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module LogStash
|
|
3
|
+
class EventDispatcher
|
|
4
|
+
java_import "java.util.concurrent.CopyOnWriteArrayList"
|
|
5
|
+
|
|
6
|
+
attr_reader :emitter
|
|
7
|
+
|
|
8
|
+
def initialize(emitter)
|
|
9
|
+
@emitter = emitter
|
|
10
|
+
@listeners = CopyOnWriteArrayList.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# This operation is slow because we use a CopyOnWriteArrayList
|
|
14
|
+
# But the majority of the addition will be done at bootstrap time
|
|
15
|
+
# So add_listener shouldn't be called often at runtime.
|
|
16
|
+
#
|
|
17
|
+
# On the other hand the notification could be called really often.
|
|
18
|
+
def add_listener(listener)
|
|
19
|
+
@listeners.add(listener)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# This operation is slow because we use a `CopyOnWriteArrayList` as the backend, instead of a
|
|
23
|
+
# ConcurrentHashMap, but since we are mostly adding stuff and iterating the `CopyOnWriteArrayList`
|
|
24
|
+
# should provide a better performance.
|
|
25
|
+
#
|
|
26
|
+
# See note on add_listener, this method shouldn't be called really often.
|
|
27
|
+
def remove_listener(listener)
|
|
28
|
+
@listeners.remove(listener)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def fire(method_name, *arguments)
|
|
32
|
+
@listeners.each do |listener|
|
|
33
|
+
if listener.respond_to?(method_name)
|
|
34
|
+
listener.send(method_name, emitter, *arguments)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
alias_method :execute, :fire
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -20,7 +20,7 @@ module LogStash
|
|
|
20
20
|
@filter = klass.new(plugin_args)
|
|
21
21
|
|
|
22
22
|
# Scope the metrics to the plugin
|
|
23
|
-
namespaced_metric = metric.namespace(
|
|
23
|
+
namespaced_metric = metric.namespace(@id.to_sym)
|
|
24
24
|
@filter.metric = namespaced_metric
|
|
25
25
|
|
|
26
26
|
@metric_events = namespaced_metric.namespace(:events)
|
|
@@ -139,6 +139,14 @@ class LogStash::Filters::Base < LogStash::Plugin
|
|
|
139
139
|
raise "#{self.class}#filter must be overidden"
|
|
140
140
|
end # def filter
|
|
141
141
|
|
|
142
|
+
public
|
|
143
|
+
def do_filter(event, &block)
|
|
144
|
+
time = java.lang.System.nanoTime
|
|
145
|
+
filter(event, &block)
|
|
146
|
+
@slow_logger.on_event("event processing time", @original_params, event, java.lang.System.nanoTime - time)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
|
|
142
150
|
# in 1.5.0 multi_filter is meant to be used in the generated filter function in LogStash::Config::AST::Plugin only
|
|
143
151
|
# and is temporary until we refactor the filter method interface to accept events list and return events list,
|
|
144
152
|
# just list in multi_filter see https://github.com/elastic/logstash/issues/2872.
|
|
@@ -153,7 +161,7 @@ class LogStash::Filters::Base < LogStash::Plugin
|
|
|
153
161
|
events.each do |event|
|
|
154
162
|
unless event.cancelled?
|
|
155
163
|
result << event
|
|
156
|
-
|
|
164
|
+
do_filter(event){|new_event| result << new_event}
|
|
157
165
|
end
|
|
158
166
|
end
|
|
159
167
|
result
|
|
@@ -161,7 +169,7 @@ class LogStash::Filters::Base < LogStash::Plugin
|
|
|
161
169
|
|
|
162
170
|
public
|
|
163
171
|
def execute(event, &block)
|
|
164
|
-
|
|
172
|
+
do_filter(event, &block)
|
|
165
173
|
end # def execute
|
|
166
174
|
|
|
167
175
|
public
|