Skip to content

Commit b920701

Browse files
authored
Merge pull request #223 from mashhurs/support-elastic-transport-client
Adds elastic-transport client support.
2 parents 5f6e8da + be39bd3 commit b920701

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 5.0.2
2+
- Add elastic-transport client support used in elasticsearch-ruby 8.x [#223](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/223)
3+
14
## 5.0.1
25
- Fix: prevent plugin crash when hits contain illegal structure [#218](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/218)
36
- 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.

lib/logstash/inputs/elasticsearch.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
require "base64"
1414

1515
require "elasticsearch"
16-
require "elasticsearch/transport/transport/http/manticore"
17-
require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore"
18-
require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector"
16+
require "manticore"
1917

2018
# .Compatibility Note
2119
# [NOTE]
@@ -316,7 +314,7 @@ def register
316314
@client_options = {
317315
:hosts => hosts,
318316
:transport_options => transport_options,
319-
:transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
317+
:transport_class => get_transport_client_class,
320318
:ssl => ssl_options
321319
}
322320

@@ -642,6 +640,20 @@ def setup_query_executor
642640
end
643641
end
644642

643+
def get_transport_client_class
644+
# LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport`
645+
# And now `elasticsearch-transport` is old, instead we have `elastic-transport`.
646+
# LS-core updated `elasticsearch` > 8: https://github.com/elastic/logstash/pull/17161
647+
# Following source bits are for the compatibility to support both `elasticsearch-transport` and `elastic-transport` gems
648+
require "elasticsearch/transport/transport/http/manticore"
649+
require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore"
650+
require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector"
651+
::Elasticsearch::Transport::Transport::HTTP::Manticore
652+
rescue ::LoadError
653+
require "elastic/transport/transport/http/manticore"
654+
::Elastic::Transport::Transport::HTTP::Manticore
655+
end
656+
645657
module URIOrEmptyValidator
646658
##
647659
# @override to provide :uri_or_empty validator

logstash-input-elasticsearch.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-input-elasticsearch'
4-
s.version = '5.0.1'
4+
s.version = '5.0.2'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Reads query results from an Elasticsearch cluster"
77
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"
88
s.authors = ["Elastic"]
99
s.email = '[email protected]'
10-
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10+
s.homepage = "https://elastic.co/logstash"
1111
s.require_paths = ["lib"]
1212

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

29-
s.add_runtime_dependency 'elasticsearch', '>= 7.17.9'
29+
s.add_runtime_dependency 'elasticsearch', '>= 7.17.9', '< 9'
3030
s.add_runtime_dependency 'logstash-mixin-ca_trusted_fingerprint_support', '~> 1.0'
3131
s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'
3232

0 commit comments

Comments
 (0)