logstash-output-elasticsearch 11.3.0-java → 11.3.1-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: a9b6a7eacf857e3f0e0953d2aa1628f3ea50f9928d73dc71fd0d09db2f2cd147
4
- data.tar.gz: 16c0222ff642f203c5a9c0553faac90b6fbf02875910191cd9b921e07b52f1df
3
+ metadata.gz: dccee6612b454d47b0596a9feb04db71f51f368a34906f559b8f7a8df7cf166e
4
+ data.tar.gz: 27d8ab736dd7c3ffa46d1229ad70afd5e8b23813ee09aa3e9d4ec05b4f263a76
5
5
  SHA512:
6
- metadata.gz: 15b8d3c36d59e2bdb087058e24a85ddd67ad09f2708ccad357b032b7c3e6bf04beb224138738ca3be09a28cd5e24fb9d5b2883b510ee406500393132825d79f1
7
- data.tar.gz: e1cc0b009714cead91f295baf08dee61fb76938abd2c1456a48440d78ab62d4beffffd761d4a831057757d090052e8bb83d670ad72805171435b056f1184500f
6
+ metadata.gz: d7ab3e32387faf0cc2680fc1446e9a330314d2ead466487fd6f63a27ab2757cac8c2d90cb41bb0eba422986b22821d0e0c813617ba153225058b1e1d09765598
7
+ data.tar.gz: df0a5b6cbcbdc592e1c18906f6a54a97d309afbbd1c36529f812501df31f78c7e4c2ba2fb8a3eab72e9fd53dfbca8388b710dc772a20ba9084c59ce1f5aa43fc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 11.3.1
2
+ - ECS-related fixes [#1046](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1046)
3
+ - Data Streams requirement on ECS is properly enforced when running on Logstash 8, and warned about when running on Logstash 7.
4
+ - ECS Compatibility v8 can now be selected
5
+
1
6
  ## 11.3.0
2
7
  - Adds ECS templates [#1048](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1048)
3
8
  - Adds templates for ECS v1 for Elasticsearch 8.x
@@ -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!
@@ -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.empty?)
62
- if !use_data_stream && data_stream_params.any?
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
- def data_stream_default(data_stream_params, valid_data_stream_config)
127
- ds_default = Gem::Version.create(LOGSTASH_VERSION) >= Gem::Version.create(DATA_STREAMS_ENABLED_BY_DEFAULT_LS_VERSION)
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
- return false unless valid_data_stream_config
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 valid_data_stream_config && !data_stream_params.any?
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)"
@@ -94,6 +94,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
94
94
  require "logstash/outputs/elasticsearch/ilm"
95
95
  require "logstash/outputs/elasticsearch/data_stream_support"
96
96
  require 'logstash/plugin_mixins/ecs_compatibility_support'
97
+ require 'logstash/plugin_mixins/deprecation_logger_support'
97
98
 
98
99
  # Protocol agnostic methods
99
100
  include(LogStash::PluginMixins::ElasticSearch::Common)
@@ -104,6 +105,9 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
104
105
  # ecs_compatibility option, provided by Logstash core or the support adapter.
105
106
  include(LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8))
106
107
 
108
+ # deprecation logger adapter for older Logstashes
109
+ include(LogStash::PluginMixins::DeprecationLoggerSupport)
110
+
107
111
  # Generic/API config options that any document indexer output needs
108
112
  include(LogStash::PluginMixins::ElasticSearch::APIConfigs)
109
113
 
@@ -498,7 +502,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
498
502
  @default_index = "logstash-%{+yyyy.MM.dd}"
499
503
  @default_ilm_rollover_alias = "logstash"
500
504
  @default_template_name = 'logstash'
501
- when :v1
505
+ when :v1, :v8
502
506
  @default_index = "ecs-logstash-%{+yyyy.MM.dd}"
503
507
  @default_ilm_rollover_alias = "ecs-logstash"
504
508
  @default_template_name = 'ecs-logstash'
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '11.3.0'
3
+ s.version = '11.3.1'
4
4
 
5
5
  s.licenses = ['apache-2.0']
6
6
  s.summary = "Stores logs in Elasticsearch"
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency 'stud', ['>= 0.0.17', '~> 0.0']
26
26
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
27
27
  s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.0'
28
+ s.add_runtime_dependency 'logstash-mixin-deprecation_logger_support', '~>1.0'
28
29
 
29
30
  s.add_development_dependency 'logstash-codec-plain'
30
31
  s.add_development_dependency 'logstash-devutils'
@@ -12,6 +12,13 @@ describe "data streams", :integration => true do
12
12
 
13
13
  subject { LogStash::Outputs::ElasticSearch.new(options) }
14
14
 
15
+ # All data-streams features require that the plugin be run in a non-disabled ECS compatibility mode.
16
+ # We run the plugin in ECS by default, and add test scenarios specifically for it being disabled.
17
+ let(:ecs_compatibility) { :v1 }
18
+ before(:each) do
19
+ allow( subject ).to receive(:ecs_compatibility).and_return(ecs_compatibility)
20
+ end
21
+
15
22
  before :each do
16
23
  @es = get_client
17
24
  @es.delete_by_query(index: ".ds-#{ds_name}-*", expand_wildcards: :all, body: { query: { match_all: {} } }) rescue nil
@@ -4,9 +4,17 @@ require "logstash/outputs/elasticsearch/data_stream_support"
4
4
  describe LogStash::Outputs::ElasticSearch::DataStreamSupport do
5
5
 
6
6
  subject { LogStash::Outputs::ElasticSearch.new(options) }
7
+
7
8
  let(:options) { { 'hosts' => [ 'localhost:12345' ] } }
8
9
  let(:es_version) { '7.10.1' }
9
10
 
11
+ # All data-streams features require that the plugin be run in a non-disabled ECS compatibility mode.
12
+ # We run the plugin in ECS by default, and add test scenarios specifically for it being disabled.
13
+ let(:ecs_compatibility) { :v1 }
14
+ before(:each) do
15
+ allow_any_instance_of(LogStash::Outputs::ElasticSearch).to receive(:ecs_compatibility).and_return(ecs_compatibility)
16
+ end
17
+
10
18
  let(:do_register) { false }
11
19
  let(:stub_plugin_register!) do
12
20
  allow(subject).to receive(:last_es_version).and_return(es_version)
@@ -52,9 +60,7 @@ describe LogStash::Outputs::ElasticSearch::DataStreamSupport do
52
60
  end
53
61
 
54
62
  it "warns when configuration is data-stream compliant (LS 7.x)" do
55
- expect( subject.logger ).to receive(:warn) do |msg|
56
- expect(msg).to include "Configuration is data stream compliant but due backwards compatibility Logstash 7.x"
57
- end
63
+ expect( subject.logger ).to receive(:warn).with(a_string_including "Configuration is data stream compliant but due backwards compatibility Logstash 7.x")
58
64
  change_constant :LOGSTASH_VERSION, '7.11.0' do
59
65
  expect( subject.data_stream_config? ).to be false
60
66
  end
@@ -66,6 +72,25 @@ describe LogStash::Outputs::ElasticSearch::DataStreamSupport do
66
72
  end
67
73
  end
68
74
 
75
+ context 'ecs_compatibility disabled' do
76
+ let(:ecs_compatibility) { :disabled }
77
+
78
+ {
79
+ '7.x (pre-DS)' => '7.9.0',
80
+ '7.x (with DS)' => '7.11.0',
81
+ '8.0' => '8.0.0',
82
+ '8.x' => '8.1.2',
83
+ }.each do |ls_version_desc, ls_version|
84
+ context "on LS #{ls_version_desc}" do
85
+ around(:each) { |example| change_constant(:LOGSTASH_VERSION, ls_version, &example) }
86
+ it "does not use data-streams" do
87
+ expect( subject.logger ).to receive(:debug).with(a_string_including "ecs_compatibility is not enabled")
88
+ expect( subject.data_stream_config? ).to be false
89
+ end
90
+ end
91
+ end
92
+ end
93
+
69
94
  context 'non-compatible ES' do
70
95
 
71
96
  let(:es_version) { '7.8.0' }
@@ -95,6 +120,7 @@ describe LogStash::Outputs::ElasticSearch::DataStreamSupport do
95
120
  before { allow(subject).to receive(:last_es_version).and_return(es_version) }
96
121
 
97
122
  it "does not use data-streams on LS 7.x" do
123
+ expect( subject.logger ).to receive(:warn).with(a_string_including "Logstash 7.x will not assume writing to a data-stream")
98
124
  change_constant :LOGSTASH_VERSION, '7.10.0' do
99
125
  expect( subject.data_stream_config? ).to be false
100
126
  end
@@ -197,12 +223,34 @@ describe LogStash::Outputs::ElasticSearch::DataStreamSupport do
197
223
  end
198
224
  end
199
225
 
200
- it "does use data-streams on LS 8.0" do
226
+ it "does use data-streams on LS 8.x" do
201
227
  change_constant :LOGSTASH_VERSION, '8.1.0' do
202
228
  expect( subject.data_stream_config? ).to be true
203
229
  end
204
230
  end
205
231
 
232
+ context 'with ecs_compatibility disabled' do
233
+ let(:ecs_compatibility) { :disabled }
234
+
235
+ context 'when running on LS 7.x' do
236
+ around(:each) { |example| change_constant(:LOGSTASH_VERSION, '7.15.1', &example) }
237
+
238
+ it "emits a deprecation warning and uses data streams anway" do
239
+ expect( subject.deprecation_logger ).to receive(:deprecated).with(a_string_including "`data_stream => true` will require the plugin to be run in ECS compatibility mode")
240
+ expect( subject.data_stream_config? ).to be true
241
+ end
242
+ end
243
+
244
+ context 'when running on LS 8.x' do
245
+ around(:each) { |example| change_constant(:LOGSTASH_VERSION, '8.0.0', &example) }
246
+
247
+ it "errors helpfully" do
248
+ expect{ subject.data_stream_config? }.to raise_error(LogStash::ConfigurationError, a_string_including("Invalid data stream configuration: `ecs_compatibility => disabled`"))
249
+ end
250
+ end
251
+
252
+ end
253
+
206
254
  context 'non-compatible ES' do
207
255
 
208
256
  let(:es_version) { '6.8.11' }
@@ -4,6 +4,8 @@ require "flores/random"
4
4
  require 'concurrent/atomic/count_down_latch'
5
5
  require "logstash/outputs/elasticsearch"
6
6
 
7
+ require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
8
+
7
9
  describe LogStash::Outputs::ElasticSearch do
8
10
  subject(:elasticsearch_output_instance) { described_class.new(options) }
9
11
  let(:options) { {} }
@@ -922,6 +924,25 @@ describe LogStash::Outputs::ElasticSearch do
922
924
  end
923
925
  end
924
926
 
927
+ describe 'ECS Compatibility Support', :ecs_compatibility_support do
928
+ [
929
+ :disabled,
930
+ :v1,
931
+ :v8,
932
+ ].each do |ecs_compatibility|
933
+ context "When initialized with `ecs_compatibility => #{ecs_compatibility}`" do
934
+ let(:options) { Hash.new }
935
+ subject(:output) { described_class.new(options.merge("ecs_compatibility" => "#{ecs_compatibility}")) }
936
+ context 'when registered' do
937
+ before(:each) { output.register }
938
+ it 'has the correct effective ECS compatibility setting' do
939
+ expect(output.ecs_compatibility).to eq(ecs_compatibility)
940
+ end
941
+ end
942
+ end
943
+ end
944
+ end
945
+
925
946
  describe "post-register ES setup" do
926
947
  let(:do_register) { false }
927
948
  let(:es_version) { '7.10.0' } # DS default on LS 8.x
@@ -959,7 +980,7 @@ describe LogStash::Outputs::ElasticSearch do
959
980
  context 'error raised' do
960
981
 
961
982
  let(:es_version) { '7.8.0' }
962
- let(:options) { super().merge('data_stream' => 'true') }
983
+ let(:options) { super().merge('data_stream' => 'true', 'ecs_compatibility' => 'v1') }
963
984
  let(:latch) { Concurrent::CountDownLatch.new }
964
985
 
965
986
  before do
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.3.0
4
+ version: 11.3.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-03 00:00:00.000000000 Z
11
+ date: 2021-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -84,6 +84,20 @@ dependencies:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
86
  version: '1.0'
87
+ - !ruby/object:Gem::Dependency
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '1.0'
93
+ name: logstash-mixin-deprecation_logger_support
94
+ prerelease: false
95
+ type: :runtime
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '1.0'
87
101
  - !ruby/object:Gem::Dependency
88
102
  requirement: !ruby/object:Gem::Requirement
89
103
  requirements: