logstash-output-elasticsearch 11.1.0-java → 11.2.3-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: a8d5dde6f4643a1482c56af7db786848d73759cac4728203ade488a8eec3ca76
4
- data.tar.gz: 8c8e8b7b05589c7d86d92d3fc50c2d267c5650456c84806326c5bef488bfb819
3
+ metadata.gz: 0f92990f09e327bd6f51bce4b20f2e4c1460afb20f6f957a8e5d22b0314df159
4
+ data.tar.gz: ad3fe0e2696447936adf5a1e44d0bcb801e7f42c46a77b0bc3c1b4a8d4573386
5
5
  SHA512:
6
- metadata.gz: aad121ec87c87db04fc35ce0bf28069eee3960b0bdca76c8297d5b1242e9e83a68b118b5f97e41ec34660073ba1f61f839e786ee2db306a56f5b2ad6c0e5dc06
7
- data.tar.gz: 5201e002ae94e3acc00e44e79da5cd721fc80d39781e876c0d009d7c53f5ab90978a6126a691c5c07b159a30bc3e2bc38ef58801d0443094bcd3b810acbd7e98
6
+ metadata.gz: 8db68360e25d159203f00073f7fc651cdfe2a42030ae23ff53f36993711d9a13e482e54dcda753d4f61a840916c434bbb9dc47a3a563bebac60feb54bef13f25
7
+ data.tar.gz: a25dcc99673a2eeee943c434914eb597673f70cc2aa15ed7b8687b328beb11d8a63d70914e705d957d6163d79324fe03eb83e7dda5c2314be4a291ba72757832
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 11.2.3
2
+ - Downgrade ECS templates, pinning to v1.10.0 of upstream; fixes an issue where ECS templates cannot be installed in Elasticsearch 6.x or 7.1-7.2, since the generated templates include fields of `type: flattened` that was introduced in Elasticsearch 7.3
3
+
4
+ ## 11.2.2
5
+ - Update ECS templates from upstream; `ecs_compatiblity => v1` now resolves to templates for ECS v1.12.1 [#1027](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/1027)
6
+
7
+ ## 11.2.1
8
+ - Fix referencing Gem classes from global lexical scope [#1044](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1044)
9
+
10
+ ## 11.2.0
11
+ - Added preflight checks on Elasticsearch [#1026](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1026)
12
+
1
13
  ## 11.1.0
2
14
  - Feat: add `user-agent` header passed to the Elasticsearch HTTP connection [#1038](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1038)
3
15
 
@@ -37,6 +37,9 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
37
37
  ROOT_URI_PATH = '/'.freeze
38
38
  LICENSE_PATH = '/_license'.freeze
39
39
 
40
+ VERSION_6_TO_7 = ::Gem::Requirement.new([">= 6.0.0", "< 7.0.0"])
41
+ VERSION_7_TO_7_14 = ::Gem::Requirement.new([">= 7.0.0", "< 7.14.0"])
42
+
40
43
  DEFAULT_OPTIONS = {
41
44
  :healthcheck_path => ROOT_URI_PATH,
42
45
  :sniffing_path => "/_nodes/http",
@@ -211,7 +214,7 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
211
214
  def start_resurrectionist
212
215
  @resurrectionist = Thread.new do
213
216
  until_stopped("resurrection", @resurrect_delay) do
214
- healthcheck!
217
+ healthcheck!(false)
215
218
  end
216
219
  end
217
220
  end
@@ -232,11 +235,18 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
232
235
  perform_request_to_url(url, :head, @healthcheck_path)
233
236
  end
234
237
 
235
- def healthcheck!
238
+ def healthcheck!(register_phase = true)
236
239
  # Try to keep locking granularity low such that we don't affect IO...
237
240
  @state_mutex.synchronize { @url_info.select {|url,meta| meta[:state] != :alive } }.each do |url,meta|
238
241
  begin
239
242
  health_check_request(url)
243
+
244
+ # when called from resurrectionist skip the product check done during register phase
245
+ if register_phase
246
+ if !elasticsearch?(url)
247
+ raise LogStash::ConfigurationError, "Could not connect to a compatible version of Elasticsearch"
248
+ end
249
+ end
240
250
  # If no exception was raised it must have succeeded!
241
251
  logger.warn("Restored connection to ES instance", url: url.sanitized.to_s)
242
252
  # We reconnected to this node, check its ES version
@@ -254,6 +264,42 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
254
264
  end
255
265
  end
256
266
 
267
+ def elasticsearch?(url)
268
+ begin
269
+ response = perform_request_to_url(url, :get, ROOT_URI_PATH)
270
+ rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError => e
271
+ return false if response.code == 401 || response.code == 403
272
+ raise e
273
+ end
274
+
275
+ version_info = LogStash::Json.load(response.body)
276
+ return false if version_info['version'].nil?
277
+
278
+ version = ::Gem::Version.new(version_info["version"]['number'])
279
+ return false if version < ::Gem::Version.new('6.0.0')
280
+
281
+ if VERSION_6_TO_7.satisfied_by?(version)
282
+ return valid_tagline?(version_info)
283
+ elsif VERSION_7_TO_7_14.satisfied_by?(version)
284
+ build_flavor = version_info["version"]['build_flavor']
285
+ return false if build_flavor.nil? || build_flavor != 'default' || !valid_tagline?(version_info)
286
+ else
287
+ # case >= 7.14
288
+ lower_headers = response.headers.transform_keys {|key| key.to_s.downcase }
289
+ product_header = lower_headers['x-elastic-product']
290
+ return false if product_header != 'Elasticsearch'
291
+ end
292
+ return true
293
+ rescue => e
294
+ logger.error("Unable to retrieve Elasticsearch version", url: url.sanitized.to_s, exception: e.class, message: e.message)
295
+ false
296
+ end
297
+
298
+ def valid_tagline?(version_info)
299
+ tagline = version_info['tagline']
300
+ tagline == "You Know, for Search"
301
+ end
302
+
257
303
  def stop_resurrectionist
258
304
  @resurrectionist.join if @resurrectionist
259
305
  end