logstash-input-elasticsearch 4.10.0 → 4.12.2
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 +12 -0
- data/Gemfile +3 -0
- data/lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_http_manticore.rb +11 -1
- data/lib/logstash/inputs/elasticsearch.rb +28 -7
- data/logstash-input-elasticsearch.gemspec +5 -3
- data/spec/inputs/elasticsearch_spec.rb +197 -8
- data/spec/inputs/integration/elasticsearch_spec.rb +42 -9
- metadata +47 -23
- data/spec/fixtures/test_certs/client/ls.crt +0 -20
- data/spec/fixtures/test_certs/client/ls.key +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caea2fedebb629d87471f67b2b03f43186e7e2b02e854e3f6df7154a64316f16
|
4
|
+
data.tar.gz: 1d75f76b97d6d8ea481637399b1ea82668f5fb47ea52a2f1a51034594b55375f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07af682a46bc7aa7bd48b0d4c4f0a4baa9e8dd5a8848821863b67fe4b2ee5890655d76de1de782938be0b73bf3057228a94ccbf155b7fb9ecaa81077831362e5
|
7
|
+
data.tar.gz: 0031f21cc9d7e41dfdbf9de400b33e21a1b9abda7c9ca2159fb21623ff5cf21258b99670d22090eda39ad42141408166c10317874ea6682e4e3b756e031355a1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 4.12.2
|
2
|
+
- Fix: hosts => "es_host:port" regression [#168](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/168)
|
3
|
+
|
4
|
+
## 4.12.1
|
5
|
+
- Fixed too_long_frame_exception by passing scroll_id in the body [#159](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/159)
|
6
|
+
|
7
|
+
## 4.12.0
|
8
|
+
- Feat: Update Elasticsearch client to 7.14.0 [#157](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/157)
|
9
|
+
|
10
|
+
## 4.11.0
|
11
|
+
- Feat: add user-agent header passed to the Elasticsearch HTTP connection [#158](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/158)
|
12
|
+
|
1
13
|
## 4.10.0
|
2
14
|
- Feat: added ecs_compatibility + event_factory support [#149](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/149)
|
3
15
|
|
data/Gemfile
CHANGED
@@ -9,3 +9,6 @@ if Dir.exist?(logstash_path) && use_logstash_source
|
|
9
9
|
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
10
|
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
11
|
end
|
12
|
+
|
13
|
+
gem 'manticore', ENV['MANTICORE_VERSION'] if ENV['MANTICORE_VERSION']
|
14
|
+
gem 'elasticsearch', ENV['ELASTICSEARCH_VERSION'] if ENV['ELASTICSEARCH_VERSION']
|
@@ -20,7 +20,17 @@ if es_client_version >= Gem::Version.new('7.2') && es_client_version < Gem::Vers
|
|
20
20
|
def apply_headers(request_options, options)
|
21
21
|
headers = (options && options[:headers]) || {}
|
22
22
|
headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
|
23
|
-
|
23
|
+
|
24
|
+
# this code is necessary to grab the correct user-agent header
|
25
|
+
# when this method is invoked with apply_headers(@request_options, options)
|
26
|
+
# from https://github.com/elastic/elasticsearch-ruby/blob/v7.14.0/elasticsearch-transport/lib/elasticsearch/transport/transport/http/manticore.rb#L113-L114
|
27
|
+
transport_user_agent = nil
|
28
|
+
if (options && options[:transport_options] && options[:transport_options][:headers])
|
29
|
+
transport_headers = options[:transport_options][:headers]
|
30
|
+
transport_user_agent = find_value(transport_headers, USER_AGENT_REGEX)
|
31
|
+
end
|
32
|
+
|
33
|
+
headers[USER_AGENT_STR] = transport_user_agent || find_value(headers, USER_AGENT_REGEX) || user_agent_header
|
24
34
|
headers[ACCEPT_ENCODING] = GZIP if use_compression?
|
25
35
|
(request_options[:headers] ||= {}).merge!(headers) # this line was changed
|
26
36
|
end
|
@@ -222,6 +222,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
222
222
|
transport_options = {:headers => {}}
|
223
223
|
transport_options[:headers].merge!(setup_basic_auth(user, password))
|
224
224
|
transport_options[:headers].merge!(setup_api_key(api_key))
|
225
|
+
transport_options[:headers].merge!({'user-agent' => prepare_user_agent()})
|
225
226
|
transport_options[:request_timeout] = @request_timeout_seconds unless @request_timeout_seconds.nil?
|
226
227
|
transport_options[:connect_timeout] = @connect_timeout_seconds unless @connect_timeout_seconds.nil?
|
227
228
|
transport_options[:socket_timeout] = @socket_timeout_seconds unless @socket_timeout_seconds.nil?
|
@@ -239,6 +240,8 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
239
240
|
:transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
|
240
241
|
:ssl => ssl_options
|
241
242
|
)
|
243
|
+
test_connection!
|
244
|
+
@client
|
242
245
|
end
|
243
246
|
|
244
247
|
|
@@ -344,7 +347,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
344
347
|
end
|
345
348
|
|
346
349
|
def clear_scroll(scroll_id)
|
347
|
-
@client.clear_scroll(
|
350
|
+
@client.clear_scroll(:body => { :scroll_id => scroll_id }) if scroll_id
|
348
351
|
rescue => e
|
349
352
|
# ignore & log any clear_scroll errors
|
350
353
|
logger.warn("Ignoring clear_scroll exception", message: e.message, exception: e.class)
|
@@ -383,13 +386,13 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
383
386
|
|
384
387
|
def setup_hosts
|
385
388
|
@hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
389
|
+
@hosts.map do |h|
|
390
|
+
if h.start_with?('http:', 'https:')
|
391
|
+
h
|
392
|
+
else
|
393
|
+
host, port = h.split(':')
|
394
|
+
{ host: host, port: port, scheme: (@ssl ? 'https' : 'http') }
|
390
395
|
end
|
391
|
-
else
|
392
|
-
@hosts
|
393
396
|
end
|
394
397
|
end
|
395
398
|
|
@@ -407,6 +410,18 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
407
410
|
{ 'Authorization' => "ApiKey #{token}" }
|
408
411
|
end
|
409
412
|
|
413
|
+
def prepare_user_agent
|
414
|
+
os_name = java.lang.System.getProperty('os.name')
|
415
|
+
os_version = java.lang.System.getProperty('os.version')
|
416
|
+
os_arch = java.lang.System.getProperty('os.arch')
|
417
|
+
jvm_vendor = java.lang.System.getProperty('java.vendor')
|
418
|
+
jvm_version = java.lang.System.getProperty('java.version')
|
419
|
+
|
420
|
+
plugin_version = Gem.loaded_specs["logstash-input-elasticsearch"].version
|
421
|
+
# example: logstash/7.14.1 (OS=Linux-5.4.0-84-generic-amd64; JVM=AdoptOpenJDK-11.0.11) logstash-input-elasticsearch/4.10.0
|
422
|
+
"logstash/#{LOGSTASH_VERSION} (OS=#{os_name}-#{os_version}-#{os_arch}; JVM=#{jvm_vendor}-#{jvm_version}) logstash-#{@plugin_type}-#{config_name}/#{plugin_version}"
|
423
|
+
end
|
424
|
+
|
410
425
|
def fill_user_password_from_cloud_auth
|
411
426
|
return unless @cloud_auth
|
412
427
|
|
@@ -460,6 +475,12 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
460
475
|
# @private used by unit specs
|
461
476
|
attr_reader :client
|
462
477
|
|
478
|
+
def test_connection!
|
479
|
+
@client.ping
|
480
|
+
rescue Elasticsearch::UnsupportedProductError
|
481
|
+
raise LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch"
|
482
|
+
end
|
483
|
+
|
463
484
|
module URIOrEmptyValidator
|
464
485
|
##
|
465
486
|
# @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.12.2'
|
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"
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0'
|
26
26
|
s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
|
27
27
|
|
28
|
-
s.add_runtime_dependency 'elasticsearch', '>=
|
28
|
+
s.add_runtime_dependency 'elasticsearch', '>= 7.14.0' # LS >= 6.7 and < 7.14 all used version 5.0.5
|
29
29
|
|
30
30
|
s.add_runtime_dependency 'tzinfo'
|
31
31
|
s.add_runtime_dependency 'tzinfo-data'
|
@@ -33,7 +33,9 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_runtime_dependency 'manticore', ">= 0.7.1"
|
34
34
|
|
35
35
|
s.add_development_dependency 'logstash-codec-plain'
|
36
|
-
s.add_development_dependency 'faraday', "~>
|
36
|
+
s.add_development_dependency 'faraday', "~> 1"
|
37
37
|
s.add_development_dependency 'logstash-devutils'
|
38
38
|
s.add_development_dependency 'timecop'
|
39
|
+
s.add_development_dependency 'cabin', ['~> 0.6']
|
40
|
+
s.add_development_dependency 'webrick'
|
39
41
|
end
|
@@ -7,6 +7,9 @@ require "timecop"
|
|
7
7
|
require "stud/temporary"
|
8
8
|
require "time"
|
9
9
|
require "date"
|
10
|
+
require "cabin"
|
11
|
+
require "webrick"
|
12
|
+
require "uri"
|
10
13
|
|
11
14
|
require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
|
12
15
|
|
@@ -15,6 +18,34 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
15
18
|
let(:plugin) { described_class.new(config) }
|
16
19
|
let(:queue) { Queue.new }
|
17
20
|
|
21
|
+
before(:each) do
|
22
|
+
Elasticsearch::Client.send(:define_method, :ping) { } # define no-action ping method
|
23
|
+
end
|
24
|
+
|
25
|
+
context "register" do
|
26
|
+
let(:config) do
|
27
|
+
{
|
28
|
+
"schedule" => "* * * * * UTC"
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
context "against authentic Elasticsearch" do
|
33
|
+
it "should not raise an exception" do
|
34
|
+
expect { plugin.register }.to_not raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "against not authentic Elasticsearch" do
|
39
|
+
before(:each) do
|
40
|
+
Elasticsearch::Client.send(:define_method, :ping) { raise Elasticsearch::UnsupportedProductError.new("Fake error") } # define error ping method
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should raise ConfigurationError" do
|
44
|
+
expect { plugin.register }.to raise_error(LogStash::ConfigurationError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
18
49
|
it_behaves_like "an interruptible input plugin" do
|
19
50
|
let(:esclient) { double("elasticsearch-client") }
|
20
51
|
let(:config) do
|
@@ -35,6 +66,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
35
66
|
allow(esclient).to receive(:search) { { "hits" => { "hits" => [hit] } } }
|
36
67
|
allow(esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
|
37
68
|
allow(esclient).to receive(:clear_scroll).and_return(nil)
|
69
|
+
allow(esclient).to receive(:ping)
|
38
70
|
end
|
39
71
|
end
|
40
72
|
|
@@ -93,6 +125,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
93
125
|
expect(client).to receive(:search).with(any_args).and_return(mock_response)
|
94
126
|
expect(client).to receive(:scroll).with({ :body => { :scroll_id => "cXVlcnlUaGVuRmV0Y2g" }, :scroll=> "1m" }).and_return(mock_scroll_response)
|
95
127
|
expect(client).to receive(:clear_scroll).and_return(nil)
|
128
|
+
expect(client).to receive(:ping)
|
96
129
|
end
|
97
130
|
|
98
131
|
it 'creates the events from the hits' do
|
@@ -308,6 +341,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
308
341
|
expect(client).to receive(:search).with(hash_including(:body => slice0_query)).and_return(slice0_response0)
|
309
342
|
expect(client).to receive(:scroll).with(hash_including(:body => { :scroll_id => slice0_scroll1 })).and_return(slice0_response1)
|
310
343
|
expect(client).to receive(:scroll).with(hash_including(:body => { :scroll_id => slice0_scroll2 })).and_return(slice0_response2)
|
344
|
+
allow(client).to receive(:ping)
|
311
345
|
|
312
346
|
# SLICE1 is a two-page scroll in which the last page has no next scroll id
|
313
347
|
slice1_query = LogStash::Json.dump(query.merge('slice' => { 'id' => 1, 'max' => 2}))
|
@@ -407,6 +441,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
407
441
|
expect(client).to receive(:search).with(any_args).and_return(response)
|
408
442
|
allow(client).to receive(:scroll).with({ :body => {:scroll_id => "cXVlcnlUaGVuRmV0Y2g"}, :scroll => "1m" }).and_return(scroll_reponse)
|
409
443
|
allow(client).to receive(:clear_scroll).and_return(nil)
|
444
|
+
allow(client).to receive(:ping).and_return(nil)
|
410
445
|
end
|
411
446
|
|
412
447
|
ecs_compatibility_matrix(:disabled, :v1, :v8) do |ecs_select|
|
@@ -583,13 +618,14 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
583
618
|
it "should set host(s)" do
|
584
619
|
plugin.register
|
585
620
|
client = plugin.send(:client)
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
621
|
+
|
622
|
+
expect( client.transport.instance_variable_get(:@seeds) ).to eql [{
|
623
|
+
:scheme => "https",
|
624
|
+
:host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
|
625
|
+
:port => 9243,
|
626
|
+
:path => "",
|
627
|
+
:protocol => "https"
|
628
|
+
}]
|
593
629
|
end
|
594
630
|
|
595
631
|
context 'invalid' do
|
@@ -690,7 +726,157 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
690
726
|
end
|
691
727
|
end
|
692
728
|
|
693
|
-
|
729
|
+
class StoppableServer
|
730
|
+
|
731
|
+
attr_reader :port
|
732
|
+
|
733
|
+
def initialize()
|
734
|
+
queue = Queue.new
|
735
|
+
@first_req_waiter = java.util.concurrent.CountDownLatch.new(1)
|
736
|
+
@first_request = nil
|
737
|
+
|
738
|
+
@t = java.lang.Thread.new(
|
739
|
+
proc do
|
740
|
+
begin
|
741
|
+
@server = WEBrick::HTTPServer.new :Port => 0, :DocumentRoot => ".",
|
742
|
+
:Logger => Cabin::Channel.get, # silence WEBrick logging
|
743
|
+
:StartCallback => Proc.new {
|
744
|
+
queue.push("started")
|
745
|
+
}
|
746
|
+
@port = @server.config[:Port]
|
747
|
+
@server.mount_proc '/' do |req, res|
|
748
|
+
res.body = '''
|
749
|
+
{
|
750
|
+
"name": "ce7ccfb438e8",
|
751
|
+
"cluster_name": "docker-cluster",
|
752
|
+
"cluster_uuid": "DyR1hN03QvuCWXRy3jtb0g",
|
753
|
+
"version": {
|
754
|
+
"number": "7.13.1",
|
755
|
+
"build_flavor": "default",
|
756
|
+
"build_type": "docker",
|
757
|
+
"build_hash": "9a7758028e4ea59bcab41c12004603c5a7dd84a9",
|
758
|
+
"build_date": "2021-05-28T17:40:59.346932922Z",
|
759
|
+
"build_snapshot": false,
|
760
|
+
"lucene_version": "8.8.2",
|
761
|
+
"minimum_wire_compatibility_version": "6.8.0",
|
762
|
+
"minimum_index_compatibility_version": "6.0.0-beta1"
|
763
|
+
},
|
764
|
+
"tagline": "You Know, for Search"
|
765
|
+
}
|
766
|
+
'''
|
767
|
+
res.status = 200
|
768
|
+
res['Content-Type'] = 'application/json'
|
769
|
+
@first_request = req
|
770
|
+
@first_req_waiter.countDown()
|
771
|
+
end
|
772
|
+
|
773
|
+
@server.mount_proc '/logstash_unit_test/_search' do |req, res|
|
774
|
+
res.body = '''
|
775
|
+
{
|
776
|
+
"took" : 1,
|
777
|
+
"timed_out" : false,
|
778
|
+
"_shards" : {
|
779
|
+
"total" : 1,
|
780
|
+
"successful" : 1,
|
781
|
+
"skipped" : 0,
|
782
|
+
"failed" : 0
|
783
|
+
},
|
784
|
+
"hits" : {
|
785
|
+
"total" : {
|
786
|
+
"value" : 10000,
|
787
|
+
"relation" : "gte"
|
788
|
+
},
|
789
|
+
"max_score" : 1.0,
|
790
|
+
"hits" : [
|
791
|
+
{
|
792
|
+
"_index" : "test_bulk_index_2",
|
793
|
+
"_type" : "_doc",
|
794
|
+
"_id" : "sHe6A3wBesqF7ydicQvG",
|
795
|
+
"_score" : 1.0,
|
796
|
+
"_source" : {
|
797
|
+
"@timestamp" : "2021-09-20T15:02:02.557Z",
|
798
|
+
"message" : "{\"name\": \"Andrea\"}",
|
799
|
+
"@version" : "1",
|
800
|
+
"host" : "kalispera",
|
801
|
+
"sequence" : 5
|
802
|
+
}
|
803
|
+
}
|
804
|
+
]
|
805
|
+
}
|
806
|
+
}
|
807
|
+
'''
|
808
|
+
res.status = 200
|
809
|
+
res['Content-Type'] = 'application/json'
|
810
|
+
@first_request = req
|
811
|
+
@first_req_waiter.countDown()
|
812
|
+
end
|
813
|
+
|
814
|
+
|
815
|
+
|
816
|
+
@server.start
|
817
|
+
rescue => e
|
818
|
+
puts "Error in webserver thread #{e}"
|
819
|
+
# ignore
|
820
|
+
end
|
821
|
+
end
|
822
|
+
)
|
823
|
+
@t.daemon = true
|
824
|
+
@t.start
|
825
|
+
queue.pop # blocks until the server is up
|
826
|
+
end
|
827
|
+
|
828
|
+
def stop
|
829
|
+
@server.shutdown
|
830
|
+
end
|
831
|
+
|
832
|
+
def wait_receive_request
|
833
|
+
@first_req_waiter.await(2, java.util.concurrent.TimeUnit::SECONDS)
|
834
|
+
@first_request
|
835
|
+
end
|
836
|
+
end
|
837
|
+
|
838
|
+
describe "'user-agent' header" do
|
839
|
+
let!(:webserver) { StoppableServer.new } # webserver must be started before the call, so no lazy "let"
|
840
|
+
|
841
|
+
after :each do
|
842
|
+
webserver.stop
|
843
|
+
end
|
844
|
+
|
845
|
+
it "server should be started" do
|
846
|
+
require 'net/http'
|
847
|
+
response = nil
|
848
|
+
Net::HTTP.start('localhost', webserver.port) {|http|
|
849
|
+
response = http.request_get('/')
|
850
|
+
}
|
851
|
+
expect(response.code.to_i).to eq(200)
|
852
|
+
end
|
853
|
+
|
854
|
+
context "used by plugin" do
|
855
|
+
let(:config) do
|
856
|
+
{
|
857
|
+
"hosts" => ["localhost:#{webserver.port}"],
|
858
|
+
"query" => '{ "query": { "match": { "statuscode": 200 } }, "sort": [ "_doc" ] }',
|
859
|
+
"index" => "logstash_unit_test"
|
860
|
+
}
|
861
|
+
end
|
862
|
+
let(:plugin) { described_class.new(config) }
|
863
|
+
let(:event) { LogStash::Event.new({}) }
|
864
|
+
|
865
|
+
it "client should sent the expect user-agent" do
|
866
|
+
plugin.register
|
867
|
+
|
868
|
+
queue = []
|
869
|
+
plugin.run(queue)
|
870
|
+
|
871
|
+
request = webserver.wait_receive_request
|
872
|
+
|
873
|
+
expect(request.header['user-agent'].size).to eq(1)
|
874
|
+
expect(request.header['user-agent'][0]).to match(/logstash\/\d*\.\d*\.\d* \(OS=.*; JVM=.*\) logstash-input-elasticsearch\/\d*\.\d*\.\d*/)
|
875
|
+
end
|
876
|
+
end
|
877
|
+
end
|
878
|
+
|
879
|
+
shared_examples 'configurable timeout' do |config_name, manticore_transport_option|
|
694
880
|
let(:config_value) { fail NotImplementedError }
|
695
881
|
let(:config) { super().merge(config_name => config_value) }
|
696
882
|
{
|
@@ -721,6 +907,9 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
|
|
721
907
|
transport_options = new_elasticsearch_client_params[:transport_options]
|
722
908
|
expect(transport_options).to include(manticore_transport_option)
|
723
909
|
expect(transport_options[manticore_transport_option]).to eq(config_value.to_i)
|
910
|
+
mock_client = double("fake_client")
|
911
|
+
allow(mock_client).to receive(:ping)
|
912
|
+
mock_client
|
724
913
|
end
|
725
914
|
|
726
915
|
plugin.register
|
@@ -6,13 +6,19 @@ require_relative "../../../spec/es_helper"
|
|
6
6
|
|
7
7
|
describe LogStash::Inputs::Elasticsearch do
|
8
8
|
|
9
|
-
|
9
|
+
SECURE_INTEGRATION = ENV['SECURE_INTEGRATION'].eql? 'true'
|
10
|
+
|
11
|
+
let(:config) { { 'hosts' => ["http#{SECURE_INTEGRATION ? 's' : nil}://#{ESHelper.get_host_port}"],
|
10
12
|
'index' => 'logs',
|
11
13
|
'query' => '{ "query": { "match": { "message": "Not found"} }}' } }
|
12
14
|
let(:plugin) { described_class.new(config) }
|
13
15
|
let(:event) { LogStash::Event.new({}) }
|
14
16
|
let(:client_options) { Hash.new }
|
15
17
|
|
18
|
+
let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' }
|
19
|
+
let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' }
|
20
|
+
let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }
|
21
|
+
|
16
22
|
before(:each) do
|
17
23
|
@es = ESHelper.get_client(client_options)
|
18
24
|
# Delete all templates first.
|
@@ -24,7 +30,6 @@ describe LogStash::Inputs::Elasticsearch do
|
|
24
30
|
ESHelper.index_doc(@es, :index => 'logs', :body => { :response => 404, :message=> 'Not Found'})
|
25
31
|
end
|
26
32
|
@es.indices.refresh
|
27
|
-
plugin.register
|
28
33
|
end
|
29
34
|
|
30
35
|
after(:each) do
|
@@ -33,6 +38,10 @@ describe LogStash::Inputs::Elasticsearch do
|
|
33
38
|
end
|
34
39
|
|
35
40
|
shared_examples 'an elasticsearch index plugin' do
|
41
|
+
before(:each) do
|
42
|
+
plugin.register
|
43
|
+
end
|
44
|
+
|
36
45
|
it 'should retrieve json event from elasticsearch' do
|
37
46
|
queue = []
|
38
47
|
plugin.run(queue)
|
@@ -42,14 +51,15 @@ describe LogStash::Inputs::Elasticsearch do
|
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
|
-
describe 'against an unsecured elasticsearch', :
|
54
|
+
describe 'against an unsecured elasticsearch', integration: true do
|
55
|
+
before(:each) do
|
56
|
+
plugin.register
|
57
|
+
end
|
58
|
+
|
46
59
|
it_behaves_like 'an elasticsearch index plugin'
|
47
60
|
end
|
48
61
|
|
49
|
-
describe 'against a secured elasticsearch', :
|
50
|
-
let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' }
|
51
|
-
let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' }
|
52
|
-
let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }
|
62
|
+
describe 'against a secured elasticsearch', secure_integration: true do
|
53
63
|
|
54
64
|
let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }
|
55
65
|
|
@@ -66,10 +76,33 @@ describe LogStash::Inputs::Elasticsearch do
|
|
66
76
|
let(:queue) { [] }
|
67
77
|
|
68
78
|
it "fails to run the plugin" do
|
69
|
-
plugin.register
|
70
|
-
expect { plugin.run queue }.to raise_error Elasticsearch::Transport::Transport::Errors::Unauthorized
|
79
|
+
expect { plugin.register }.to raise_error Elasticsearch::Transport::Transport::Errors::Unauthorized
|
71
80
|
end
|
72
81
|
end
|
73
82
|
|
74
83
|
end
|
84
|
+
|
85
|
+
context 'setting host:port', integration: true do
|
86
|
+
|
87
|
+
let(:config) do
|
88
|
+
super().merge "hosts" => [ESHelper.get_host_port]
|
89
|
+
end
|
90
|
+
|
91
|
+
it_behaves_like 'an elasticsearch index plugin'
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'setting host:port (and ssl)', secure_integration: true do
|
96
|
+
|
97
|
+
let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }
|
98
|
+
|
99
|
+
let(:config) do
|
100
|
+
config = super().merge "hosts" => [ESHelper.get_host_port]
|
101
|
+
config.merge('user' => user, 'password' => password, 'ssl' => true, 'ca_file' => ca_file)
|
102
|
+
end
|
103
|
+
|
104
|
+
it_behaves_like 'an elasticsearch index plugin'
|
105
|
+
|
106
|
+
end
|
107
|
+
|
75
108
|
end
|
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.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -20,8 +20,8 @@ dependencies:
|
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '2.99'
|
22
22
|
name: logstash-core-plugin-api
|
23
|
-
type: :runtime
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -37,8 +37,8 @@ dependencies:
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '1.3'
|
39
39
|
name: logstash-mixin-ecs_compatibility_support
|
40
|
-
type: :runtime
|
41
40
|
prerelease: false
|
41
|
+
type: :runtime
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
@@ -51,8 +51,8 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '1.0'
|
53
53
|
name: logstash-mixin-event_support
|
54
|
-
type: :runtime
|
55
54
|
prerelease: false
|
55
|
+
type: :runtime
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
@@ -65,8 +65,8 @@ dependencies:
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '1.0'
|
67
67
|
name: logstash-mixin-validator_support
|
68
|
-
type: :runtime
|
69
68
|
prerelease: false
|
69
|
+
type: :runtime
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
@@ -77,15 +77,15 @@ dependencies:
|
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 7.14.0
|
81
81
|
name: elasticsearch
|
82
|
-
type: :runtime
|
83
82
|
prerelease: false
|
83
|
+
type: :runtime
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: 7.14.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
@@ -93,8 +93,8 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
name: tzinfo
|
96
|
-
type: :runtime
|
97
96
|
prerelease: false
|
97
|
+
type: :runtime
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
@@ -107,8 +107,8 @@ dependencies:
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
name: tzinfo-data
|
110
|
-
type: :runtime
|
111
110
|
prerelease: false
|
111
|
+
type: :runtime
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
@@ -121,8 +121,8 @@ dependencies:
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
name: rufus-scheduler
|
124
|
-
type: :runtime
|
125
124
|
prerelease: false
|
125
|
+
type: :runtime
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
@@ -135,8 +135,8 @@ dependencies:
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: 0.7.1
|
137
137
|
name: manticore
|
138
|
-
type: :runtime
|
139
138
|
prerelease: false
|
139
|
+
type: :runtime
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - ">="
|
@@ -149,8 +149,8 @@ dependencies:
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
name: logstash-codec-plain
|
152
|
-
type: :development
|
153
152
|
prerelease: false
|
153
|
+
type: :development
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - ">="
|
@@ -161,15 +161,15 @@ dependencies:
|
|
161
161
|
requirements:
|
162
162
|
- - "~>"
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version:
|
164
|
+
version: '1'
|
165
165
|
name: faraday
|
166
|
-
type: :development
|
167
166
|
prerelease: false
|
167
|
+
type: :development
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
172
|
+
version: '1'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
requirement: !ruby/object:Gem::Requirement
|
175
175
|
requirements:
|
@@ -177,8 +177,8 @@ dependencies:
|
|
177
177
|
- !ruby/object:Gem::Version
|
178
178
|
version: '0'
|
179
179
|
name: logstash-devutils
|
180
|
-
type: :development
|
181
180
|
prerelease: false
|
181
|
+
type: :development
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
184
|
- - ">="
|
@@ -191,8 +191,36 @@ dependencies:
|
|
191
191
|
- !ruby/object:Gem::Version
|
192
192
|
version: '0'
|
193
193
|
name: timecop
|
194
|
+
prerelease: false
|
195
|
+
type: :development
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
requirement: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - "~>"
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0.6'
|
207
|
+
name: cabin
|
208
|
+
prerelease: false
|
194
209
|
type: :development
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - "~>"
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0.6'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
requirement: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '0'
|
221
|
+
name: webrick
|
195
222
|
prerelease: false
|
223
|
+
type: :development
|
196
224
|
version_requirements: !ruby/object:Gem::Requirement
|
197
225
|
requirements:
|
198
226
|
- - ">="
|
@@ -220,8 +248,6 @@ files:
|
|
220
248
|
- spec/es_helper.rb
|
221
249
|
- spec/fixtures/test_certs/ca.crt
|
222
250
|
- spec/fixtures/test_certs/ca.key
|
223
|
-
- spec/fixtures/test_certs/client/ls.crt
|
224
|
-
- spec/fixtures/test_certs/client/ls.key
|
225
251
|
- spec/fixtures/test_certs/es.crt
|
226
252
|
- spec/fixtures/test_certs/es.key
|
227
253
|
- spec/inputs/elasticsearch_spec.rb
|
@@ -247,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
273
|
- !ruby/object:Gem::Version
|
248
274
|
version: '0'
|
249
275
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
276
|
+
rubygems_version: 3.1.6
|
251
277
|
signing_key:
|
252
278
|
specification_version: 4
|
253
279
|
summary: Reads query results from an Elasticsearch cluster
|
@@ -255,8 +281,6 @@ test_files:
|
|
255
281
|
- spec/es_helper.rb
|
256
282
|
- spec/fixtures/test_certs/ca.crt
|
257
283
|
- spec/fixtures/test_certs/ca.key
|
258
|
-
- spec/fixtures/test_certs/client/ls.crt
|
259
|
-
- spec/fixtures/test_certs/client/ls.key
|
260
284
|
- spec/fixtures/test_certs/es.crt
|
261
285
|
- spec/fixtures/test_certs/es.key
|
262
286
|
- spec/inputs/elasticsearch_spec.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIDMTCCAhmgAwIBAgIUCJ5+zdYJIlL04EOwC0tqVbZYKQUwDQYJKoZIhvcNAQEL
|
3
|
-
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
|
4
|
-
cmF0ZWQgQ0EwHhcNMjEwODEyMDUxNTI3WhcNMjQwODExMDUxNTI3WjANMQswCQYD
|
5
|
-
VQQDEwJsczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMFY71j9Proa
|
6
|
-
x95bWoBQOcc0ncqVvQO+Tk/Do4ynoe64pOJEf3txh1viHbnzFUGf+NF5WW6trlZ2
|
7
|
-
ErP81vy7Ds5J5ngXjjdzOOGsTs9+l7KkqPfUwXqGoldWFtr//9mkLvWpd8uPvVtO
|
8
|
-
dRnpcjQSlHHEB/HaqxkyBAvHLv1Fi1jTgIgn32NEM2mlCJ3M8OVfO9pqlO/6gjjs
|
9
|
-
Miow8zZqtczeuv0JPu7V5xPDrcX0xh0kZdpH4gSh9r314TwZXFCofNUbkZrPV+Q9
|
10
|
-
XJs64NlBjJZkd5qwKeXujZRV4eVvAOTlp+4Nh4eDqXE323s5yiPuov0StvNrbh3d
|
11
|
-
rcg+IM+RTdMCAwEAAaNiMGAwHQYDVR0OBBYEFGnXHJEJ+LG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