logstash-output-elasticsearch 11.0.5-java → 11.2.2-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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/logstash/outputs/elasticsearch/http_client/pool.rb +48 -2
- data/lib/logstash/outputs/elasticsearch/http_client.rb +15 -0
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-6x.json +2958 -224
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-7x.json +2950 -300
- data/logstash-output-elasticsearch.gemspec +3 -1
- data/spec/es_spec_helper.rb +10 -1
- data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +158 -9
- data/spec/unit/outputs/elasticsearch/http_client_spec.rb +69 -0
- data/spec/unit/outputs/elasticsearch_spec.rb +1 -1
- metadata +30 -3
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-8x.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1875fec2480eb6333ab5468fcab7310efef1327b20c1d7908cb8e1cc83d3d98a
|
4
|
+
data.tar.gz: f7ba2a0bffd9f4205a887bbafd277f254d9b63138f4b24da96e0eb74847c2a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 896ba67674bb5e589ae9f9ba622e98f9840d7c1823e8fbeafab946826c08d71438ce1e1d448258ca240c4704f734840ebb56e6fbd0bc7ba56067b23707396c42
|
7
|
+
data.tar.gz: 8390add54b65038c916b7589bb02868450568e7e647008a2e68216a4f47168fe6c79ee9ac945f466898667b1bde7f71d9076fc528c2d7d24b01b0e9eafa58cf0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 11.2.2
|
2
|
+
- 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)
|
3
|
+
|
4
|
+
## 11.2.1
|
5
|
+
- Fix referencing Gem classes from global lexical scope [#1044](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1044)
|
6
|
+
|
7
|
+
## 11.2.0
|
8
|
+
- Added preflight checks on Elasticsearch [#1026](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1026)
|
9
|
+
|
10
|
+
## 11.1.0
|
11
|
+
- Feat: add `user-agent` header passed to the Elasticsearch HTTP connection [#1038](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1038)
|
12
|
+
|
1
13
|
## 11.0.5
|
2
14
|
- Fixed running post-register action when Elasticsearch status change from unhealthy to healthy [#1035](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1035)
|
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
|
@@ -4,6 +4,7 @@ require 'logstash/outputs/elasticsearch/http_client/manticore_adapter'
|
|
4
4
|
require 'cgi'
|
5
5
|
require 'zlib'
|
6
6
|
require 'stringio'
|
7
|
+
require 'java'
|
7
8
|
|
8
9
|
module LogStash; module Outputs; class ElasticSearch;
|
9
10
|
# This is a constant instead of a config option because
|
@@ -301,6 +302,8 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
301
302
|
:request_timeout => timeout,
|
302
303
|
}
|
303
304
|
|
305
|
+
adapter_options[:user_agent] = prepare_user_agent
|
306
|
+
|
304
307
|
adapter_options[:proxy] = client_settings[:proxy] if client_settings[:proxy]
|
305
308
|
|
306
309
|
adapter_options[:check_connection_timeout] = client_settings[:check_connection_timeout] if client_settings[:check_connection_timeout]
|
@@ -322,6 +325,18 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
322
325
|
adapter_class = ::LogStash::Outputs::ElasticSearch::HttpClient::ManticoreAdapter
|
323
326
|
adapter = adapter_class.new(@logger, adapter_options)
|
324
327
|
end
|
328
|
+
|
329
|
+
def prepare_user_agent
|
330
|
+
os_name = java.lang.System.getProperty('os.name')
|
331
|
+
os_version = java.lang.System.getProperty('os.version')
|
332
|
+
os_arch = java.lang.System.getProperty('os.arch')
|
333
|
+
jvm_vendor = java.lang.System.getProperty('java.vendor')
|
334
|
+
jvm_version = java.lang.System.getProperty('java.version')
|
335
|
+
|
336
|
+
plugin_version = Gem.loaded_specs['logstash-output-elasticsearch'].version
|
337
|
+
# example: Logstash/7.14.1 (OS=Linux-5.4.0-84-generic-amd64; JVM=AdoptOpenJDK-11.0.11) logstash-output-elasticsearch/11.0.1
|
338
|
+
"Logstash/#{LOGSTASH_VERSION} (OS=#{os_name}-#{os_version}-#{os_arch}; JVM=#{jvm_vendor}-#{jvm_version}) logstash-output-elasticsearch/#{plugin_version}"
|
339
|
+
end
|
325
340
|
|
326
341
|
def build_pool(options)
|
327
342
|
adapter = build_adapter(options)
|