lib/logstash/inputs/jdbc.rb in logstash-integration-jdbc-5.1.4 vs lib/logstash/inputs/jdbc.rb in logstash-integration-jdbc-5.1.5
- old
+ new
@@ -2,12 +2,15 @@
require "logstash/inputs/base"
require "logstash/namespace"
require "logstash/plugin_mixins/jdbc/common"
require "logstash/plugin_mixins/jdbc/jdbc"
require "logstash/plugin_mixins/ecs_compatibility_support"
+require "logstash/plugin_mixins/ecs_compatibility_support/target_check"
require "logstash/plugin_mixins/validator_support/field_reference_validation_adapter"
+require "logstash/plugin_mixins/event_support/event_factory_adapter"
+
# this require_relative returns early unless the JRuby version is between 9.2.0.0 and 9.2.8.0
require_relative "tzinfo_jruby_patch"
# This plugin was created as a way to ingest data from any database
# with a JDBC interface into Logstash. You can periodically schedule ingestion
@@ -129,12 +132,18 @@
# ---------------------------------------------------------------------------------------------------
#
module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
include LogStash::PluginMixins::Jdbc::Common
include LogStash::PluginMixins::Jdbc::Jdbc
+
# adds ecs_compatibility config which could be :disabled or :v1
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled,:v1,:v8 => :v1)
+ include LogStash::PluginMixins::ECSCompatibilitySupport::TargetCheck
+
+ # adds `event_factory` and `targeted_event_factory
+ include LogStash::PluginMixins::EventSupport::EventFactoryAdapter
+
# adds :field_reference validator adapter
extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
config_name "jdbc"
@@ -268,17 +277,10 @@
converter = LogStash::Util::Charset.new(encoding)
converter.logger = self.logger
converters[encoding] = converter
end
end
-
- # target must be populated if ecs_compatibility is not :disabled
- if @target.nil? && ecs_compatibility != :disabled
- logger.info('ECS compatibility is enabled but no ``target`` option was specified, it is recommended'\
- ' to set the option to avoid potential schema conflicts (if your data is ECS compliant or'\
- ' non-conflicting feel free to ignore this message)')
- end
end # def register
# test injection points
def set_statement_logger(instance)
@statement_handler = LogStash::PluginMixins::Jdbc::StatementHandler.build_statement_handler(self, instance)
@@ -333,15 +335,10 @@
execute_statement do |row|
if enable_encoding?
## do the necessary conversions to string elements
row = Hash[row.map { |k, v| [k.to_s, convert(k, v)] }]
end
- if @target
- event = LogStash::Event.new
- event.set(@target, row)
- else
- event = LogStash::Event.new(row)
- end
+ event = targeted_event_factory.new_event(row)
decorate(event)
queue << event
end
@value_tracker.write
end