logstash-output-elasticsearch 11.15.2-java → 11.15.4-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d000a73f7c5397c4e4643c0d1dbb4efb0c04b290054b0d455f020ec3443765d5
4
- data.tar.gz: 9330ee2b0e8a903cc966c502fdc321e39fb2ee15b7b2782f2539567743346d71
3
+ metadata.gz: 35c442c72cb3629cc3d17b28bffce6351c6e61a6332c254bef41ad89c9cc2810
4
+ data.tar.gz: 396df2b1625d0b62f8f71982203f01f1fa8901a6ccaf2098e10b51c4f77c9d80
5
5
  SHA512:
6
- metadata.gz: ddcee04fc7e64d4dd77b6c868c34e65e9fff345c7d1d2c37da5752ae612f09ae8147d0686cfdcdee8494c9c6e6c6045a204ddc157db959733c677f719ca958f9
7
- data.tar.gz: '032939b34d7fbf6b4107295ea12c80ea651da05b29290154da37e6ff2b04cb123dcc07dee3bdce2ba184f06d2a2d0b4036dac9b3d8099e403bfda836efb4f29e'
6
+ metadata.gz: 3acda17f89403df63a709bedb84481c259178c97963120cce9452565d1d93981ac4a8b3766c9de2ee356d540f38109afbaf03cba3de17402551ee55cc09e74ce
7
+ data.tar.gz: fb405743b1746631fe84e4b346810df84b21955bb7ef0d5adf122d03d9e7fc739fde8623947fc9ae94d1139cb34ecef869eb18141344231183d844a334b3b6dd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 11.15.4
2
+ - Improved connection handling under several partial-failure scenarios [#1130](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1130)
3
+ - Ensures an HTTP connection can be established before adding the connection to the pool
4
+ - Ensures that the version of the connected Elasticsearch is retrieved _successfully_ before the connection is added to the pool.
5
+ - Fixes a crash that could occur when the plugin is configured to connect to a live HTTP resource that is _not_ Elasticsearch
6
+
7
+ ## 11.15.3
8
+ - Removes the ECS v8 unreleased preview warning [#1131](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1131)
9
+
1
10
  ## 11.15.2
2
11
  - 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
12
 
@@ -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
@@ -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.4'
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.4
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-15 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