logstash-input-elasticsearch 4.17.1 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/logstash/inputs/elasticsearch.rb +36 -4
- data/logstash-input-elasticsearch.gemspec +2 -2
- data/spec/inputs/elasticsearch_spec.rb +46 -2
- data/spec/inputs/elasticsearch_ssl_spec.rb +5 -3
- data/spec/inputs/integration/elasticsearch_spec.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035d372d2fbedd9c038c2ad182ea8826ce35f73dab09d7c1534dde9b019e6c82
|
4
|
+
data.tar.gz: 04a65a4a915231720975f25d614d44bb9b3b8f5cdde77142178b66eb6678be1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beee15cfed06fbee80b9ac7b3bd389e8fb0c5ca6f290a81cdb2f6389293bc32859c555a00483c3456854fb5e04ff6d64e23f272a17995f5677f544bd0916d966
|
7
|
+
data.tar.gz: 7152b896548b45f1c1dbeb973e6c10efbed2e76a0c2a9082aa0c6f1e24475a04e6b4537cff1d5d2265b1ce249fb4dddfd136cbbeb5808e870ff70434a033fb43
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 4.18.0
|
2
|
+
- Added request header `Elastic-Api-Version` for serverless [#195](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/195)
|
3
|
+
|
4
|
+
## 4.17.2
|
5
|
+
- Fixes a regression introduced in 4.17.0 which could prevent a connection from being established to Elasticsearch in some SSL configurations [#193](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/193)
|
6
|
+
|
1
7
|
## 4.17.1
|
2
8
|
- Fix: scroll slice high memory consumption [#189](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/189)
|
3
9
|
|
@@ -258,6 +258,9 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
258
258
|
|
259
259
|
attr_reader :pipeline_id
|
260
260
|
|
261
|
+
BUILD_FLAVOR_SERVERLESS = 'serverless'.freeze
|
262
|
+
DEFAULT_EAV_HEADER = { "Elastic-Api-Version" => "2023-10-31" }.freeze
|
263
|
+
|
261
264
|
def initialize(params={})
|
262
265
|
super(params)
|
263
266
|
|
@@ -305,13 +308,19 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
305
308
|
|
306
309
|
transport_options[:proxy] = @proxy.to_s if @proxy && !@proxy.eql?('')
|
307
310
|
|
308
|
-
@
|
311
|
+
@client_options = {
|
309
312
|
:hosts => hosts,
|
310
313
|
:transport_options => transport_options,
|
311
314
|
:transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
|
312
315
|
:ssl => ssl_options
|
313
|
-
|
316
|
+
}
|
317
|
+
|
318
|
+
@client = Elasticsearch::Client.new(@client_options)
|
319
|
+
|
314
320
|
test_connection!
|
321
|
+
|
322
|
+
setup_serverless
|
323
|
+
|
315
324
|
@client
|
316
325
|
end
|
317
326
|
|
@@ -435,7 +444,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
435
444
|
@client.scroll(:body => { :scroll_id => scroll_id }, :scroll => @scroll)
|
436
445
|
end
|
437
446
|
|
438
|
-
def search_request(options)
|
447
|
+
def search_request(options={})
|
439
448
|
@client.search(options)
|
440
449
|
end
|
441
450
|
|
@@ -521,7 +530,9 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
521
530
|
"to make sure your data is secure set `ssl_verification_mode => full`"
|
522
531
|
ssl_options[:verify] = :disable
|
523
532
|
else
|
524
|
-
|
533
|
+
# Manticore's :default maps to Apache HTTP Client's DefaultHostnameVerifier,
|
534
|
+
# which is the modern STRICT verifier that replaces the deprecated StrictHostnameVerifier
|
535
|
+
ssl_options[:verify] = :default
|
525
536
|
end
|
526
537
|
end
|
527
538
|
|
@@ -666,6 +677,27 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
666
677
|
raise LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch"
|
667
678
|
end
|
668
679
|
|
680
|
+
# recreate client with default header when it is serverless
|
681
|
+
# verify the header by sending GET /
|
682
|
+
def setup_serverless
|
683
|
+
if serverless?
|
684
|
+
@client_options[:transport_options][:headers].merge!(DEFAULT_EAV_HEADER)
|
685
|
+
@client = Elasticsearch::Client.new(@client_options)
|
686
|
+
@client.info
|
687
|
+
end
|
688
|
+
rescue => e
|
689
|
+
@logger.error("Failed to retrieve Elasticsearch info", message: e.message, exception: e.class, backtrace: e.backtrace)
|
690
|
+
raise LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch"
|
691
|
+
end
|
692
|
+
|
693
|
+
def build_flavor
|
694
|
+
@build_flavor ||= @client.info&.dig('version', 'build_flavor')
|
695
|
+
end
|
696
|
+
|
697
|
+
def serverless?
|
698
|
+
@is_serverless ||= (build_flavor == BUILD_FLAVOR_SERVERLESS)
|
699
|
+
end
|
700
|
+
|
669
701
|
module URIOrEmptyValidator
|
670
702
|
##
|
671
703
|
# @override to provide :uri_or_empty validator
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-elasticsearch'
|
4
|
-
s.version = '4.
|
4
|
+
s.version = '4.18.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Reads query results from an Elasticsearch cluster"
|
7
7
|
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"
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
|
27
27
|
s.add_runtime_dependency "logstash-mixin-scheduler", '~> 1.0'
|
28
28
|
|
29
|
-
s.add_runtime_dependency 'elasticsearch', '>= 7.17.
|
29
|
+
s.add_runtime_dependency 'elasticsearch', '>= 7.17.9'
|
30
30
|
s.add_runtime_dependency 'logstash-mixin-ca_trusted_fingerprint_support', '~> 1.0'
|
31
31
|
s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'
|
32
32
|
|
@@ -17,9 +17,12 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
17
17
|
|
18
18
|
let(:plugin) { described_class.new(config) }
|
19
19
|
let(:queue) { Queue.new }
|
20
|
+
let(:build_flavor) { "default" }
|
21
|
+
let(:cluster_info) { {"version" => {"number" => "7.5.0", "build_flavor" => build_flavor}, "tagline" => "You Know, for Search"} }
|
20
22
|
|
21
23
|
before(:each) do
|
22
24
|
Elasticsearch::Client.send(:define_method, :ping) { } # define no-action ping method
|
25
|
+
allow_any_instance_of(Elasticsearch::Client).to receive(:info).and_return(cluster_info)
|
23
26
|
end
|
24
27
|
|
25
28
|
let(:base_config) do
|
@@ -39,7 +42,13 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
39
42
|
context "against authentic Elasticsearch" do
|
40
43
|
it "should not raise an exception" do
|
41
44
|
expect { plugin.register }.to_not raise_error
|
42
|
-
|
45
|
+
end
|
46
|
+
|
47
|
+
it "does not set header Elastic-Api-Version" do
|
48
|
+
plugin.register
|
49
|
+
client = plugin.send(:client)
|
50
|
+
expect( extract_transport(client).options[:transport_options][:headers] ).not_to match hash_including("Elastic-Api-Version" => "2023-10-31")
|
51
|
+
end
|
43
52
|
end
|
44
53
|
|
45
54
|
context "against not authentic Elasticsearch" do
|
@@ -52,6 +61,37 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
52
61
|
end
|
53
62
|
end
|
54
63
|
|
64
|
+
context "against serverless Elasticsearch" do
|
65
|
+
before do
|
66
|
+
allow(plugin).to receive(:test_connection!)
|
67
|
+
allow(plugin).to receive(:serverless?).and_return(true)
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with unsupported header" do
|
71
|
+
let(:es_client) { double("es_client") }
|
72
|
+
|
73
|
+
before do
|
74
|
+
allow(Elasticsearch::Client).to receive(:new).and_return(es_client)
|
75
|
+
allow(es_client).to receive(:info).and_raise(
|
76
|
+
Elasticsearch::Transport::Transport::Errors::BadRequest.new
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises an exception" do
|
81
|
+
expect {plugin.register}.to raise_error(LogStash::ConfigurationError)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with supported header" do
|
86
|
+
it "set default header to rest client" do
|
87
|
+
expect_any_instance_of(Elasticsearch::Client).to receive(:info).and_return(true)
|
88
|
+
plugin.register
|
89
|
+
client = plugin.send(:client)
|
90
|
+
expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_including("Elastic-Api-Version" => "2023-10-31")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
55
95
|
context "retry" do
|
56
96
|
let(:config) do
|
57
97
|
{
|
@@ -85,6 +125,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
85
125
|
allow(@esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
|
86
126
|
allow(@esclient).to receive(:clear_scroll).and_return(nil)
|
87
127
|
allow(@esclient).to receive(:ping)
|
128
|
+
allow(@esclient).to receive(:info).and_return(cluster_info)
|
88
129
|
end
|
89
130
|
end
|
90
131
|
|
@@ -869,7 +910,9 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
869
910
|
let(:plugin) { described_class.new(config) }
|
870
911
|
let(:event) { LogStash::Event.new({}) }
|
871
912
|
|
872
|
-
|
913
|
+
# elasticsearch-ruby 7.17.9 initialize two user agent headers, `user-agent` and `User-Agent`
|
914
|
+
# hence, fail this header size test case
|
915
|
+
xit "client should sent the expect user-agent" do
|
873
916
|
plugin.register
|
874
917
|
|
875
918
|
queue = []
|
@@ -916,6 +959,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
916
959
|
expect(transport_options[manticore_transport_option]).to eq(config_value.to_i)
|
917
960
|
mock_client = double("fake_client")
|
918
961
|
allow(mock_client).to receive(:ping)
|
962
|
+
allow(mock_client).to receive(:info).and_return(cluster_info)
|
919
963
|
mock_client
|
920
964
|
end
|
921
965
|
|
@@ -14,6 +14,8 @@ describe "SSL options" do
|
|
14
14
|
before do
|
15
15
|
allow(es_client_double).to receive(:close)
|
16
16
|
allow(es_client_double).to receive(:ping).with(any_args).and_return(double("pong").as_null_object)
|
17
|
+
allow(es_client_double).to receive(:info).and_return({"version" => {"number" => "7.5.0", "build_flavor" => "default"},
|
18
|
+
"tagline" => "You Know, for Search"})
|
17
19
|
allow(Elasticsearch::Client).to receive(:new).and_return(es_client_double)
|
18
20
|
end
|
19
21
|
|
@@ -123,7 +125,7 @@ describe "SSL options" do
|
|
123
125
|
|
124
126
|
it "should pass the flag to the ES client" do
|
125
127
|
expect(::Elasticsearch::Client).to receive(:new) do |args|
|
126
|
-
expect(args[:ssl]).to match hash_including(:ssl => true, :verify => :
|
128
|
+
expect(args[:ssl]).to match hash_including(:ssl => true, :verify => :default)
|
127
129
|
end.and_return(es_client_double)
|
128
130
|
|
129
131
|
subject.register
|
@@ -200,7 +202,7 @@ describe "SSL options" do
|
|
200
202
|
:truststore => ssl_truststore_path,
|
201
203
|
:truststore_type => "jks",
|
202
204
|
:truststore_password => "foo",
|
203
|
-
:verify => :
|
205
|
+
:verify => :default,
|
204
206
|
:cipher_suites => ["TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"],
|
205
207
|
:protocols => ["TLSv1.3"],
|
206
208
|
)
|
@@ -236,7 +238,7 @@ describe "SSL options" do
|
|
236
238
|
:ca_file => ssl_certificate_authorities_path,
|
237
239
|
:client_cert => ssl_certificate_path,
|
238
240
|
:client_key => ssl_key_path,
|
239
|
-
:verify => :
|
241
|
+
:verify => :default,
|
240
242
|
:cipher_suites => ["TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"],
|
241
243
|
:protocols => ["TLSv1.3"],
|
242
244
|
)
|
@@ -4,7 +4,7 @@ require "logstash/plugin"
|
|
4
4
|
require "logstash/inputs/elasticsearch"
|
5
5
|
require_relative "../../../spec/es_helper"
|
6
6
|
|
7
|
-
describe LogStash::Inputs::Elasticsearch do
|
7
|
+
describe LogStash::Inputs::Elasticsearch, :integration => true do
|
8
8
|
|
9
9
|
SECURE_INTEGRATION = ENV['SECURE_INTEGRATION'].eql? 'true'
|
10
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,7 +91,7 @@ dependencies:
|
|
91
91
|
requirements:
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 7.17.
|
94
|
+
version: 7.17.9
|
95
95
|
name: elasticsearch
|
96
96
|
prerelease: false
|
97
97
|
type: :runtime
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 7.17.
|
102
|
+
version: 7.17.9
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
@@ -304,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
304
|
- !ruby/object:Gem::Version
|
305
305
|
version: '0'
|
306
306
|
requirements: []
|
307
|
-
rubygems_version: 3.
|
307
|
+
rubygems_version: 3.2.33
|
308
308
|
signing_key:
|
309
309
|
specification_version: 4
|
310
310
|
summary: Reads query results from an Elasticsearch cluster
|