logstash-input-elasticsearch 5.0.0 → 5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b34b6c6d814152e88f320525ea0bb80bbf1e63ff962e022aaac0a2385dd087b6
4
- data.tar.gz: d142df9148ad69bf838d62badeec71382118741938db61e6aad0676bdb918a37
3
+ metadata.gz: 435dd3535dc912d60a6b363a3f04d61261106e844b21fc250b2b68867c12e3e6
4
+ data.tar.gz: 2b1b4677f75e491f70cfcf119c78576c5060dcfb3bb88aa4d8ac6953ec188f43
5
5
  SHA512:
6
- metadata.gz: 19b2b1325ded83b5b93966365f855f104ba1881f2c991ffdbe92216e08d12d18a7b3ddd4a14d755f6d55c85c98e00d12ca566188c63706d6db1f0aa5b085048b
7
- data.tar.gz: ff5de17e75281d8ddd0be70167f2c4dee0a90eef328c7e486b704e79fe10db7b7108b733f77438386a7abb18d504efbef5aaf7b0f34a6c8edd62791640514b7b
6
+ metadata.gz: cff6d761bea5229ce1bced81889c747a5fe04ac481d7009b1d33110b2fb598c15a0db366c3ce1fb17e26d16ef713281683cfd894b46dfb499d2de3a5af61695d
7
+ data.tar.gz: fcd0202d0b949194a361d1b05e813196ea8958147ba6b107b2e68d83861975144ff30139ee5f302e5abce626fbdecf05529a0f95284bdb6c7a7f1f11c0f33325
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
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
+
4
+ ## 5.0.1
5
+ - Fix: prevent plugin crash when hits contain illegal structure [#218](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/218)
6
+ - 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.
7
+
1
8
  ## 5.0.0
2
9
  - SSL settings that were marked deprecated in version `4.17.0` are now marked obsolete, and will prevent the plugin from starting.
3
10
  - These settings are:
@@ -5,6 +12,7 @@
5
12
  - `ca_file`, which should bre replaced by `ssl_certificate_authorities`
6
13
  - `ssl_certificate_verification`, which should bre replaced by `ssl_verification_mode`
7
14
  - [#213](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/213)
15
+ - Add support for custom headers [#207](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/207)
8
16
 
9
17
  ## 4.20.5
10
18
  - Add `x-elastic-product-origin` header to Elasticsearch requests [#211](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/211)
data/docs/index.asciidoc CHANGED
@@ -93,6 +93,16 @@ The plugin logs a warning when ECS is enabled and `target` isn't set.
93
93
 
94
94
  TIP: Set the `target` option to avoid potential schema conflicts.
95
95
 
96
+ [id="plugins-{type}s-{plugin}-failure-handling"]
97
+ ==== Failure handling
98
+
99
+ When this input plugin cannot create a structured `Event` from a hit result, it will instead create an `Event` that is tagged with `_elasticsearch_input_failure` whose `[event][original]` is a JSON-encoded string representation of the entire hit.
100
+
101
+ Common causes are:
102
+
103
+ - When the hit result contains top-level fields that are {logstash-ref}/processing.html#reserved-fields[reserved in Logstash] but do not have the expected shape. Use the <<plugins-{type}s-{plugin}-target>> directive to avoid conflicts with the top-level namespace.
104
+ - When <<plugins-{type}s-{plugin}-docinfo>> is enabled and the docinfo fields cannot be merged into the hit result. Combine <<plugins-{type}s-{plugin}-target>> and <<plugins-{type}s-{plugin}-docinfo_target>> to avoid conflict.
105
+
96
106
  [id="plugins-{type}s-{plugin}-options"]
97
107
  ==== Elasticsearch Input configuration options
98
108
 
@@ -101,9 +111,6 @@ This plugin supports these configuration options plus the <<plugins-{type}s-{plu
101
111
  NOTE: As of version `5.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed.
102
112
  Please check out <<plugins-{type}s-{plugin}-obsolete-options>> for details.
103
113
 
104
- NOTE: As of version `5.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed.
105
- Please check out <<plugins-{type}s-{plugin}-obsolete-options>> for details.
106
-
107
114
  [cols="<,<,<",options="header",]
108
115
  |=======================================================================
109
116
  |Setting |Input type|Required
@@ -13,9 +13,7 @@ require "logstash/plugin_mixins/normalize_config_support"
13
13
  require "base64"
14
14
 
15
15
  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"
19
17
 
20
18
  # .Compatibility Note
21
19
  # [NOTE]
@@ -316,7 +314,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
316
314
  @client_options = {
317
315
  :hosts => hosts,
318
316
  :transport_options => transport_options,
319
- :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
317
+ :transport_class => get_transport_client_class,
320
318
  :ssl => ssl_options
321
319
  }
322
320
 
@@ -346,21 +344,29 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
346
344
  # This can be called externally from the query_executor
347
345
  public
348
346
  def push_hit(hit, output_queue, root_field = '_source')
349
- event = targeted_event_factory.new_event hit[root_field]
350
- set_docinfo_fields(hit, event) if @docinfo
347
+ event = event_from_hit(hit, root_field)
351
348
  decorate(event)
352
349
  output_queue << event
353
350
  end
354
351
 
352
+ def event_from_hit(hit, root_field)
353
+ event = targeted_event_factory.new_event hit[root_field]
354
+ set_docinfo_fields(hit, event) if @docinfo
355
+
356
+ event
357
+ rescue => e
358
+ serialized_hit = hit.to_json
359
+ logger.warn("Event creation error, original data now in [event][original] field", message: e.message, exception: e.class, data: serialized_hit)
360
+ return event_factory.new_event('event' => { 'original' => serialized_hit }, 'tags' => ['_elasticsearch_input_failure'])
361
+ end
362
+
355
363
  def set_docinfo_fields(hit, event)
356
364
  # do not assume event[@docinfo_target] to be in-place updatable. first get it, update it, then at the end set it in the event.
357
365
  docinfo_target = event.get(@docinfo_target) || {}
358
366
 
359
367
  unless docinfo_target.is_a?(Hash)
360
- @logger.error("Incompatible Event, incompatible type for the docinfo_target=#{@docinfo_target} field in the `_source` document, expected a hash got:", :docinfo_target_type => docinfo_target.class, :event => event.to_hash_with_metadata)
361
-
362
- # TODO: (colin) I am not sure raising is a good strategy here?
363
- raise Exception.new("Elasticsearch input: incompatible event")
368
+ # expect error to be handled by `#event_from_hit`
369
+ fail RuntimeError, "Incompatible event; unable to merge docinfo fields into docinfo_target=`#{@docinfo_target}`"
364
370
  end
365
371
 
366
372
  @docinfo_fields.each do |field|
@@ -634,6 +640,20 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
634
640
  end
635
641
  end
636
642
 
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
+
637
657
  module URIOrEmptyValidator
638
658
  ##
639
659
  # @override to provide :uri_or_empty validator
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-elasticsearch'
4
- s.version = '5.0.0'
4
+ s.version = '5.0.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"
8
8
  s.authors = ["Elastic"]
9
9
  s.email = 'info@elastic.co'
10
- s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.homepage = "https://elastic.co/logstash"
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
@@ -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.9'
29
+ s.add_runtime_dependency 'elasticsearch', '>= 7.17.9', '< 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
 
@@ -0,0 +1 @@
1
+ 2024-12-26T22:27:15+00:00
@@ -1,20 +1,19 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDSTCCAjGgAwIBAgIUUcAg9c8B8jiliCkOEJyqoAHrmccwDQYJKoZIhvcNAQEL
3
- BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
4
- cmF0ZWQgQ0EwHhcNMjEwODEyMDUxNDU1WhcNMjQwODExMDUxNDU1WjA0MTIwMAYD
5
- VQQDEylFbGFzdGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBDQTCC
6
- ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK1HuusRuGNsztd4EQvqwcMr
7
- 8XvnNNaalerpMOorCGySEFrNf0HxDIVMGMCrOv1F8SvlcGq3XANs2MJ4F2xhhLZr
8
- PpqVHx+QnSZ66lu5R89QVSuMh/dCMxhNBlOA/dDlvy+EJBl9H791UGy/ChhSgaBd
9
- OKVyGkhjErRTeMIq7rR7UG6GL/fV+JGy41Ui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GEtms+mpUfH5CdJnrqW7lHz1BVK4yH
8
+ 90IzGE0GU4D90OW/L4QkGX0fv3VQbL8KGFKBoF04pXIaSGMStFN4wirutHtQboYv
9
+ 99X4kbLjVSIuubUpA/v9dUP1TNl8ar+HKUWRM96ijHkFTF3FR0NnZyt44gP5qC0h
10
+ i4lUiR6Uo9D6WMFjeRYFF7GolCy/I1SzWBmmOnNhQLO5VxcNG4ldhBcapZeGwE98
11
+ m/5lxLIwgFR9ZP8bXdxZTWLC58/LQ2NqOjA9mwIDAQABozIwMDAPBgNVHRMBAf8E
12
+ BTADAQH/MB0GA1UdDgQWBBTIJMnuftpfkxNCOkbF0R4xgcKQRjANBgkqhkiG9w0B
13
+ AQsFAAOCAQEAhfg/cmXc4Uh90yiXU8jOW8saQjTsq4ZMDQiLfJsNmNNYmHFN0vhv
14
+ lJRI1STdy7+GpjS5QbrMjQIxWSS8X8xysE4Rt81IrWmLuao35TRFyoiE1seBQ5sz
15
+ p/BxZUe57JvWi9dyzv2df4UfWFdGBhzdr80odZmz4i5VIv6qCKJKsGikcuLpepmp
16
+ E/UKnKHeR/dFWsxzA9P2OzHTUNBMOOA2PyAUL49pwoChwJeOWN/zAgwMWLbuHFG0
17
+ IN0u8swAmeH98QdvzbhiOatGNpqfTNvQEDc19yVjfXKpBVZQ79WtronYSqrbrUa1
18
+ T2zD8bIVP7CdddD/UmpT1SSKh4PJxudy5Q==
20
19
  -----END CERTIFICATE-----
@@ -1 +1 @@
1
- 195a7e7b1bc29f3d7913a918a44721704d27fa56facea0cd72a8093c7107c283
1
+ b1e955819b0d14f64f863adb103c248ddacf2e17bea48d04ee4b57c64814ccc4
@@ -0,0 +1,38 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDIzCCAgugAwIBAgIBATANBgkqhkiG9w0BAQsFADA0MTIwMAYDVQQDEylFbGFz
3
+ dGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBDQTAeFw0yNDEyMjYy
4
+ MjI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lOe2yzQeH+alttp
14
+ CSQVINjJotS1WvmtqjBB6ArqLpXIGU89TZsktNe/NQJzgYSaMnlIuHVLFdxJYmwU
15
+ T1cP6VC/brmqP/dd5y7VWE7Lp+Wd5CxKl/WY+9chmgc+a1fW/lnPEJJ6pca1Bo8b
16
+ byIL0yY2IUv4R2eh1IyQl9oGH1GOPLgO7cY04eajxYcOVA2eDSItoyDtrJfkFP/P
17
+ UXtC1JAkvWKuujFEiBj0AannhroWlp3gvChhBwCuCAU0KXD6g8BE8tn6oT1+FW7J
18
+ avSfHxAe+VHtYhF8sJ8jrdm0d7E4GKS9UR/pkLAL1JuRdJ1VkPx3
20
19
  -----END CERTIFICATE-----
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+ cd "$(dirname "$0")"
5
+
6
+ openssl x509 -x509toreq -in ca.crt -copy_extensions copyall -signkey ca.key -out ca.csr
7
+ openssl x509 -req -copy_extensions copyall -days 365 -in ca.csr -set_serial 0x01 -signkey ca.key -out ca.crt && rm ca.csr
8
+ openssl x509 -in ca.crt -outform der | sha256sum | awk '{print $1}' > ca.der.sha256
9
+
10
+ openssl x509 -x509toreq -in es.crt -copy_extensions copyall -signkey es.key -out es.csr
11
+ openssl x509 -req -copy_extensions copyall -days 365 -in es.csr -set_serial 0x01 -CA ca.crt -CAkey ca.key -out es.crt && rm es.csr
12
+ cat es.crt ca.crt > es.chain.crt
13
+
14
+ # output ISO8601 timestamp to file
15
+ date -Iseconds > GENERATED_AT
@@ -21,6 +21,13 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
21
21
  let(:es_version) { "7.5.0" }
22
22
  let(:cluster_info) { {"version" => {"number" => es_version, "build_flavor" => build_flavor}, "tagline" => "You Know, for Search"} }
23
23
 
24
+ def elastic_ruby_v8_client_available?
25
+ Elasticsearch::Transport
26
+ false
27
+ rescue NameError # NameError: uninitialized constant Elasticsearch::Transport if Elastic Ruby client is not available
28
+ true
29
+ end
30
+
24
31
  before(:each) do
25
32
  Elasticsearch::Client.send(:define_method, :ping) { } # define no-action ping method
26
33
  allow_any_instance_of(Elasticsearch::Client).to receive(:info).and_return(cluster_info)
@@ -92,9 +99,11 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
92
99
 
93
100
  before do
94
101
  allow(Elasticsearch::Client).to receive(:new).and_return(es_client)
95
- allow(es_client).to receive(:info).and_raise(
96
- Elasticsearch::Transport::Transport::Errors::BadRequest.new
97
- )
102
+ if elastic_ruby_v8_client_available?
103
+ allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
104
+ else
105
+ allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new)
106
+ end
98
107
  end
99
108
 
100
109
  it "raises an exception" do
@@ -666,11 +675,28 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
666
675
  context 'if the `docinfo_target` exist but is not of type hash' do
667
676
  let(:config) { base_config.merge 'docinfo' => true, "docinfo_target" => 'metadata_with_string' }
668
677
  let(:do_register) { false }
678
+ let(:mock_queue) { double('Queue', :<< => nil) }
679
+ let(:hit) { response.dig('hits', 'hits').first }
680
+
681
+ it 'emits a tagged event with JSON-serialized event in [event][original]' do
682
+ allow(plugin).to receive(:logger).and_return(double('Logger').as_null_object)
669
683
 
670
- it 'raises an exception if the `docinfo_target` exist but is not of type hash' do
671
- expect(client).not_to receive(:clear_scroll)
672
684
  plugin.register
673
- expect { plugin.run([]) }.to raise_error(Exception, /incompatible event/)
685
+ plugin.run(mock_queue)
686
+
687
+ expect(mock_queue).to have_received(:<<) do |event|
688
+ expect(event).to be_a_kind_of LogStash::Event
689
+
690
+ expect(event.get('tags')).to include("_elasticsearch_input_failure")
691
+ expect(event.get('[event][original]')).to be_a_kind_of String
692
+ expect(JSON.load(event.get('[event][original]'))).to eq hit
693
+ end
694
+
695
+ expect(plugin.logger)
696
+ .to have_received(:warn).with(
697
+ a_string_including("Event creation error, original data now in [event][original] field"),
698
+ a_hash_including(:message => a_string_including('unable to merge docinfo fields into docinfo_target=`metadata_with_string`'),
699
+ :data => a_string_including('"_id":"C5b2xLQwTZa76jBmHIbwHQ"')))
674
700
  end
675
701
 
676
702
  end
@@ -727,8 +753,13 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
727
753
  it "should set host(s)" do
728
754
  plugin.register
729
755
  client = plugin.send(:client)
730
-
731
- expect( client.transport.instance_variable_get(:@seeds) ).to eql [{
756
+ target_field = :@seeds
757
+ begin
758
+ Elasticsearch::Transport::Client
759
+ rescue
760
+ target_field = :@hosts
761
+ end
762
+ expect( client.transport.instance_variable_get(target_field) ).to eql [{
732
763
  :scheme => "https",
733
764
  :host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
734
765
  :port => 9243,
@@ -1248,6 +1279,88 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
1248
1279
  end
1249
1280
  end
1250
1281
 
1282
+ context '#push_hit' do
1283
+ let(:config) do
1284
+ {
1285
+ 'docinfo' => true, # include ids
1286
+ 'docinfo_target' => '[@metadata][docinfo]'
1287
+ }
1288
+ end
1289
+
1290
+ let(:hit) do
1291
+ JSON.load(<<~EOJSON)
1292
+ {
1293
+ "_index" : "test_bulk_index_2",
1294
+ "_type" : "_doc",
1295
+ "_id" : "sHe6A3wBesqF7ydicQvG",
1296
+ "_score" : 1.0,
1297
+ "_source" : {
1298
+ "@timestamp" : "2021-09-20T15:02:02.557Z",
1299
+ "message" : "ping",
1300
+ "@version" : "17",
1301
+ "sequence" : 7,
1302
+ "host" : {
1303
+ "name" : "maybe.local",
1304
+ "ip" : "127.0.0.1"
1305
+ }
1306
+ }
1307
+ }
1308
+ EOJSON
1309
+ end
1310
+
1311
+ let(:mock_queue) { double('queue', :<< => nil) }
1312
+
1313
+ it 'pushes a generated event to the queue' do
1314
+ plugin.send(:push_hit, hit, mock_queue)
1315
+ expect(mock_queue).to have_received(:<<) do |event|
1316
+ expect(event).to be_a_kind_of LogStash::Event
1317
+
1318
+ # fields overriding defaults
1319
+ expect(event.timestamp.to_s).to eq("2021-09-20T15:02:02.557Z")
1320
+ expect(event.get('@version')).to eq("17")
1321
+
1322
+ # structure from hit's _source
1323
+ expect(event.get('message')).to eq("ping")
1324
+ expect(event.get('sequence')).to eq(7)
1325
+ expect(event.get('[host][name]')).to eq("maybe.local")
1326
+ expect(event.get('[host][ip]')).to eq("127.0.0.1")
1327
+
1328
+ # docinfo fields
1329
+ expect(event.get('[@metadata][docinfo][_index]')).to eq("test_bulk_index_2")
1330
+ expect(event.get('[@metadata][docinfo][_type]')).to eq("_doc")
1331
+ expect(event.get('[@metadata][docinfo][_id]')).to eq("sHe6A3wBesqF7ydicQvG")
1332
+ end
1333
+ end
1334
+
1335
+ context 'when event creation fails' do
1336
+ before(:each) do
1337
+ allow(plugin).to receive(:logger).and_return(double('Logger').as_null_object)
1338
+
1339
+ allow(plugin.event_factory).to receive(:new_event).and_call_original
1340
+ allow(plugin.event_factory).to receive(:new_event).with(a_hash_including hit['_source']).and_raise(RuntimeError, 'intentional')
1341
+ end
1342
+
1343
+ it 'pushes a tagged event containing a JSON-encoded hit in [event][original]' do
1344
+ plugin.send(:push_hit, hit, mock_queue)
1345
+
1346
+ expect(mock_queue).to have_received(:<<) do |event|
1347
+ expect(event).to be_a_kind_of LogStash::Event
1348
+
1349
+ expect(event.get('tags')).to include("_elasticsearch_input_failure")
1350
+ expect(event.get('[event][original]')).to be_a_kind_of String
1351
+ expect(JSON.load(event.get('[event][original]'))).to eq hit
1352
+ end
1353
+
1354
+ expect(plugin.logger)
1355
+ .to have_received(:warn).with(
1356
+ a_string_including("Event creation error, original data now in [event][original] field"),
1357
+ a_hash_including(:message => a_string_including('intentional'),
1358
+ :data => a_string_including('"_id":"sHe6A3wBesqF7ydicQvG"')))
1359
+
1360
+ end
1361
+ end
1362
+ end
1363
+
1251
1364
  # @note can be removed once we depends on elasticsearch gem >= 6.x
1252
1365
  def extract_transport(client) # on 7.x client.transport is a ES::Transport::Client
1253
1366
  client.transport.respond_to?(:transport) ? client.transport.transport : client.transport
@@ -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, :integration => true do
7
+ describe LogStash::Inputs::Elasticsearch 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: 5.0.0
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
11
+ date: 2025-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +92,9 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 7.17.9
95
+ - - "<"
96
+ - !ruby/object:Gem::Version
97
+ version: '9'
95
98
  name: elasticsearch
96
99
  type: :runtime
97
100
  prerelease: false
@@ -100,6 +103,9 @@ dependencies:
100
103
  - - ">="
101
104
  - !ruby/object:Gem::Version
102
105
  version: 7.17.9
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: '9'
103
109
  - !ruby/object:Gem::Dependency
104
110
  requirement: !ruby/object:Gem::Requirement
105
111
  requirements:
@@ -277,16 +283,19 @@ files:
277
283
  - lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_http_manticore.rb
278
284
  - logstash-input-elasticsearch.gemspec
279
285
  - spec/es_helper.rb
286
+ - spec/fixtures/test_certs/GENERATED_AT
280
287
  - spec/fixtures/test_certs/ca.crt
281
288
  - spec/fixtures/test_certs/ca.der.sha256
282
289
  - spec/fixtures/test_certs/ca.key
290
+ - spec/fixtures/test_certs/es.chain.crt
283
291
  - spec/fixtures/test_certs/es.crt
284
292
  - spec/fixtures/test_certs/es.key
293
+ - spec/fixtures/test_certs/renew.sh
285
294
  - spec/inputs/elasticsearch_spec.rb
286
295
  - spec/inputs/elasticsearch_ssl_spec.rb
287
296
  - spec/inputs/integration/elasticsearch_spec.rb
288
297
  - spec/inputs/paginated_search_spec.rb
289
- homepage: http://www.elastic.co/guide/en/logstash/current/index.html
298
+ homepage: https://elastic.co/logstash
290
299
  licenses:
291
300
  - Apache License (2.0)
292
301
  metadata:
@@ -313,11 +322,14 @@ specification_version: 4
313
322
  summary: Reads query results from an Elasticsearch cluster
314
323
  test_files:
315
324
  - spec/es_helper.rb
325
+ - spec/fixtures/test_certs/GENERATED_AT
316
326
  - spec/fixtures/test_certs/ca.crt
317
327
  - spec/fixtures/test_certs/ca.der.sha256
318
328
  - spec/fixtures/test_certs/ca.key
329
+ - spec/fixtures/test_certs/es.chain.crt
319
330
  - spec/fixtures/test_certs/es.crt
320
331
  - spec/fixtures/test_certs/es.key
332
+ - spec/fixtures/test_certs/renew.sh
321
333
  - spec/inputs/elasticsearch_spec.rb
322
334
  - spec/inputs/elasticsearch_ssl_spec.rb
323
335
  - spec/inputs/integration/elasticsearch_spec.rb