logstash-output-elasticsearch 11.3.0-java → 11.4.0-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 +19 -2
- data/docs/index.asciidoc +3 -7
- data/lib/logstash/outputs/elasticsearch/data_stream_support.rb +43 -9
- data/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb +40 -16
- data/lib/logstash/outputs/elasticsearch/http_client/pool.rb +5 -9
- data/lib/logstash/outputs/elasticsearch/http_client.rb +1 -2
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-7x.json +2196 -288
- data/lib/logstash/outputs/elasticsearch/templates/ecs-v1/elasticsearch-8x.json +2196 -288
- data/lib/logstash/outputs/elasticsearch.rb +5 -1
- data/logstash-output-elasticsearch.gemspec +2 -1
- data/spec/es_spec_helper.rb +5 -1
- data/spec/integration/outputs/data_stream_spec.rb +7 -0
- data/spec/integration/outputs/ilm_spec.rb +2 -1
- data/spec/integration/outputs/ingest_pipeline_spec.rb +2 -1
- data/spec/integration/outputs/retry_spec.rb +2 -1
- data/spec/integration/outputs/sniffer_spec.rb +1 -1
- data/spec/unit/outputs/elasticsearch/data_stream_support_spec.rb +52 -4
- data/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb +6 -5
- data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +1 -1
- data/spec/unit/outputs/elasticsearch_spec.rb +22 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3932944b80f3ae81063657ab9255cb9504624d1c6c0634c547b69b38d4a9b4a9
|
4
|
+
data.tar.gz: b850f5abbe8ae00b62e379d6f7c90802172602f23a3ab0e3f67b1a4d8319bbea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bc64de78f7ca0808e377595774f63b874d753801bbee8722bcd58af6a556e9c8baae683359179b65ee5a282c321c40dbeda838a9caacb5fc7ff14e7fe63e294
|
7
|
+
data.tar.gz: 0ff0a9731418cb7858e51109c8392d4a7692629d85141eedfa7019d99bbc12d7b9f016bd21d976f390ba5d745e039be6998742107b0eded2525a8c4dc7d0bf5f
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,30 @@
|
|
1
|
+
## 11.4.0
|
2
|
+
- Updates ECS templates [#1062](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1062)
|
3
|
+
- Updates v1 templates to 1.12.1 for use with Elasticsearch 7.x and 8.x
|
4
|
+
- Updates BETA preview of ECS v8 templates for Elasticsearch 7.x and 8.x
|
5
|
+
|
6
|
+
## 11.3.3
|
7
|
+
- Feat: add support for 'traces' data stream type [#1057](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1057)
|
8
|
+
|
9
|
+
## 11.3.2
|
10
|
+
- Refactor: review manticore error handling/logging, logging originating cause in case of connection related error when debug level is enabled [#1029](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1029)
|
11
|
+
- Java causes on connection related exceptions will now be extra logged when plugin is logging at debug level
|
12
|
+
|
13
|
+
## 11.3.1
|
14
|
+
- ECS-related fixes [#1046](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1046)
|
15
|
+
- Data Streams requirement on ECS is properly enforced when running on Logstash 8, and warned about when running on Logstash 7.
|
16
|
+
- ECS Compatibility v8 can now be selected
|
17
|
+
|
1
18
|
## 11.3.0
|
2
19
|
- Adds ECS templates [#1048](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1048)
|
3
20
|
- Adds templates for ECS v1 for Elasticsearch 8.x
|
4
21
|
- Adds templates for BETA preview of ECS v8 for both Elasticsearch 7.x and 8.x
|
5
22
|
|
6
23
|
## 11.2.3
|
7
|
-
- 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
|
24
|
+
- 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. [#1049](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1049)
|
8
25
|
|
9
26
|
## 11.2.2
|
10
|
-
- 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)
|
27
|
+
- Update ECS templates from upstream; `ecs_compatiblity => v1` now resolves to templates for ECS v1.12.1 [#1047](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1047). Fixes [#1027](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/1027)
|
11
28
|
|
12
29
|
## 11.2.1
|
13
30
|
- Fix referencing Gem classes from global lexical scope [#1044](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1044)
|
data/docs/index.asciidoc
CHANGED
@@ -117,12 +117,8 @@ output {
|
|
117
117
|
|
118
118
|
==== Writing to different indices: best practices
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
You cannot use dynamic variable substitution when `ilm_enabled` is `true` and
|
123
|
-
when using `ilm_rollover_alias`.
|
124
|
-
|
125
|
-
================================================================================
|
120
|
+
NOTE: You cannot use dynamic variable substitution when `ilm_enabled` is `true`
|
121
|
+
and when using `ilm_rollover_alias`.
|
126
122
|
|
127
123
|
If you're sending events to the same Elasticsearch cluster, but you're targeting different indices you can:
|
128
124
|
|
@@ -509,7 +505,7 @@ overwritten with a warning.
|
|
509
505
|
* Default value is `logs`.
|
510
506
|
|
511
507
|
The data stream type used to construct the data stream at index time.
|
512
|
-
Currently, only `logs`, `metrics` and `
|
508
|
+
Currently, only `logs`, `metrics`, `synthetics` and `traces` are supported.
|
513
509
|
|
514
510
|
[id="plugins-{type}s-{plugin}-doc_as_upsert"]
|
515
511
|
===== `doc_as_upsert`
|
@@ -2,6 +2,15 @@ module LogStash module Outputs class ElasticSearch
|
|
2
2
|
# DS specific behavior/configuration.
|
3
3
|
module DataStreamSupport
|
4
4
|
|
5
|
+
# @api private
|
6
|
+
ENABLING_ECS_GUIDANCE = <<~END.tr("\n", " ")
|
7
|
+
Elasticsearch data streams require that events adhere to the Elastic Common Schema.
|
8
|
+
While `ecs_compatibility` can be set for this individual Elasticsearch output plugin, doing so will not fix schema conflicts caused by upstream plugins in your pipeline.
|
9
|
+
To avoid mapping conflicts, you will need to use ECS-compatible field names and datatypes throughout your pipeline.
|
10
|
+
Many plugins support an `ecs_compatibility` mode, and the `pipeline.ecs_compatibility` setting can be used to opt-in for all plugins in a pipeline.
|
11
|
+
END
|
12
|
+
private_constant :ENABLING_ECS_GUIDANCE
|
13
|
+
|
5
14
|
def self.included(base)
|
6
15
|
# Defines whether data will be indexed into an Elasticsearch data stream,
|
7
16
|
# `data_stream_*` settings will only be used if this setting is enabled!
|
@@ -9,7 +18,7 @@ module LogStash module Outputs class ElasticSearch
|
|
9
18
|
# Defaults to `false` in Logstash 7.x and `auto` starting in Logstash 8.0.
|
10
19
|
base.config :data_stream, :validate => ['true', 'false', 'auto']
|
11
20
|
|
12
|
-
base.config :data_stream_type, :validate => ['logs', 'metrics', 'synthetics'], :default => 'logs'
|
21
|
+
base.config :data_stream_type, :validate => ['logs', 'metrics', 'synthetics', 'traces'], :default => 'logs'
|
13
22
|
base.config :data_stream_dataset, :validate => :dataset_identifier, :default => 'generic'
|
14
23
|
base.config :data_stream_namespace, :validate => :namespace_identifier, :default => 'default'
|
15
24
|
|
@@ -36,6 +45,8 @@ module LogStash module Outputs class ElasticSearch
|
|
36
45
|
"#{type}-#{dataset}-#{namespace}"
|
37
46
|
end
|
38
47
|
|
48
|
+
DATA_STREAMS_REQUIRES_ECS_LS_VERSION = '8.0.0'
|
49
|
+
|
39
50
|
# @param params the user configuration for the ES output
|
40
51
|
# @note LS initialized configuration (with filled defaults) won't detect as data-stream
|
41
52
|
# compatible, only explicit (`original_params`) config should be tested.
|
@@ -56,14 +67,26 @@ module LogStash module Outputs class ElasticSearch
|
|
56
67
|
@logger.error "Invalid data stream configuration, following parameters are not supported:", invalid_data_stream_params
|
57
68
|
raise LogStash::ConfigurationError, "Invalid data stream configuration: #{invalid_data_stream_params.keys}"
|
58
69
|
end
|
70
|
+
if ecs_compatibility == :disabled
|
71
|
+
if ::Gem::Version.create(LOGSTASH_VERSION) < ::Gem::Version.create(DATA_STREAMS_REQUIRES_ECS_LS_VERSION)
|
72
|
+
@deprecation_logger.deprecated "In a future release of Logstash, the Elasticsearch output plugin's `data_stream => true` will require the plugin to be run in ECS compatibility mode. " + ENABLING_ECS_GUIDANCE
|
73
|
+
else
|
74
|
+
@logger.error "Invalid data stream configuration; `ecs_compatibility` must not be `disabled`. " + ENABLING_ECS_GUIDANCE
|
75
|
+
raise LogStash::ConfigurationError, "Invalid data stream configuration: `ecs_compatibility => disabled`"
|
76
|
+
end
|
77
|
+
end
|
59
78
|
return true
|
60
79
|
else
|
61
|
-
use_data_stream = data_stream_default(data_stream_params, invalid_data_stream_params
|
62
|
-
if
|
80
|
+
use_data_stream = data_stream_default(data_stream_params, invalid_data_stream_params)
|
81
|
+
if use_data_stream
|
82
|
+
@logger.info("Config is compliant with data streams. `data_stream => auto` resolved to `true`")
|
83
|
+
elsif data_stream_params.any?
|
63
84
|
# DS (auto) disabled but there's still some data-stream parameters (and no `data_stream => false`)
|
64
85
|
@logger.error "Ambiguous configuration; data stream settings are present, but data streams are not enabled", data_stream_params
|
65
86
|
raise LogStash::ConfigurationError, "Ambiguous configuration, please set data_stream => true " +
|
66
87
|
"or remove data stream specific settings: #{data_stream_params.keys}"
|
88
|
+
else
|
89
|
+
@logger.info("Config is not compliant with data streams. `data_stream => auto` resolved to `false`")
|
67
90
|
end
|
68
91
|
use_data_stream
|
69
92
|
end
|
@@ -93,6 +116,7 @@ module LogStash module Outputs class ElasticSearch
|
|
93
116
|
true
|
94
117
|
when 'data_stream'
|
95
118
|
value.to_s == 'true'
|
119
|
+
when 'ecs_compatibility' then true # required for LS <= 6.x
|
96
120
|
else
|
97
121
|
name.start_with?('data_stream_') ||
|
98
122
|
shared_params.include?(name) ||
|
@@ -110,8 +134,8 @@ module LogStash module Outputs class ElasticSearch
|
|
110
134
|
# @return [Gem::Version] if ES supports DS nil (or raise) otherwise
|
111
135
|
def assert_es_version_supports_data_streams
|
112
136
|
fail 'no last_es_version' unless last_es_version # assert - should not happen
|
113
|
-
es_version = Gem::Version.create(last_es_version)
|
114
|
-
if es_version < Gem::Version.create(DATA_STREAMS_ORIGIN_ES_VERSION)
|
137
|
+
es_version = ::Gem::Version.create(last_es_version)
|
138
|
+
if es_version < ::Gem::Version.create(DATA_STREAMS_ORIGIN_ES_VERSION)
|
115
139
|
@logger.error "Elasticsearch version does not support data streams, Logstash might end up writing to an index", es_version: es_version.version
|
116
140
|
# NOTE: when switching to synchronous check from register, this should be a ConfigurationError
|
117
141
|
raise LogStash::Error, "A data_stream configuration is only supported since Elasticsearch #{DATA_STREAMS_ORIGIN_ES_VERSION} " +
|
@@ -123,18 +147,28 @@ module LogStash module Outputs class ElasticSearch
|
|
123
147
|
DATA_STREAMS_ENABLED_BY_DEFAULT_LS_VERSION = '8.0.0'
|
124
148
|
|
125
149
|
# when data_stream => is either 'auto' or not set
|
126
|
-
|
127
|
-
|
150
|
+
# @param data_stream_params [#any?]
|
151
|
+
# @param invalid_data_stream_config [#any?#inspect]
|
152
|
+
def data_stream_default(data_stream_params, invalid_data_stream_config)
|
153
|
+
if ecs_compatibility == :disabled
|
154
|
+
@logger.debug("Not eligible for data streams because ecs_compatibility is not enabled. " + ENABLING_ECS_GUIDANCE)
|
155
|
+
return false
|
156
|
+
end
|
157
|
+
|
158
|
+
ds_default = ::Gem::Version.create(LOGSTASH_VERSION) >= ::Gem::Version.create(DATA_STREAMS_ENABLED_BY_DEFAULT_LS_VERSION)
|
128
159
|
|
129
160
|
if ds_default # LS 8.0
|
130
|
-
|
161
|
+
if invalid_data_stream_config.any?
|
162
|
+
@logger.debug("Not eligible for data streams because config contains one or more settings that are not compatible with data streams: #{invalid_data_stream_config.inspect}")
|
163
|
+
return false
|
164
|
+
end
|
131
165
|
|
132
166
|
@logger.debug 'Configuration is data stream compliant'
|
133
167
|
return true
|
134
168
|
end
|
135
169
|
|
136
170
|
# LS 7.x
|
137
|
-
if
|
171
|
+
if !invalid_data_stream_config.any? && !data_stream_params.any?
|
138
172
|
@logger.warn "Configuration is data stream compliant but due backwards compatibility Logstash 7.x will not assume " +
|
139
173
|
"writing to a data-stream, default behavior will change on Logstash 8.0 " +
|
140
174
|
"(set `data_stream => true/false` to disable this warning)"
|
@@ -7,9 +7,9 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
|
|
7
7
|
class ManticoreAdapter
|
8
8
|
attr_reader :manticore, :logger
|
9
9
|
|
10
|
-
def initialize(logger, options
|
10
|
+
def initialize(logger, options)
|
11
11
|
@logger = logger
|
12
|
-
options = options.
|
12
|
+
options = options.dup
|
13
13
|
options[:ssl] = options[:ssl] || {}
|
14
14
|
|
15
15
|
# We manage our own retries directly, so let's disable them here
|
@@ -66,23 +66,53 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
|
|
66
66
|
|
67
67
|
request_uri = format_url(url, path)
|
68
68
|
request_uri_as_string = remove_double_escaping(request_uri.to_s)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
begin
|
70
|
+
resp = @manticore.send(method.downcase, request_uri_as_string, params)
|
71
|
+
# Manticore returns lazy responses by default
|
72
|
+
# We want to block for our usage, this will wait for the response to finish
|
73
|
+
resp.call
|
74
|
+
rescue ::Manticore::ManticoreException => e
|
75
|
+
log_request_error(e)
|
76
|
+
raise ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError.new(e, request_uri_as_string)
|
77
|
+
end
|
75
78
|
|
76
79
|
# 404s are excluded because they are valid codes in the case of
|
77
80
|
# template installation. We might need a better story around this later
|
78
81
|
# but for our current purposes this is correct
|
79
|
-
|
80
|
-
|
82
|
+
code = resp.code
|
83
|
+
if code < 200 || code > 299 && code != 404
|
84
|
+
raise ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError.new(code, request_uri, body, resp.body)
|
81
85
|
end
|
82
86
|
|
83
87
|
resp
|
84
88
|
end
|
85
89
|
|
90
|
+
def log_request_error(e)
|
91
|
+
details = { message: e.message, exception: e.class }
|
92
|
+
details[:cause] = e.cause if e.respond_to?(:cause)
|
93
|
+
details[:backtrace] = e.backtrace if @logger.debug?
|
94
|
+
|
95
|
+
level = case e
|
96
|
+
when ::Manticore::Timeout
|
97
|
+
:debug
|
98
|
+
when ::Manticore::UnknownException
|
99
|
+
:warn
|
100
|
+
else
|
101
|
+
:info
|
102
|
+
end
|
103
|
+
|
104
|
+
@logger.send level, "Failed to perform request", details
|
105
|
+
log_java_exception(details[:cause], :debug) if details[:cause] && @logger.debug?
|
106
|
+
end
|
107
|
+
|
108
|
+
def log_java_exception(e, level = :debug)
|
109
|
+
return unless e.is_a?(java.lang.Exception)
|
110
|
+
# @logger.name using the same convention as LS does
|
111
|
+
logger = self.class.name.gsub('::', '.').downcase
|
112
|
+
logger = org.apache.logging.log4j.LogManager.getLogger(logger)
|
113
|
+
logger.send(level, '', e) # logger.error('', e) - prints nested causes
|
114
|
+
end
|
115
|
+
|
86
116
|
# Returned urls from this method should be checked for double escaping.
|
87
117
|
def format_url(url, path_and_query=nil)
|
88
118
|
request_uri = url.clone
|
@@ -96,9 +126,6 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
|
|
96
126
|
|
97
127
|
parsed_path_and_query = java.net.URI.new(path_and_query)
|
98
128
|
|
99
|
-
query = request_uri.query
|
100
|
-
parsed_query = parsed_path_and_query.query
|
101
|
-
|
102
129
|
new_query_parts = [request_uri.query, parsed_path_and_query.query].select do |part|
|
103
130
|
part && !part.empty? # Skip empty nil and ""
|
104
131
|
end
|
@@ -124,8 +151,5 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
|
|
124
151
|
@manticore.close
|
125
152
|
end
|
126
153
|
|
127
|
-
def host_unreachable_exceptions
|
128
|
-
[::Manticore::Timeout,::Manticore::SocketException, ::Manticore::ClientProtocolException, ::Manticore::ResolutionFailure, Manticore::SocketTimeout]
|
129
|
-
end
|
130
154
|
end
|
131
155
|
end; end; end; end
|
@@ -8,27 +8,25 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
|
|
8
8
|
attr_reader :url, :response_code, :request_body, :response_body
|
9
9
|
|
10
10
|
def initialize(response_code, url, request_body, response_body)
|
11
|
+
super("Got response code '#{response_code}' contacting Elasticsearch at URL '#{url}'")
|
12
|
+
|
11
13
|
@response_code = response_code
|
12
14
|
@url = url
|
13
15
|
@request_body = request_body
|
14
16
|
@response_body = response_body
|
15
17
|
end
|
16
18
|
|
17
|
-
def message
|
18
|
-
"Got response code '#{response_code}' contacting Elasticsearch at URL '#{@url}'"
|
19
|
-
end
|
20
19
|
end
|
21
20
|
class HostUnreachableError < Error;
|
22
21
|
attr_reader :original_error, :url
|
23
22
|
|
24
23
|
def initialize(original_error, url)
|
24
|
+
super("Elasticsearch Unreachable: [#{url}][#{original_error.class}] #{original_error.message}")
|
25
|
+
|
25
26
|
@original_error = original_error
|
26
27
|
@url = url
|
27
28
|
end
|
28
29
|
|
29
|
-
def message
|
30
|
-
"Elasticsearch Unreachable: [#{@url}][#{original_error.class}] #{original_error.message}"
|
31
|
-
end
|
32
30
|
end
|
33
31
|
|
34
32
|
attr_reader :logger, :adapter, :sniffing, :sniffer_delay, :resurrect_delay, :healthcheck_path, :sniffing_path, :bulk_path
|
@@ -323,9 +321,7 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
|
|
323
321
|
end
|
324
322
|
|
325
323
|
def perform_request_to_url(url, method, path, params={}, body=nil)
|
326
|
-
|
327
|
-
rescue *@adapter.host_unreachable_exceptions => e
|
328
|
-
raise HostUnreachableError.new(e, url), "Could not reach host #{e.class}: #{e.message}"
|
324
|
+
@adapter.perform_request(url, method, path, params, body)
|
329
325
|
end
|
330
326
|
|
331
327
|
def normalize_url(uri)
|
@@ -322,8 +322,7 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
322
322
|
|
323
323
|
adapter_options[:headers] = client_settings[:headers] if client_settings[:headers]
|
324
324
|
|
325
|
-
|
326
|
-
adapter = adapter_class.new(@logger, adapter_options)
|
325
|
+
::LogStash::Outputs::ElasticSearch::HttpClient::ManticoreAdapter.new(@logger, adapter_options)
|
327
326
|
end
|
328
327
|
|
329
328
|
def prepare_user_agent
|