logstash-core 6.3.2-java → 6.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash/agent.rb +10 -6
  3. data/lib/logstash/api/modules/logging.rb +4 -0
  4. data/lib/logstash/api/service.rb +0 -1
  5. data/lib/logstash/bootstrap_check/default_config.rb +0 -2
  6. data/lib/logstash/bootstrap_check/persisted_queue_config.rb +0 -1
  7. data/lib/logstash/codecs/base.rb +2 -4
  8. data/lib/logstash/compiler.rb +2 -3
  9. data/lib/logstash/compiler/lscl.rb +0 -1
  10. data/lib/logstash/config/config_ast.rb +0 -1
  11. data/lib/logstash/config/cpu_core_strategy.rb +0 -1
  12. data/lib/logstash/config/defaults.rb +0 -1
  13. data/lib/logstash/config/file.rb +0 -2
  14. data/lib/logstash/config/mixin.rb +4 -7
  15. data/lib/logstash/config/modules_common.rb +0 -2
  16. data/lib/logstash/config/source/local.rb +1 -3
  17. data/lib/logstash/config/source/modules.rb +0 -2
  18. data/lib/logstash/config/source/multi_local.rb +0 -1
  19. data/lib/logstash/config/source_loader.rb +1 -2
  20. data/lib/logstash/dependency_report.rb +19 -6
  21. data/lib/logstash/elasticsearch_client.rb +0 -2
  22. data/lib/logstash/environment.rb +3 -2
  23. data/lib/logstash/errors.rb +1 -15
  24. data/lib/logstash/event.rb +0 -1
  25. data/lib/logstash/event_dispatcher.rb +1 -40
  26. data/lib/logstash/execution_context.rb +2 -19
  27. data/lib/logstash/filters/base.rb +0 -2
  28. data/lib/logstash/inputs/base.rb +2 -4
  29. data/lib/logstash/inputs/threadable.rb +2 -3
  30. data/lib/logstash/instrument/collector.rb +0 -2
  31. data/lib/logstash/instrument/metric.rb +1 -105
  32. data/lib/logstash/instrument/namespaced_metric.rb +1 -58
  33. data/lib/logstash/instrument/namespaced_null_metric.rb +1 -58
  34. data/lib/logstash/instrument/null_metric.rb +2 -71
  35. data/lib/logstash/instrument/periodic_poller/base.rb +0 -1
  36. data/lib/logstash/instrument/periodic_poller/cgroup.rb +0 -1
  37. data/lib/logstash/java_pipeline.rb +33 -222
  38. data/lib/logstash/json.rb +0 -1
  39. data/lib/logstash/logging.rb +0 -2
  40. data/lib/logstash/logging/logger.rb +1 -159
  41. data/lib/logstash/modules/cli_parser.rb +0 -4
  42. data/lib/logstash/modules/elasticsearch_config.rb +0 -3
  43. data/lib/logstash/modules/elasticsearch_importer.rb +0 -3
  44. data/lib/logstash/modules/elasticsearch_resource.rb +0 -1
  45. data/lib/logstash/modules/file_reader.rb +0 -2
  46. data/lib/logstash/modules/kibana_base.rb +0 -1
  47. data/lib/logstash/modules/kibana_client.rb +0 -2
  48. data/lib/logstash/modules/kibana_config.rb +0 -3
  49. data/lib/logstash/modules/kibana_dashboards.rb +0 -2
  50. data/lib/logstash/modules/kibana_importer.rb +0 -3
  51. data/lib/logstash/modules/kibana_resource.rb +0 -1
  52. data/lib/logstash/modules/kibana_settings.rb +0 -2
  53. data/lib/logstash/modules/logstash_config.rb +0 -1
  54. data/lib/logstash/modules/resource_base.rb +0 -1
  55. data/lib/logstash/modules/scaffold.rb +0 -3
  56. data/lib/logstash/modules/settings_merger.rb +0 -2
  57. data/lib/logstash/namespace.rb +2 -15
  58. data/lib/logstash/outputs/base.rb +3 -5
  59. data/lib/logstash/patches/clamp.rb +6 -0
  60. data/lib/logstash/pipeline.rb +38 -180
  61. data/lib/logstash/pipeline_action/create.rb +0 -2
  62. data/lib/logstash/pipeline_action/reload.rb +1 -4
  63. data/lib/logstash/pipeline_action/stop.rb +0 -2
  64. data/lib/logstash/pipeline_reporter.rb +2 -108
  65. data/lib/logstash/plugin.rb +4 -7
  66. data/lib/logstash/plugins/hooks_registry.rb +1 -63
  67. data/lib/logstash/plugins/registry.rb +3 -2
  68. data/lib/logstash/runner.rb +6 -7
  69. data/lib/logstash/settings.rb +4 -5
  70. data/lib/logstash/shutdown_watcher.rb +0 -119
  71. data/lib/logstash/universal_plugin.rb +1 -13
  72. data/lib/logstash/util.rb +0 -1
  73. data/lib/logstash/util/buftok.rb +1 -139
  74. data/lib/logstash/util/byte_value.rb +2 -3
  75. data/lib/logstash/util/charset.rb +0 -1
  76. data/lib/logstash/util/cloud_setting_auth.rb +0 -1
  77. data/lib/logstash/util/cloud_setting_id.rb +20 -8
  78. data/lib/logstash/util/dead_letter_queue_manager.rb +2 -61
  79. data/lib/logstash/util/decorators.rb +0 -1
  80. data/lib/logstash/util/loggable.rb +1 -31
  81. data/lib/logstash/util/modules_setting_array.rb +2 -2
  82. data/lib/logstash/util/password.rb +0 -1
  83. data/lib/logstash/util/plugin_version.rb +0 -1
  84. data/lib/logstash/util/safe_uri.rb +7 -8
  85. data/lib/logstash/util/secretstore.rb +1 -38
  86. data/lib/logstash/util/substitution_variables.rb +4 -5
  87. data/lib/logstash/util/worker_threads_default_printer.rb +0 -1
  88. data/locales/en.yml +28 -1
  89. data/spec/logstash/config/mixin_spec.rb +4 -4
  90. data/spec/logstash/converge_result_spec.rb +0 -1
  91. data/spec/logstash/event_dispatcher_spec.rb +0 -2
  92. data/spec/logstash/event_spec.rb +22 -26
  93. data/spec/logstash/execution_context_spec.rb +0 -2
  94. data/spec/logstash/filter_delegator_spec.rb +12 -28
  95. data/spec/logstash/inputs/base_spec.rb +4 -5
  96. data/spec/logstash/instrument/metric_spec.rb +0 -1
  97. data/spec/logstash/instrument/namespaced_metric_spec.rb +0 -2
  98. data/spec/logstash/instrument/namespaced_null_metric_spec.rb +1 -3
  99. data/spec/logstash/instrument/null_metric_spec.rb +1 -4
  100. data/spec/logstash/instrument/periodic_poller/base_spec.rb +0 -1
  101. data/spec/logstash/instrument/periodic_poller/os_spec.rb +0 -1
  102. data/spec/logstash/instrument/wrapped_write_client_spec.rb +0 -1
  103. data/spec/logstash/java_filter_delegator_spec.rb +0 -3
  104. data/spec/logstash/java_integration_spec.rb +0 -1
  105. data/spec/logstash/java_pipeline_spec.rb +1 -4
  106. data/spec/logstash/modules/cli_parser_spec.rb +1 -3
  107. data/spec/logstash/modules/scaffold_spec.rb +0 -1
  108. data/spec/logstash/outputs/base_spec.rb +9 -10
  109. data/spec/logstash/pipeline_action/create_spec.rb +2 -3
  110. data/spec/logstash/pipeline_action/reload_spec.rb +1 -2
  111. data/spec/logstash/pipeline_action/stop_spec.rb +0 -1
  112. data/spec/logstash/pipeline_dlq_commit_spec.rb +0 -6
  113. data/spec/logstash/pipeline_reporter_spec.rb +18 -4
  114. data/spec/logstash/pipeline_spec.rb +2 -6
  115. data/spec/logstash/plugin_spec.rb +1 -2
  116. data/spec/logstash/plugins/hooks_registry_spec.rb +0 -2
  117. data/spec/logstash/queue_factory_spec.rb +0 -1
  118. data/spec/logstash/runner_spec.rb +16 -9
  119. data/spec/logstash/settings/modules_spec.rb +3 -3
  120. data/spec/logstash/shutdown_watcher_spec.rb +0 -27
  121. data/spec/logstash/state_resolver_spec.rb +0 -1
  122. data/spec/logstash/util/buftok_spec.rb +0 -1
  123. data/spec/logstash/util/cloud_setting_id_spec.rb +55 -2
  124. data/spec/logstash/util/secretstore_spec.rb +10 -10
  125. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +2 -2
  126. data/versions-gem-copy.yml +2 -2
  127. metadata +2 -16
  128. data/lib/logstash/bootstrap_check/bad_java.rb +0 -16
  129. data/lib/logstash/bootstrap_check/bad_ruby.rb +0 -12
  130. data/lib/logstash/converge_result.rb +0 -103
  131. data/lib/logstash/instrument/global_metrics.rb +0 -13
  132. data/lib/logstash/instrument/snapshot.rb +0 -15
  133. data/lib/logstash/java_integration.rb +0 -116
  134. data/lib/logstash/logging/json.rb +0 -21
  135. data/lib/logstash/plugins/plugin_factory.rb +0 -107
  136. data/lib/logstash/queue_factory.rb +0 -34
  137. data/lib/logstash/util/retryable.rb +0 -40
  138. data/spec/logstash/output_delegator_spec.rb +0 -201
  139. data/spec/logstash/timestamp_spec.rb +0 -45
data/lib/logstash/json.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/environment"
3
3
  require "jrjackson"
4
- require "logstash/java_integration"
5
4
 
6
5
  module LogStash
7
6
  module Json
@@ -1,3 +1 @@
1
1
  # encoding: utf-8
2
- require "logstash/logging/logger"
3
- require "logstash/namespace"
@@ -1,159 +1 @@
1
- require "logstash/java_integration"
2
- require "uri"
3
-
4
- module LogStash
5
- module Logging
6
- java_import org.apache.logging.log4j.Level
7
- java_import org.apache.logging.log4j.LogManager
8
- java_import org.apache.logging.log4j.core.config.Configurator
9
- java_import org.apache.logging.log4j.core.config.DefaultConfiguration
10
- java_import org.apache.logging.log4j.core.config.LoggerConfig
11
- java_import org.logstash.log.LogstashLoggerContextFactory
12
- java_import org.apache.logging.log4j.core.LoggerContext
13
- java_import java.net.URI
14
-
15
- class Logger
16
- @@config_mutex = Mutex.new
17
-
18
- def initialize(name)
19
- @logger = LogManager.getLogger(name)
20
- end
21
-
22
- def debug?
23
- @logger.is_debug_enabled
24
- end
25
-
26
- def info?
27
- @logger.is_info_enabled
28
- end
29
-
30
- def error?
31
- @logger.is_error_enabled
32
- end
33
-
34
- def warn?
35
- @logger.is_warn_enabled
36
- end
37
-
38
- def fatal?
39
- @logger.is_fatal_enabled
40
- end
41
-
42
- def trace?
43
- @logger.is_trace_enabled
44
- end
45
-
46
- def debug(message, data = {})
47
- @logger.debug(message, data)
48
- end
49
-
50
- def warn(message, data = {})
51
- @logger.warn(message, data)
52
- end
53
-
54
- def info(message, data = {})
55
- @logger.info(message, data)
56
- end
57
-
58
- def error(message, data = {})
59
- @logger.error(message, data)
60
- end
61
-
62
- def fatal(message, data = {})
63
- @logger.fatal(message, data)
64
- end
65
-
66
- def trace(message, data = {})
67
- @logger.trace(message, data)
68
- end
69
-
70
- def self.configure_logging(level, path = LogManager::ROOT_LOGGER_NAME)
71
- @@config_mutex.synchronize { set_level(level, path) }
72
- rescue Exception => e
73
- raise ArgumentError, "invalid level[#{level}] for logger[#{path}]"
74
- end
75
-
76
- def self.reconfigure(config_location)
77
- @@config_mutex.synchronize do
78
- config_location_uri = URI.create(config_location)
79
- file_path = config_location_uri.path
80
- if ::File.exists?(file_path)
81
- logs_location = java.lang.System.getProperty("ls.logs")
82
- puts "Sending Logstash's logs to #{logs_location} which is now configured via log4j2.properties"
83
- #reconfigure the default context to use our log4j2.properties file
84
- get_logging_context.setConfigLocation(URI.create(config_location))
85
- #ensure everyone agrees which context to use for the LogManager
86
- context_factory = LogstashLoggerContextFactory.new(get_logging_context)
87
- LogManager.setFactory(context_factory)
88
- else
89
- # fall back to default config
90
- puts "Could not find log4j2 configuration at path #{file_path}. Using default config which logs errors to the console"
91
- end
92
- end
93
- end
94
-
95
- # until dev_utils/rspec/spec_helper is changed, we need to have both methods
96
- singleton_class.send(:alias_method, :initialize, :reconfigure)
97
-
98
- def self.get_logging_context
99
- return LoggerContext.getContext(false)
100
- end
101
-
102
- # Clone of org.apache.logging.log4j.core.config.Configurator.setLevel(), but ensure the proper context is used
103
- def self.set_level(_level, path)
104
- configuration = get_logging_context.getConfiguration()
105
- level = Level.valueOf(_level)
106
- if path.nil? || path.strip.empty?
107
- root_logger = configuration.getRootLogger()
108
- if root_logger.getLevel() != level
109
- root_logger.setLevel(level)
110
- get_logging_context.updateLoggers()
111
- end
112
- else
113
- package_logger = configuration.getLoggerConfig(path)
114
- if package_logger.name != path #no package logger found
115
- configuration.addLogger(path, LoggerConfig.new(path, level, true))
116
- get_logging_context.updateLoggers()
117
- elsif package_logger.getLevel() != level
118
- package_logger.setLevel(level)
119
- get_logging_context.updateLoggers()
120
- end
121
- end
122
- end
123
-
124
- private_class_method :set_level
125
- end
126
-
127
- class SlowLogger
128
- def initialize(name, warn_threshold, info_threshold, debug_threshold, trace_threshold)
129
- slowlog_name = ["slowlog", name].join('.')
130
- @slowlogger = LogManager.getLogger(slowlog_name)
131
- @warn_threshold = warn_threshold
132
- @info_threshold = info_threshold
133
- @debug_threshold = debug_threshold
134
- @trace_threshold = trace_threshold
135
- end
136
-
137
- def as_data(plugin_params, event, took_in_nanos)
138
- {
139
- :plugin_params => plugin_params,
140
- :took_in_nanos => took_in_nanos,
141
- :took_in_millis => took_in_nanos / 1000000,
142
- :event => event.to_json
143
- }
144
- end
145
-
146
- def on_event(message, plugin_params, event, took_in_nanos)
147
- if @warn_threshold >= 0 and took_in_nanos > @warn_threshold
148
- @slowlogger.warn(message, as_data(plugin_params, event, took_in_nanos))
149
- elsif @info_threshold >= 0 and took_in_nanos > @info_threshold
150
- @slowlogger.info(message, as_data(plugin_params, event, took_in_nanos))
151
- elsif @debug_threshold >= 0 and took_in_nanos > @debug_threshold
152
- @slowlogger.debug(message, as_data(plugin_params, event, took_in_nanos))
153
- elsif @trace_threshold >= 0 and took_in_nanos > @trace_threshold
154
- @slowlogger.trace(message, as_data(plugin_params, event, took_in_nanos))
155
- end
156
- end
157
- end
158
- end
159
- end
1
+ # Keeping this file for backwards compatibility with plugins that include it directly.
@@ -1,8 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
- require "logstash/errors"
5
-
6
2
  module LogStash module Modules class CLIParser
7
3
  include LogStash::Util::Loggable
8
4
 
@@ -1,7 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
-
5
2
  require_relative "elasticsearch_resource"
6
3
 
7
4
  module LogStash module Modules class ElasticsearchConfig
@@ -1,7 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
-
5
2
  module LogStash module Modules class ElasticsearchImporter
6
3
  include LogStash::Util::Loggable
7
4
 
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
2
  require_relative "resource_base"
4
3
 
5
4
  module LogStash module Modules class ElasticsearchResource
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
2
  require "logstash/json"
5
3
 
6
4
  module LogStash module Modules class FileReader
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
2
  require "logstash/json"
4
3
 
5
4
  module LogStash module Modules class KibanaBase
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
2
  require "logstash/json"
5
3
  require "manticore"
6
4
 
@@ -1,7 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
-
5
2
  require_relative "file_reader"
6
3
  require_relative "kibana_settings"
7
4
  require_relative "kibana_dashboards"
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
2
  require_relative "kibana_base"
5
3
 
6
4
  module LogStash module Modules class KibanaDashboards < KibanaBase
@@ -1,7 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
-
5
2
  module LogStash module Modules class KibanaImporter
6
3
  include LogStash::Util::Loggable
7
4
 
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
2
  require_relative "resource_base"
4
3
 
5
4
  module LogStash module Modules class KibanaResource
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
2
  require_relative "kibana_base"
5
3
 
6
4
  module LogStash module Modules class KibanaSettings < KibanaBase
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
2
  require_relative "file_reader"
4
3
  require "logstash/settings"
5
4
 
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
2
  require "logstash/json"
4
3
  require_relative "file_reader"
5
4
 
@@ -1,7 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
- require "logstash/util/loggable"
5
2
  require "erb"
6
3
 
7
4
  require_relative "elasticsearch_config"
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
2
  require "logstash/util"
4
- require "logstash/util/loggable"
5
3
 
6
4
  module LogStash module Modules module SettingsMerger
7
5
  include LogStash::Util::Loggable
@@ -1,15 +1,2 @@
1
- # encoding: utf-8
2
- module LogStash
3
- module Inputs; end
4
- module Outputs; end
5
- module Filters; end
6
- module Search; end
7
- module Config; end
8
- module File; end
9
- module Web; end
10
- module Util; end
11
- module PluginMixins; end
12
- module PluginManager; end
13
- module Api; end
14
- module Modules; end
15
- end # module LogStash
1
+ # The contents of this file have been ported to Java. It is included for for compatibility
2
+ # with plugins that directly require it.
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/event"
3
- require "logstash/logging"
4
3
  require "logstash/plugin"
5
- require "logstash/namespace"
6
4
  require "logstash/config/mixin"
7
5
  require "concurrent/atomic/atomic_fixnum"
8
6
 
@@ -24,7 +22,7 @@ class LogStash::Outputs::Base < LogStash::Plugin
24
22
  # when we no longer support the :legacy type
25
23
  # This is hacky, but it can only be herne
26
24
  config :workers, :type => :number, :default => 1
27
-
25
+
28
26
  # Set or return concurrency type
29
27
  def self.concurrency(type=nil)
30
28
  if type
@@ -68,7 +66,7 @@ class LogStash::Outputs::Base < LogStash::Plugin
68
66
  # If we're running with a single thread we must enforce single-threaded concurrency by default
69
67
  # Maybe in a future version we'll assume output plugins are threadsafe
70
68
  @single_worker_mutex = Mutex.new
71
-
69
+
72
70
  @receives_encoded = self.methods.include?(:multi_receive_encoded)
73
71
  end
74
72
 
@@ -108,7 +106,7 @@ class LogStash::Outputs::Base < LogStash::Plugin
108
106
  super
109
107
  # There is no easy way to propage an instance variable into the codec, because the codec
110
108
  # are created at the class level
111
- # TODO(talevy): Codecs should have their own execution_context, for now they will inherit their
109
+ # TODO(talevy): Codecs should have their own execution_context, for now they will inherit their
112
110
  # parent plugin's
113
111
  @codec.execution_context = context
114
112
  context
@@ -48,6 +48,12 @@ module Clamp
48
48
  end
49
49
  end
50
50
 
51
+ def define_appender_for(option)
52
+ define_method(option.append_method) do |value|
53
+ LogStash::SETTINGS.get_value(option.attribute_name) << value
54
+ end
55
+ end
56
+
51
57
  def define_deprecated_accessors_for(option, opts, &block)
52
58
  define_deprecated_writer_for(option, opts, &block)
53
59
  end
@@ -2,67 +2,34 @@
2
2
  require "thread"
3
3
  require "stud/interval"
4
4
  require "concurrent"
5
- require "logstash/namespace"
6
- require "logstash/errors"
7
5
  require "logstash-core/logstash-core"
8
6
  require "logstash/event"
9
7
  require "logstash/config/file"
10
8
  require "logstash/filters/base"
11
9
  require "logstash/inputs/base"
12
10
  require "logstash/outputs/base"
13
- require "logstash/shutdown_watcher"
14
- require "logstash/pipeline_reporter"
15
- require "logstash/instrument/metric"
16
- require "logstash/instrument/namespaced_metric"
17
- require "logstash/instrument/null_metric"
18
- require "logstash/instrument/namespaced_null_metric"
19
11
  require "logstash/instrument/collector"
20
- require "logstash/util/dead_letter_queue_manager"
21
12
  require "logstash/filter_delegator"
22
- require "logstash/queue_factory"
23
- require "logstash/plugins/plugin_factory"
24
13
  require "logstash/compiler"
25
- require "logstash/execution_context"
26
- require "securerandom"
27
14
 
28
- java_import org.logstash.common.DeadLetterQueueFactory
29
- java_import org.logstash.common.SourceWithMetadata
30
- java_import org.logstash.common.io.DeadLetterQueueWriter
31
- java_import org.logstash.config.ir.ConfigCompiler
32
-
33
- module LogStash; class BasePipeline
15
+ module LogStash; class BasePipeline < AbstractPipeline
34
16
  include LogStash::Util::Loggable
35
17
 
36
- attr_reader :settings, :config_str, :config_hash, :inputs, :filters, :outputs, :pipeline_id, :lir, :execution_context, :ephemeral_id
37
- attr_reader :pipeline_config
18
+ attr_reader :inputs, :filters, :outputs
38
19
 
39
20
  def initialize(pipeline_config, namespaced_metric = nil, agent = nil)
40
21
  @logger = self.logger
41
- @mutex = Mutex.new
42
- @ephemeral_id = SecureRandom.uuid
43
-
44
- @pipeline_config = pipeline_config
45
- @config_str = pipeline_config.config_string
46
- @settings = pipeline_config.settings
47
- @config_hash = Digest::SHA1.hexdigest(@config_str)
48
-
49
- @lir = ConfigCompiler.configToPipelineIR(
50
- @config_str, @settings.get_value("config.support_escapes")
51
- )
52
-
53
- @pipeline_id = @settings.get_value("pipeline.id") || self.object_id
22
+ super pipeline_config, namespaced_metric, @logger
54
23
 
55
24
  @inputs = nil
56
25
  @filters = nil
57
26
  @outputs = nil
58
27
  @agent = agent
59
28
 
60
- @dlq_writer = dlq_writer
61
-
62
29
  @plugin_factory = LogStash::Plugins::PluginFactory.new(
63
30
  # use NullMetric if called in the BasePipeline context otherwise use the @metric value
64
- @lir, LogStash::Plugins::PluginMetricFactory.new(pipeline_id, @metric || Instrument::NullMetric.new),
65
- LogStash::Plugins::ExecutionContextFactory.new(@agent, self, @dlq_writer),
31
+ lir, LogStash::Plugins::PluginMetricFactory.new(pipeline_id, metric),
32
+ LogStash::Plugins::ExecutionContextFactory.new(@agent, self, dlq_writer),
66
33
  FilterDelegator
67
34
  )
68
35
  grammar = LogStashConfigParser.new
@@ -85,39 +52,10 @@ module LogStash; class BasePipeline
85
52
  end
86
53
  end
87
54
 
88
- def dlq_writer
89
- if settings.get_value("dead_letter_queue.enable")
90
- @dlq_writer = DeadLetterQueueFactory.getWriter(pipeline_id, settings.get_value("path.dead_letter_queue"), settings.get_value("dead_letter_queue.max_bytes"))
91
- else
92
- @dlq_writer = LogStash::Util::DummyDeadLetterQueueWriter.new
93
- end
94
- end
95
-
96
- def close_dlq_writer
97
- @dlq_writer.close
98
- if settings.get_value("dead_letter_queue.enable")
99
- DeadLetterQueueFactory.release(pipeline_id)
100
- end
101
- end
102
-
103
- def compile_lir
104
- org.logstash.config.ir.ConfigCompiler.configToPipelineIR(
105
- self.config_str, @settings.get_value("config.support_escapes")
106
- )
107
- end
108
-
109
- def plugin(plugin_type, name, line, column, *args)
110
- @plugin_factory.plugin(plugin_type, name, line, column, *args)
111
- end
112
-
113
55
  def reloadable?
114
56
  configured_as_reloadable? && reloadable_plugins?
115
57
  end
116
58
 
117
- def configured_as_reloadable?
118
- settings.get("pipeline.reloadable")
119
- end
120
-
121
59
  def reloadable_plugins?
122
60
  non_reloadable_plugins.empty?
123
61
  end
@@ -128,6 +66,11 @@ module LogStash; class BasePipeline
128
66
 
129
67
  private
130
68
 
69
+
70
+ def plugin(plugin_type, name, line, column, *args)
71
+ @plugin_factory.plugin(plugin_type, name, line, column, *args)
72
+ end
73
+
131
74
  def default_logging_keys(other_keys = {})
132
75
  { :pipeline_id => pipeline_id }.merge(other_keys)
133
76
  end
@@ -138,51 +81,19 @@ module LogStash; class Pipeline < BasePipeline
138
81
  :worker_threads,
139
82
  :events_consumed,
140
83
  :events_filtered,
141
- :reporter,
142
84
  :started_at,
143
- :thread,
144
- :settings,
145
- :metric,
146
- :filter_queue_client,
147
- :input_queue_client,
148
- :queue
85
+ :thread
149
86
 
150
87
  MAX_INFLIGHT_WARN_THRESHOLD = 10_000
151
88
 
152
89
  def initialize(pipeline_config, namespaced_metric = nil, agent = nil)
153
- @settings = pipeline_config.settings
154
- # This needs to be configured before we call super which will evaluate the code to make
155
- # sure the metric instance is correctly send to the plugins to make the namespace scoping work
156
- @metric = if namespaced_metric
157
- settings.get("metric.collect") ? namespaced_metric : Instrument::NullMetric.new(namespaced_metric.collector)
158
- else
159
- Instrument::NullMetric.new
160
- end
161
-
162
- @ephemeral_id = SecureRandom.uuid
163
- @settings = settings
164
- @reporter = PipelineReporter.new(@logger, self)
165
- @worker_threads = []
166
-
167
90
  super
168
91
 
169
- begin
170
- @queue = LogStash::QueueFactory.create(settings)
171
- rescue => e
172
- @logger.error("Logstash failed to create queue", default_logging_keys("exception" => e.message, "backtrace" => e.backtrace))
173
- raise e
174
- end
92
+ @worker_threads = []
175
93
 
176
- @input_queue_client = @queue.write_client
177
- @filter_queue_client = @queue.read_client
178
94
  @signal_queue = java.util.concurrent.LinkedBlockingQueue.new
179
- # Note that @inflight_batches as a central mechanism for tracking inflight
180
- # batches will fail if we have multiple read clients here.
181
- @filter_queue_client.set_events_metric(metric.namespace([:stats, :events]))
182
- @filter_queue_client.set_pipeline_metric(
183
- metric.namespace([:stats, :pipelines, pipeline_id.to_s.to_sym, :events])
184
- )
185
- @drain_queue = @settings.get_value("queue.drain") || settings.get("queue.type") == "memory"
95
+
96
+ @drain_queue = settings.get_value("queue.drain") || settings.get("queue.type") == "memory"
186
97
 
187
98
 
188
99
  @events_filtered = java.util.concurrent.atomic.LongAdder.new
@@ -202,14 +113,14 @@ module LogStash; class Pipeline < BasePipeline
202
113
  end
203
114
 
204
115
  def safe_pipeline_worker_count
205
- default = @settings.get_default("pipeline.workers")
206
- pipeline_workers = @settings.get("pipeline.workers") #override from args "-w 8" or config
116
+ default = settings.get_default("pipeline.workers")
117
+ pipeline_workers = settings.get("pipeline.workers") #override from args "-w 8" or config
207
118
  safe_filters, unsafe_filters = @filters.partition(&:threadsafe?)
208
119
  plugins = unsafe_filters.collect { |f| f.config_name }
209
120
 
210
121
  return pipeline_workers if unsafe_filters.empty?
211
122
 
212
- if @settings.set?("pipeline.workers")
123
+ if settings.set?("pipeline.workers")
213
124
  if pipeline_workers > 1
214
125
  @logger.warn("Warning: Manual override - there are filters that might not work with multiple worker threads", default_logging_keys(:worker_threads => pipeline_workers, :filters => plugins))
215
126
  end
@@ -236,9 +147,9 @@ module LogStash; class Pipeline < BasePipeline
236
147
  collect_dlq_stats
237
148
 
238
149
  @logger.info("Starting pipeline", default_logging_keys(
239
- "pipeline.workers" => @settings.get("pipeline.workers"),
240
- "pipeline.batch.size" => @settings.get("pipeline.batch.size"),
241
- "pipeline.batch.delay" => @settings.get("pipeline.batch.delay")))
150
+ "pipeline.workers" => settings.get("pipeline.workers"),
151
+ "pipeline.batch.size" => settings.get("pipeline.batch.size"),
152
+ "pipeline.batch.delay" => settings.get("pipeline.batch.delay")))
242
153
 
243
154
  @finished_execution = Concurrent::AtomicBoolean.new(false)
244
155
 
@@ -307,12 +218,6 @@ module LogStash; class Pipeline < BasePipeline
307
218
  return 0
308
219
  end # def run
309
220
 
310
- def close
311
- @filter_queue_client.close
312
- @queue.close
313
- close_dlq_writer
314
- end
315
-
316
221
  def transition_to_running
317
222
  @running.make_true
318
223
  end
@@ -329,10 +234,6 @@ module LogStash; class Pipeline < BasePipeline
329
234
  @running.false?
330
235
  end
331
236
 
332
- def system?
333
- settings.get_value("pipeline.system")
334
- end
335
-
336
237
  # register_plugin simply calls the plugin #register method and catches & logs any error
337
238
  # @param plugin [Plugin] the plugin to register
338
239
  # @return [Plugin] the registered plugin
@@ -361,8 +262,8 @@ module LogStash; class Pipeline < BasePipeline
361
262
  maybe_setup_out_plugins
362
263
 
363
264
  pipeline_workers = safe_pipeline_worker_count
364
- batch_size = @settings.get("pipeline.batch.size")
365
- batch_delay = @settings.get("pipeline.batch.delay")
265
+ batch_size = settings.get("pipeline.batch.size")
266
+ batch_delay = settings.get("pipeline.batch.delay")
366
267
 
367
268
  max_inflight = batch_size * pipeline_workers
368
269
 
@@ -370,10 +271,10 @@ module LogStash; class Pipeline < BasePipeline
370
271
  config_metric.gauge(:workers, pipeline_workers)
371
272
  config_metric.gauge(:batch_size, batch_size)
372
273
  config_metric.gauge(:batch_delay, batch_delay)
373
- config_metric.gauge(:config_reload_automatic, @settings.get("config.reload.automatic"))
374
- config_metric.gauge(:config_reload_interval, @settings.get("config.reload.interval"))
274
+ config_metric.gauge(:config_reload_automatic, settings.get("config.reload.automatic"))
275
+ config_metric.gauge(:config_reload_interval, settings.get("config.reload.interval"))
375
276
  config_metric.gauge(:dead_letter_queue_enabled, dlq_enabled?)
376
- config_metric.gauge(:dead_letter_queue_path, @dlq_writer.get_path.to_absolute_path.to_s) if dlq_enabled?
277
+ config_metric.gauge(:dead_letter_queue_path, dlq_writer.get_path.to_absolute_path.to_s) if dlq_enabled?
377
278
 
378
279
  if max_inflight > MAX_INFLIGHT_WARN_THRESHOLD
379
280
  @logger.warn("CAUTION: Recommended inflight events max exceeded! Logstash will run with up to #{max_inflight} events in memory in your current configuration. If your message sizes are large this may cause instability with the default heap size. Please consider setting a non-standard heap size, changing the batch size (currently #{batch_size}), or changing the number of pipeline workers (currently #{pipeline_workers})", default_logging_keys)
@@ -403,19 +304,15 @@ module LogStash; class Pipeline < BasePipeline
403
304
  end
404
305
  end
405
306
 
406
- def dlq_enabled?
407
- @settings.get("dead_letter_queue.enable")
408
- end
409
-
410
307
  # Main body of what a worker thread does
411
308
  # Repeatedly takes batches off the queue, filters, then outputs them
412
309
  def worker_loop(batch_size, batch_delay)
413
- @filter_queue_client.set_batch_dimensions(batch_size, batch_delay)
310
+ filter_queue_client.set_batch_dimensions(batch_size, batch_delay)
414
311
  output_events_map = Hash.new { |h, k| h[k] = [] }
415
312
  while true
416
313
  signal = @signal_queue.poll || NO_SIGNAL
417
314
 
418
- batch = @filter_queue_client.read_batch.to_java # metrics are started in read_batch
315
+ batch = filter_queue_client.read_batch.to_java # metrics are started in read_batch
419
316
  batch_size = batch.filteredSize
420
317
  if batch_size > 0
421
318
  @events_consumed.add(batch_size)
@@ -424,7 +321,7 @@ module LogStash; class Pipeline < BasePipeline
424
321
  flush_filters_to_batch(batch, :final => false) if signal.flush?
425
322
  if batch.filteredSize > 0
426
323
  output_batch(batch, output_events_map)
427
- @filter_queue_client.close_batch(batch)
324
+ filter_queue_client.close_batch(batch)
428
325
  end
429
326
  # keep break at end of loop, after the read_batch operation, some pipeline specs rely on this "final read_batch" before shutdown.
430
327
  break if (@worker_shutdown.get && !draining_queue?)
@@ -432,11 +329,11 @@ module LogStash; class Pipeline < BasePipeline
432
329
 
433
330
  # we are shutting down, queue is drained if it was required, now perform a final flush.
434
331
  # for this we need to create a new empty batch to contain the final flushed events
435
- batch = @filter_queue_client.to_java.newBatch
436
- @filter_queue_client.start_metrics(batch) # explicitly call start_metrics since we dont do a read_batch here
332
+ batch = filter_queue_client.to_java.newBatch
333
+ filter_queue_client.start_metrics(batch) # explicitly call start_metrics since we dont do a read_batch here
437
334
  flush_filters_to_batch(batch, :final => true)
438
335
  output_batch(batch, output_events_map)
439
- @filter_queue_client.close_batch(batch)
336
+ filter_queue_client.close_batch(batch)
440
337
  end
441
338
 
442
339
  def filter_batch(batch)
@@ -444,7 +341,7 @@ module LogStash; class Pipeline < BasePipeline
444
341
  #these are both original and generated events
445
342
  batch.merge(e) unless e.cancelled?
446
343
  end
447
- @filter_queue_client.add_filtered_metrics(batch.filtered_size)
344
+ filter_queue_client.add_filtered_metrics(batch.filtered_size)
448
345
  @events_filtered.add(batch.filteredSize)
449
346
  rescue Exception => e
450
347
  # Plugins authors should manage their own exceptions in the plugin code
@@ -476,7 +373,7 @@ module LogStash; class Pipeline < BasePipeline
476
373
  events.clear
477
374
  end
478
375
 
479
- @filter_queue_client.add_output_metrics(batch.filtered_size)
376
+ filter_queue_client.add_output_metrics(batch.filtered_size)
480
377
  end
481
378
 
482
379
  def wait_inputs
@@ -508,8 +405,7 @@ module LogStash; class Pipeline < BasePipeline
508
405
  def inputworker(plugin)
509
406
  Util::set_thread_name("[#{pipeline_id}]<#{plugin.class.config_name}")
510
407
  begin
511
- input_queue_client = wrapped_write_client(plugin.id.to_sym)
512
- plugin.run(input_queue_client)
408
+ plugin.run(wrapped_write_client(plugin.id.to_sym))
513
409
  rescue => e
514
410
  if plugin.stop?
515
411
  @logger.debug("Input plugin raised exception during shutdown, ignoring it.",
@@ -663,41 +559,10 @@ module LogStash; class Pipeline < BasePipeline
663
559
  .each {|t| t.delete("status") }
664
560
  end
665
561
 
666
- def collect_dlq_stats
667
- if dlq_enabled?
668
- dlq_metric = @metric.namespace([:stats, :pipelines, pipeline_id.to_s.to_sym, :dlq])
669
- dlq_metric.gauge(:queue_size_in_bytes, @dlq_writer.get_current_queue_size)
670
- end
671
- end
672
-
673
- def collect_stats
674
- pipeline_metric = @metric.namespace([:stats, :pipelines, pipeline_id.to_s.to_sym, :queue])
675
- pipeline_metric.gauge(:type, settings.get("queue.type"))
676
- if @queue.is_a?(LogStash::WrappedAckedQueue) && @queue.queue.is_a?(LogStash::AckedQueue)
677
- queue = @queue.queue
678
- dir_path = queue.dir_path
679
- file_store = Files.get_file_store(Paths.get(dir_path))
680
-
681
- pipeline_metric.namespace([:capacity]).tap do |n|
682
- n.gauge(:page_capacity_in_bytes, queue.page_capacity)
683
- n.gauge(:max_queue_size_in_bytes, queue.max_size_in_bytes)
684
- n.gauge(:max_unread_events, queue.max_unread_events)
685
- n.gauge(:queue_size_in_bytes, queue.persisted_size_in_bytes)
686
- end
687
- pipeline_metric.namespace([:data]).tap do |n|
688
- n.gauge(:free_space_in_bytes, file_store.get_unallocated_space)
689
- n.gauge(:storage_type, file_store.type)
690
- n.gauge(:path, dir_path)
691
- end
692
-
693
- pipeline_metric.gauge(:events, queue.unread_count)
694
- end
695
- end
696
-
697
562
  def clear_pipeline_metrics
698
563
  # TODO(ph): I think the metric should also proxy that call correctly to the collector
699
564
  # this will simplify everything since the null metric would simply just do a noop
700
- collector = @metric.collector
565
+ collector = metric.collector
701
566
 
702
567
  unless collector.nil?
703
568
  # selectively reset metrics we don't wish to keep after reloading
@@ -713,8 +578,8 @@ module LogStash; class Pipeline < BasePipeline
713
578
  # We want to hide most of what's in here
714
579
  def inspect
715
580
  {
716
- :pipeline_id => @pipeline_id,
717
- :settings => @settings.inspect,
581
+ :pipeline_id => pipeline_id,
582
+ :settings => settings.inspect,
718
583
  :ready => @ready,
719
584
  :running => @running,
720
585
  :flushing => @flushing
@@ -737,13 +602,6 @@ module LogStash; class Pipeline < BasePipeline
737
602
  end
738
603
 
739
604
  def draining_queue?
740
- @drain_queue ? !@filter_queue_client.empty? : false
741
- end
742
-
743
- def wrapped_write_client(plugin_id)
744
- #need to ensure that metrics are initialized one plugin at a time, else a race condition can exist.
745
- @mutex.synchronize do
746
- LogStash::WrappedWriteClient.new(@input_queue_client, @pipeline_id.to_s.to_sym, metric, plugin_id)
747
- end
605
+ @drain_queue ? !filter_queue_client.empty? : false
748
606
  end
749
607
  end; end