Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 5.0.2
- Add elastic-transport client support used in elasticsearch-ruby 8.x [#223](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/223)

## 5.0.1
- Fix: prevent plugin crash when hits contain illegal structure [#218](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/218)
- When a hit cannot be converted to an event, the input now emits an event tagged with `_elasticsearch_input_failure` with an `[event][original]` containing a JSON-encoded string representation of the entire hit.
Expand Down
20 changes: 16 additions & 4 deletions lib/logstash/inputs/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
require "base64"

require "elasticsearch"
require "elasticsearch/transport/transport/http/manticore"
require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore"
require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector"
require "manticore"

# .Compatibility Note
# [NOTE]
Expand Down Expand Up @@ -316,7 +314,7 @@ def register
@client_options = {
:hosts => hosts,
:transport_options => transport_options,
:transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
:transport_class => get_transport_client_class,
:ssl => ssl_options
}

Expand Down Expand Up @@ -642,6 +640,20 @@ def setup_query_executor
end
end

def get_transport_client_class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment here explaining what's happening

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added.

# LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport`
# And now `elasticsearch-transport` is old, instead we have `elastic-transport`.
# LS-core updated `elasticsearch` > 8: https://github.com/elastic/logstash/pull/17161
# Following source bits are for the compatibility to support both `elasticsearch-transport` and `elastic-transport` gems
require "elasticsearch/transport/transport/http/manticore"
require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review note:

  • _elasticsearch_transport_http_manticore sets
    set user-agent and accept-encoding headers for the es-transport-client versions between 7.2 and 7.16. It seems to me we can remove this but I have kept so far as there are active 7.x users;
  • _elasticsearch_transport_connections_selector has a round-robin load balancer logic for the es-client versions <7.2.0

I have kept them for now but it looks to me we can remove.

require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector"
::Elasticsearch::Transport::Transport::HTTP::Manticore
rescue ::LoadError
require "elastic/transport/transport/http/manticore"
::Elastic::Transport::Transport::HTTP::Manticore
end

module URIOrEmptyValidator
##
# @override to provide :uri_or_empty validator
Expand Down
6 changes: 3 additions & 3 deletions logstash-input-elasticsearch.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Gem::Specification.new do |s|

s.name = 'logstash-input-elasticsearch'
s.version = '5.0.1'
s.version = '5.0.2'
s.licenses = ['Apache License (2.0)']
s.summary = "Reads query results from an Elasticsearch cluster"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
s.authors = ["Elastic"]
s.email = '[email protected]'
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
s.homepage = "https://elastic.co/logstash"
s.require_paths = ["lib"]

# Files
Expand All @@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
s.add_runtime_dependency "logstash-mixin-scheduler", '~> 1.0'

s.add_runtime_dependency 'elasticsearch', '>= 7.17.9'
s.add_runtime_dependency 'elasticsearch', '>= 7.17.9', '< 9'
s.add_runtime_dependency 'logstash-mixin-ca_trusted_fingerprint_support', '~> 1.0'
s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'

Expand Down
Loading