Class: LogStash::Filters::ElasticIntegration

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/elastic_integration.rb

Constant Summary collapse

ELASTICSEARCH_DEFAULT_PORT =
9200.freeze
ELASTICSEARCH_DEFAULT_PATH =
'/'.freeze
HTTP_PROTOCOL =
"http".freeze
HTTPS_PROTOCOL =
"https".freeze
ELASTIC_API_VERSION =
"2023-10-31".freeze
USER_AGENT_HEADER_VALUE =
"Logstash/v#{LOGSTASH_VERSION} (ElasticIntegration/v#{VERSION})"

Instance Method Summary collapse

Constructor Details

#initialize(*a, &b) ⇒ ElasticIntegration

Validates that this plugin can be initialized BEFORE loading dependencies and delegating to super, so that when this plugin CANNOT be run the process is not encumbered by those dependencies.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/logstash/filters/elastic_integration.rb', line 106

def initialize(*a, &b)
  ensure_complete_logstash!
  ensure_java_major_version!(17)

  require_relative "elastic_integration/jar_dependencies"
  require_relative "elastic_integration/event_api_bridge"
  require_relative "elastic_integration/geoip_database_provider_bridge"

  extend EventApiBridge
  extend GeoipDatabaseProviderBridge

  super

  java_import('co.elastic.logstash.filters.elasticintegration.util.PluginContext')
  @plugin_context = PluginContext.new(execution_context&.pipeline_id || "UNDEF", id)
end

Instance Method Details

#closeObject



158
159
160
161
162
# File 'lib/logstash/filters/elastic_integration.rb', line 158

def close
  @elasticsearch_rest_client&.close
  @geoip_database_provider&.close
  @event_processor&.close
end

#filter(event) ⇒ Object

def register



140
141
142
# File 'lib/logstash/filters/elastic_integration.rb', line 140

def filter(event)
  fail "#{self.class}#filter is not allowed. Use #{self.class}#multi_filter"
end

#filter_matched_java(java_event) ⇒ Object



154
155
156
# File 'lib/logstash/filters/elastic_integration.rb', line 154

def filter_matched_java(java_event)
  filter_matched(mutable_ruby_view_of_java_event(java_event))
end

#multi_filter(ruby_api_events) ⇒ Object



144
145
146
147
148
149
150
151
152
# File 'lib/logstash/filters/elastic_integration.rb', line 144

def multi_filter(ruby_api_events)
  LogStash::Util.set_thread_plugin(self)

  incoming_java_api_events = ruby_events_as_java(ruby_api_events)

  outgoing_java_api_events = @event_processor.process_events(incoming_java_api_events)

  java_events_as_ruby(outgoing_java_api_events)
end

#registerObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/logstash/filters/elastic_integration.rb', line 123

def register
  @logger.debug("Registering `filter-elastic_integration` plugin.", :params => original_params)

  validate_connection_settings!
  @ssl_enabled = infer_ssl_from_connection_settings if @ssl_enabled.nil?

  validate_ssl_settings!
  validate_auth_settings!
  validate_and_normalize_hosts

  initialize_elasticsearch_rest_client!
  initialize_geoip_database_provider!
  initialize_event_processor!

  perform_preflight_check!
end