diff --git a/CHANGELOG.md b/CHANGELOG.md index 00c0b68..bc00c0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/logstash/inputs/elasticsearch.rb b/lib/logstash/inputs/elasticsearch.rb index dd1f047..c9d8b55 100644 --- a/lib/logstash/inputs/elasticsearch.rb +++ b/lib/logstash/inputs/elasticsearch.rb @@ -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] @@ -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 } @@ -642,6 +640,20 @@ def setup_query_executor end end + def get_transport_client_class + # 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" + 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 diff --git a/logstash-input-elasticsearch.gemspec b/logstash-input-elasticsearch.gemspec index 5a08eea..8e36201 100644 --- a/logstash-input-elasticsearch.gemspec +++ b/logstash-input-elasticsearch.gemspec @@ -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 = 'info@elastic.co' - s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html" + s.homepage = "https://elastic.co/logstash" s.require_paths = ["lib"] # Files @@ -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'