logstash-output-elasticsearch 11.15.2-java → 11.15.5-java

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: d000a73f7c5397c4e4643c0d1dbb4efb0c04b290054b0d455f020ec3443765d5
4
- data.tar.gz: 9330ee2b0e8a903cc966c502fdc321e39fb2ee15b7b2782f2539567743346d71
3
+ metadata.gz: 5a43c2d3780ba862c30d3149ca123c980bc131a6752c02b81e20fd29d2930779
4
+ data.tar.gz: be8ab42869f43e35f94ae6eb550e1718de545fef9a85584b98ed0471d14e9e89
5
5
  SHA512:
6
- metadata.gz: ddcee04fc7e64d4dd77b6c868c34e65e9fff345c7d1d2c37da5752ae612f09ae8147d0686cfdcdee8494c9c6e6c6045a204ddc157db959733c677f719ca958f9
7
- data.tar.gz: '032939b34d7fbf6b4107295ea12c80ea651da05b29290154da37e6ff2b04cb123dcc07dee3bdce2ba184f06d2a2d0b4036dac9b3d8099e403bfda836efb4f29e'
6
+ metadata.gz: 45d6399c0d788768210f8196fdc392c64c654d99c387e3684c33467cd85e5f972a1404783ab00f255bd76f485a36a801906737526132e90bbf1ca3d98b98bcdb
7
+ data.tar.gz: 2d5172a5cac98a2836fe907dacdf0193af6ee2f1f30369ae15ac064e60628e57d253b696b5f9eef2c37a961bd75bdbcdea5f7d83f572a3d81eff6c85b5ac154f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 11.15.5
2
+ - Fixes `undefined 'shutdown_requested' method` error when plugin checks if shutdown request is received [#1134](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1134)
3
+
4
+ ## 11.15.4
5
+ - Improved connection handling under several partial-failure scenarios [#1130](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1130)
6
+ - Ensures an HTTP connection can be established before adding the connection to the pool
7
+ - Ensures that the version of the connected Elasticsearch is retrieved _successfully_ before the connection is added to the pool.
8
+ - Fixes a crash that could occur when the plugin is configured to connect to a live HTTP resource that is _not_ Elasticsearch
9
+
10
+ ## 11.15.3
11
+ - Removes the ECS v8 unreleased preview warning [#1131](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1131)
12
+
1
13
  ## 11.15.2
2
14
  - Restores DLQ logging behavior from 11.8.x to include the action-tuple as structured [#1105](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1105)
3
15
 
@@ -229,14 +229,16 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
229
229
  end
230
230
 
231
231
  def health_check_request(url)
232
- logger.debug("Running health check to see if an ES connection is working", url: url.sanitized.to_s, path: @healthcheck_path)
233
- perform_request_to_url(url, :head, @healthcheck_path)
232
+ response = perform_request_to_url(url, :head, @healthcheck_path)
233
+ raise BadResponseCodeError.new(response.code, url, nil, response.body) unless (200..299).cover?(response.code)
234
234
  end
235
235
 
236
236
  def healthcheck!(register_phase = true)
237
237
  # Try to keep locking granularity low such that we don't affect IO...
238
238
  @state_mutex.synchronize { @url_info.select {|url,meta| meta[:state] != :alive } }.each do |url,meta|
239
239
  begin
240
+ logger.debug("Running health check to see if an Elasticsearch connection is working",
241
+ :healthcheck_url => url.sanitized.to_s, :path => @healthcheck_path)
240
242
  health_check_request(url)
241
243
 
242
244
  # when called from resurrectionist skip the product check done during register phase
@@ -249,6 +251,10 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
249
251
  logger.warn("Restored connection to ES instance", url: url.sanitized.to_s)
250
252
  # We reconnected to this node, check its ES version
251
253
  es_version = get_es_version(url)
254
+ if es_version.nil?
255
+ logger.warn("Failed to retrieve Elasticsearch version data from connected endpoint, connection aborted", :url => url.sanitized.to_s)
256
+ next
257
+ end
252
258
  @state_mutex.synchronize do
253
259
  meta[:version] = es_version
254
260
  set_last_es_version(es_version, url)
@@ -464,8 +470,12 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
464
470
  end
465
471
 
466
472
  def get_es_version(url)
467
- request = perform_request_to_url(url, :get, ROOT_URI_PATH)
468
- LogStash::Json.load(request.body)["version"]["number"] # e.g. "7.10.0"
473
+ response = perform_request_to_url(url, :get, ROOT_URI_PATH)
474
+ return nil unless (200..299).cover?(response.code)
475
+
476
+ response = LogStash::Json.load(response.body)
477
+
478
+ response.fetch('version', {}).fetch('number', nil)
469
479
  end
470
480
 
471
481
  def last_es_version
@@ -330,11 +330,6 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
330
330
  @bulk_request_metrics = metric.namespace(:bulk_requests)
331
331
  @document_level_metrics = metric.namespace(:documents)
332
332
 
333
- if ecs_compatibility == :v8
334
- @logger.warn("Elasticsearch Output configured with `ecs_compatibility => v8`, which resolved to an UNRELEASED preview of version 8.0.0 of the Elastic Common Schema. " +
335
- "Once ECS v8 and an updated release of this plugin are publicly available, you will need to update this plugin to resolve this warning.")
336
- end
337
-
338
333
  @after_successful_connection_thread = after_successful_connection do
339
334
  begin
340
335
  finish_register
@@ -376,9 +376,9 @@ module LogStash; module PluginMixins; module ElasticSearch
376
376
  end
377
377
 
378
378
  def pipeline_shutdown_requested?
379
- return super if defined?(super) # since LS 8.1.0
380
- execution_context&.pipeline&.shutdown_requested
381
- end
379
+ return super if defined?(super) # since LS 8.1.0
380
+ execution_context&.pipeline&.shutdown_requested?
381
+ end
382
382
 
383
383
  def abort_batch_if_available!
384
384
  raise org.logstash.execution.AbortedBatchException.new if abort_batch_present?
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '11.15.2'
3
+ s.version = '11.15.5'
4
4
  s.licenses = ['apache-2.0']
5
5
  s.summary = "Stores logs in Elasticsearch"
6
6
  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"
7
7
  s.authors = ["Elastic"]
8
8
  s.email = 'info@elastic.co'
9
- s.homepage = "http://logstash.net/"
9
+ s.homepage = "https://www.elastic.co/guide/en/logstash/current/index.html"
10
10
  s.require_paths = ["lib"]
11
11
 
12
12
  s.platform = RUBY_PLATFORM
@@ -50,19 +50,19 @@ describe "index template expected behavior", :integration => true do
50
50
 
51
51
  # Wait or fail until everything's indexed.
52
52
  Stud::try(20.times) do
53
- r = @es.search(index: 'logstash-*')
53
+ r = @es.search(index: 'logstash*')
54
54
  expect(r).to have_hits(8)
55
55
  end
56
56
  end
57
57
 
58
58
  it "permits phrase searching on string fields" do
59
- results = @es.search(:q => "message:\"sample message\"")
59
+ results = @es.search(index: 'logstash*', q: "message:\"sample message\"")
60
60
  expect(results).to have_hits(1)
61
61
  expect(results["hits"]["hits"][0]["_source"]["message"]).to eq("sample message here")
62
62
  end
63
63
 
64
64
  it "numbers dynamically map to a numeric type and permit range queries" do
65
- results = @es.search(:q => "somevalue:[5 TO 105]")
65
+ results = @es.search(index: 'logstash*', q: "somevalue:[5 TO 105]")
66
66
  expect(results).to have_hits(2)
67
67
 
68
68
  values = results["hits"]["hits"].collect { |r| r["_source"]["somevalue"] }
@@ -72,22 +72,22 @@ describe "index template expected behavior", :integration => true do
72
72
  end
73
73
 
74
74
  it "does not create .keyword field for top-level message field" do
75
- results = @es.search(:q => "message.keyword:\"sample message here\"")
75
+ results = @es.search(index: 'logstash*', q: "message.keyword:\"sample message here\"")
76
76
  expect(results).to have_hits(0)
77
77
  end
78
78
 
79
79
  it "creates .keyword field for nested message fields" do
80
- results = @es.search(:q => "somemessage.message.keyword:\"sample nested message here\"")
80
+ results = @es.search(index: 'logstash*', q: "somemessage.message.keyword:\"sample nested message here\"")
81
81
  expect(results).to have_hits(1)
82
82
  end
83
83
 
84
84
  it "creates .keyword field from any string field which is not_analyzed" do
85
- results = @es.search(:q => "country.keyword:\"us\"")
85
+ results = @es.search(index: 'logstash*', q: "country.keyword:\"us\"")
86
86
  expect(results).to have_hits(1)
87
87
  expect(results["hits"]["hits"][0]["_source"]["country"]).to eq("us")
88
88
 
89
89
  # partial or terms should not work.
90
- results = @es.search(:q => "country.keyword:\"u\"")
90
+ results = @es.search(index: 'logstash*', q: "country.keyword:\"u\"")
91
91
  expect(results).to have_hits(0)
92
92
  end
93
93
 
@@ -96,7 +96,7 @@ describe "index template expected behavior", :integration => true do
96
96
  end
97
97
 
98
98
  it "aggregate .keyword results correctly " do
99
- results = @es.search(:body => { "aggregations" => { "my_agg" => { "terms" => { "field" => "country.keyword" } } } })["aggregations"]["my_agg"]
99
+ results = @es.search(index: 'logstash*', body: { "aggregations" => { "my_agg" => { "terms" => { "field" => "country.keyword" } } } })["aggregations"]["my_agg"]
100
100
  terms = results["buckets"].collect { |b| b["key"] }
101
101
 
102
102
  expect(terms).to include("us")
@@ -50,6 +50,8 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
50
50
 
51
51
  describe "healthcheck url handling" do
52
52
  let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://localhost:9200")] }
53
+ let(:success_response) { double("Response", :code => 200) }
54
+
53
55
  before(:example) do
54
56
  expect(adapter).to receive(:perform_request).with(anything, :get, "/", anything, anything) do |url, _, _, _, _|
55
57
  expect(url.path).to be_empty
@@ -60,6 +62,8 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
60
62
  it "performs the healthcheck to the root" do
61
63
  expect(adapter).to receive(:perform_request).with(anything, :head, "/", anything, anything) do |url, _, _, _, _|
62
64
  expect(url.path).to be_empty
65
+
66
+ success_response
63
67
  end
64
68
  expect { subject.healthcheck! }.to raise_error(LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch")
65
69
  end
@@ -71,6 +75,8 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
71
75
  it "performs the healthcheck to the healthcheck_path" do
72
76
  expect(adapter).to receive(:perform_request).with(anything, :head, eq(healthcheck_path), anything, anything) do |url, _, _, _, _|
73
77
  expect(url.path).to be_empty
78
+
79
+ success_response
74
80
  end
75
81
  expect { subject.healthcheck! }.to raise_error(LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch")
76
82
  end
@@ -197,9 +203,10 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
197
203
  "build_flavor" => 'default'}
198
204
  })
199
205
  end
206
+ let(:success_response) { double("head_req", :code => 200)}
200
207
 
201
208
  before :each do
202
- allow(adapter).to receive(:perform_request).with(anything, :head, subject.healthcheck_path, {}, nil)
209
+ allow(adapter).to receive(:perform_request).with(anything, :head, subject.healthcheck_path, {}, nil).and_return(success_response)
203
210
  allow(adapter).to receive(:perform_request).with(anything, :get, subject.healthcheck_path, {}, nil).and_return(version_ok)
204
211
  end
205
212
  let(:initial_urls) { [ ::LogStash::Util::SafeURI.new("http://localhost:9200"), ::LogStash::Util::SafeURI.new("http://localhost:9201"), ::LogStash::Util::SafeURI.new("http://localhost:9202") ] }
@@ -225,7 +232,7 @@ describe LogStash::Outputs::ElasticSearch::HttpClient::Pool do
225
232
  u,m = subject.get_connection
226
233
 
227
234
  # The resurrectionist will call this to check on the backend
228
- response = double("response")
235
+ response = double("response", :code => 200)
229
236
  expect(adapter).to receive(:perform_request).with(u, :head, subject.healthcheck_path, {}, nil).and_return(response)
230
237
 
231
238
  subject.return_connection(u)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.15.2
4
+ version: 11.15.5
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-28 00:00:00.000000000 Z
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -335,7 +335,7 @@ files:
335
335
  - spec/unit/outputs/elasticsearch_ssl_spec.rb
336
336
  - spec/unit/outputs/error_whitelist_spec.rb
337
337
  - spec/unit/outputs/license_check_spec.rb
338
- homepage: http://logstash.net/
338
+ homepage: https://www.elastic.co/guide/en/logstash/current/index.html
339
339
  licenses:
340
340
  - apache-2.0
341
341
  metadata:
@@ -356,7 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
356
  - !ruby/object:Gem::Version
357
357
  version: '0'
358
358
  requirements: []
359
- rubygems_version: 3.1.6
359
+ rubygems_version: 3.2.33
360
360
  signing_key:
361
361
  specification_version: 4
362
362
  summary: Stores logs in Elasticsearch