logstash-output-elasticsearch 10.7.0-java → 10.8.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/CONTRIBUTORS +1 -0
  4. data/README.md +1 -1
  5. data/docs/index.asciidoc +226 -153
  6. data/lib/logstash/outputs/elasticsearch.rb +302 -165
  7. data/lib/logstash/outputs/elasticsearch/http_client.rb +7 -2
  8. data/lib/logstash/outputs/elasticsearch/http_client/pool.rb +13 -28
  9. data/lib/logstash/outputs/elasticsearch/http_client_builder.rb +1 -0
  10. data/lib/logstash/outputs/elasticsearch/ilm.rb +9 -5
  11. data/lib/logstash/outputs/elasticsearch/license_checker.rb +47 -0
  12. data/lib/logstash/outputs/elasticsearch/template_manager.rb +8 -3
  13. data/lib/logstash/outputs/elasticsearch/templates/ecs-disabled/elasticsearch-8x.json +39 -33
  14. data/lib/logstash/plugin_mixins/elasticsearch/api_configs.rb +163 -0
  15. data/lib/logstash/{outputs → plugin_mixins}/elasticsearch/common.rb +40 -167
  16. data/lib/logstash/plugin_mixins/elasticsearch/noop_license_checker.rb +9 -0
  17. data/logstash-output-elasticsearch.gemspec +1 -1
  18. data/spec/es_spec_helper.rb +32 -12
  19. data/spec/fixtures/template-with-policy-es8x.json +50 -0
  20. data/spec/integration/outputs/ilm_spec.rb +34 -20
  21. data/spec/integration/outputs/metrics_spec.rb +1 -5
  22. data/spec/integration/outputs/retry_spec.rb +14 -2
  23. data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +45 -5
  24. data/spec/unit/outputs/elasticsearch/http_client_spec.rb +22 -0
  25. data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +31 -0
  26. data/spec/unit/outputs/elasticsearch_spec.rb +2 -2
  27. data/spec/unit/outputs/license_check_spec.rb +41 -0
  28. metadata +10 -4
  29. data/lib/logstash/outputs/elasticsearch/common_configs.rb +0 -167
@@ -1,7 +1,10 @@
1
1
  require "logstash/outputs/elasticsearch/template_manager"
2
2
 
3
- module LogStash; module Outputs; class ElasticSearch;
3
+ module LogStash; module PluginMixins; module ElasticSearch
4
4
  module Common
5
+
6
+ # This module defines common methods that can be reused by alternate elasticsearch output plugins such as the elasticsearch_data_streams output.
7
+
5
8
  attr_reader :client, :hosts
6
9
 
7
10
  # These codes apply to documents, not at the request level
@@ -9,116 +12,26 @@ module LogStash; module Outputs; class ElasticSearch;
9
12
  DOC_SUCCESS_CODES = [200, 201]
10
13
  DOC_CONFLICT_CODE = 409
11
14
 
12
- # When you use external versioning, you are communicating that you want
13
- # to ignore conflicts. More obviously, since an external version is a
14
- # constant part of the incoming document, we should not retry, as retrying
15
- # will never succeed.
16
- VERSION_TYPES_PERMITTING_CONFLICT = ["external", "external_gt", "external_gte"]
17
-
18
- def register
19
- @template_installed = Concurrent::AtomicBoolean.new(false)
20
- @stopping = Concurrent::AtomicBoolean.new(false)
21
- # To support BWC, we check if DLQ exists in core (< 5.4). If it doesn't, we use nil to resort to previous behavior.
22
- @dlq_writer = dlq_enabled? ? execution_context.dlq_writer : nil
23
- build_client
24
- setup_after_successful_connection
25
- check_action_validity
26
- @bulk_request_metrics = metric.namespace(:bulk_requests)
27
- @document_level_metrics = metric.namespace(:documents)
28
- @logger.info("New Elasticsearch output", :class => self.class.name, :hosts => @hosts.map(&:sanitized).map(&:to_s))
29
- end
30
-
31
- # Receive an array of events and immediately attempt to index them (no buffering)
32
- def multi_receive(events)
33
- until @template_installed.true?
34
- sleep 1
15
+ # Perform some ES options validations and Build the HttpClient.
16
+ # Note that this methods may sets the @user, @password, @hosts and @client ivars as a side effect.
17
+ # @param license_checker [#appropriate_license?] An optional license checker that will be used by the Pool class.
18
+ # @return [HttpClient] the new http client
19
+ def build_client(license_checker = nil)
20
+ params["license_checker"] = license_checker
21
+
22
+ # the following 3 options validation & setup methods are called inside build_client
23
+ # because they must be executed prior to building the client and logstash
24
+ # monitoring and management rely on directly calling build_client
25
+ # see https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/934#pullrequestreview-396203307
26
+ validate_authentication
27
+ fill_hosts_from_cloud_id
28
+ setup_hosts
29
+
30
+ params["metric"] = metric
31
+ if @proxy.eql?('')
32
+ @logger.warn "Supplied proxy setting (proxy => '') has no effect"
35
33
  end
36
- retrying_submit(events.map {|e| event_action_tuple(e)})
37
- end
38
-
39
- def setup_after_successful_connection
40
- @template_installer ||= Thread.new do
41
- sleep_interval = @retry_initial_interval
42
- until successful_connection? || @stopping.true?
43
- @logger.debug("Waiting for connectivity to Elasticsearch cluster. Retrying in #{sleep_interval}s")
44
- Stud.stoppable_sleep(sleep_interval) { @stopping.true? }
45
- sleep_interval = next_sleep_interval(sleep_interval)
46
- end
47
- if successful_connection?
48
- discover_cluster_uuid
49
- install_template
50
- setup_ilm if ilm_in_use?
51
- end
52
- end
53
- end
54
-
55
- def stop_template_installer
56
- @template_installer.join unless @template_installer.nil?
57
- end
58
-
59
- def successful_connection?
60
- !!maximum_seen_major_version
61
- end
62
-
63
- ##
64
- # WARNING: This method is overridden in a subclass in Logstash Core 7.7-7.8's monitoring,
65
- # where a `client` argument is both required and ignored. In later versions of
66
- # Logstash Core it is optional and ignored, but to make it optional here would
67
- # allow us to accidentally break compatibility with Logstashes where it was required.
68
- # @param noop_required_client [nil]: required `nil` for legacy reasons.
69
- # @return [Boolean]
70
- def use_event_type?(noop_required_client)
71
- maximum_seen_major_version < 8
72
- end
73
-
74
- # Convert the event into a 3-tuple of action, params, and event
75
- def event_action_tuple(event)
76
- action = event.sprintf(@action)
77
-
78
- params = {
79
- :_id => @document_id ? event.sprintf(@document_id) : nil,
80
- :_index => event.sprintf(@index),
81
- routing_field_name => @routing ? event.sprintf(@routing) : nil
82
- }
83
-
84
- params[:_type] = get_event_type(event) if use_event_type?(nil)
85
-
86
- if @pipeline
87
- value = event.sprintf(@pipeline)
88
- # convention: empty string equates to not using a pipeline
89
- # this is useful when using a field reference in the pipeline setting, e.g.
90
- # elasticsearch {
91
- # pipeline => "%{[@metadata][pipeline]}"
92
- # }
93
- params[:pipeline] = value unless value.empty?
94
- end
95
-
96
- if @parent
97
- if @join_field
98
- join_value = event.get(@join_field)
99
- parent_value = event.sprintf(@parent)
100
- event.set(@join_field, { "name" => join_value, "parent" => parent_value })
101
- params[routing_field_name] = event.sprintf(@parent)
102
- else
103
- params[:parent] = event.sprintf(@parent)
104
- end
105
- end
106
-
107
- if action == 'update'
108
- params[:_upsert] = LogStash::Json.load(event.sprintf(@upsert)) if @upsert != ""
109
- params[:_script] = event.sprintf(@script) if @script != ""
110
- params[retry_on_conflict_action_name] = @retry_on_conflict
111
- end
112
-
113
- if @version
114
- params[:version] = event.sprintf(@version)
115
- end
116
-
117
- if @version_type
118
- params[:version_type] = event.sprintf(@version_type)
119
- end
120
-
121
- [action, params, event]
34
+ @client ||= ::LogStash::Outputs::ElasticSearch::HttpClientBuilder.build(@logger, @hosts, params)
122
35
  end
123
36
 
124
37
  def validate_authentication
@@ -153,7 +66,7 @@ module LogStash; module Outputs; class ElasticSearch;
153
66
 
154
67
  def hosts_default?(hosts)
155
68
  # NOTE: would be nice if pipeline allowed us a clean way to detect a config default :
156
- hosts.is_a?(Array) && hosts.size == 1 && hosts.first.equal?(CommonConfigs::DEFAULT_HOST)
69
+ hosts.is_a?(Array) && hosts.size == 1 && hosts.first.equal?(LogStash::PluginMixins::ElasticSearch::APIConfigs::DEFAULT_HOST)
157
70
  end
158
71
  private :hosts_default?
159
72
 
@@ -206,17 +119,23 @@ module LogStash; module Outputs; class ElasticSearch;
206
119
  client.maximum_seen_major_version
207
120
  end
208
121
 
209
- def routing_field_name
210
- maximum_seen_major_version >= 6 ? :routing : :_routing
211
- end
212
-
213
- def retry_on_conflict_action_name
214
- maximum_seen_major_version >= 7 ? :retry_on_conflict : :_retry_on_conflict
122
+ def successful_connection?
123
+ !!maximum_seen_major_version
215
124
  end
216
125
 
217
- def install_template
218
- TemplateManager.install_template(self)
219
- @template_installed.make_true
126
+ # launch a thread that waits for an initial successful connection to the ES cluster to call the given block
127
+ # @param block [Proc] the block to execute upon initial successful connection
128
+ # @return [Thread] the successful connection wait thread
129
+ def setup_after_successful_connection(&block)
130
+ Thread.new do
131
+ sleep_interval = @retry_initial_interval
132
+ until successful_connection? || @stopping.true?
133
+ @logger.debug("Waiting for connectivity to Elasticsearch cluster. Retrying in #{sleep_interval}s")
134
+ Stud.stoppable_sleep(sleep_interval) { @stopping.true? }
135
+ sleep_interval = next_sleep_interval(sleep_interval)
136
+ end
137
+ block.call if successful_connection?
138
+ end
220
139
  end
221
140
 
222
141
  def discover_cluster_uuid
@@ -228,22 +147,6 @@ module LogStash; module Outputs; class ElasticSearch;
228
147
  # @logger.error("Unable to retrieve elasticsearch cluster uuid", error => e.message)
229
148
  end
230
149
 
231
- def check_action_validity
232
- raise LogStash::ConfigurationError, "No action specified!" unless @action
233
-
234
- # If we're using string interpolation, we're good!
235
- return if @action =~ /%{.+}/
236
- return if valid_actions.include?(@action)
237
-
238
- raise LogStash::ConfigurationError, "Action '#{@action}' is invalid! Pick one of #{valid_actions} or use a sprintf style statement"
239
- end
240
-
241
- # To be overidden by the -java version
242
- VALID_HTTP_ACTIONS=["index", "delete", "create", "update"]
243
- def valid_actions
244
- VALID_HTTP_ACTIONS
245
- end
246
-
247
150
  def retrying_submit(actions)
248
151
  # Initially we submit the full list of actions
249
152
  submit_actions = actions
@@ -352,32 +255,6 @@ module LogStash; module Outputs; class ElasticSearch;
352
255
  end
353
256
  end
354
257
 
355
- # Determine the correct value for the 'type' field for the given event
356
- DEFAULT_EVENT_TYPE_ES6="doc".freeze
357
- DEFAULT_EVENT_TYPE_ES7="_doc".freeze
358
- def get_event_type(event)
359
- # Set the 'type' value for the index.
360
- type = if @document_type
361
- event.sprintf(@document_type)
362
- else
363
- if maximum_seen_major_version < 6
364
- event.get("type") || DEFAULT_EVENT_TYPE_ES6
365
- elsif maximum_seen_major_version == 6
366
- DEFAULT_EVENT_TYPE_ES6
367
- elsif maximum_seen_major_version == 7
368
- DEFAULT_EVENT_TYPE_ES7
369
- else
370
- nil
371
- end
372
- end
373
-
374
- if !(type.is_a?(String) || type.is_a?(Numeric))
375
- @logger.warn("Bad event type! Non-string/integer type value set!", :type_class => type.class, :type_value => type.to_s, :event => event)
376
- end
377
-
378
- type.to_s
379
- end
380
-
381
258
  # Rescue retryable errors during bulk submission
382
259
  def safe_bulk(actions)
383
260
  sleep_interval = @retry_initial_interval
@@ -448,10 +325,6 @@ module LogStash; module Outputs; class ElasticSearch;
448
325
  end
449
326
  end
450
327
 
451
- def default_index?(index)
452
- @index == @default_index
453
- end
454
-
455
328
  def dlq_enabled?
456
329
  # TODO there should be a better way to query if DLQ is enabled
457
330
  # See more in: https://github.com/elastic/logstash/issues/8064
@@ -459,4 +332,4 @@ module LogStash; module Outputs; class ElasticSearch;
459
332
  !execution_context.dlq_writer.inner_writer.is_a?(::LogStash::Util::DummyDeadLetterQueueWriter)
460
333
  end
461
334
  end
462
- end end end
335
+ end; end; end
@@ -0,0 +1,9 @@
1
+ module LogStash; module PluginMixins; module ElasticSearch
2
+ class NoopLicenseChecker
3
+ INSTANCE = self.new
4
+
5
+ def appropriate_license?(pool, url)
6
+ true
7
+ end
8
+ end
9
+ end; end; end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-elasticsearch'
3
- s.version = '10.7.0'
3
+ s.version = '10.8.3'
4
4
 
5
5
  s.licenses = ['apache-2.0']
6
6
  s.summary = "Stores logs in Elasticsearch"
@@ -49,19 +49,10 @@ module ESHelper
49
49
  Time.now.strftime("%Y.%m.%d")
50
50
  end
51
51
 
52
-
53
- def default_mapping_from_mappings(mappings)
54
- if ESHelper.es_version_satisfies?(">=7")
55
- mappings
56
- else
57
- mappings["_default_"]
58
- end
59
- end
60
-
61
52
  def field_properties_from_template(template_name, field)
62
- mappings = @es.indices.get_template(name: template_name)[template_name]["mappings"]
63
- mapping = default_mapping_from_mappings(mappings)
64
- mapping["properties"][field]["properties"]
53
+ template = get_template(@es, template_name)
54
+ mappings = get_template_mappings(template)
55
+ mappings["properties"][field]["properties"]
65
56
  end
66
57
 
67
58
  def routing_field_name
@@ -105,6 +96,7 @@ module ESHelper
105
96
 
106
97
  def clean(client)
107
98
  client.indices.delete_template(:name => "*")
99
+ client.indices.delete_index_template(:name => "logstash*") rescue nil
108
100
  # This can fail if there are no indexes, ignore failure.
109
101
  client.indices.delete(:index => "*") rescue nil
110
102
  clean_ilm(client) if supports_ilm?(client)
@@ -182,6 +174,34 @@ module ESHelper
182
174
  }
183
175
  }
184
176
  end
177
+
178
+ def get_template(client, name)
179
+ if ESHelper.es_version_satisfies?(">=8")
180
+ t = client.indices.get_index_template(name: name)
181
+ t['index_templates'][0]['index_template']
182
+ else
183
+ t = client.indices.get_template(name: name)
184
+ t[name]
185
+ end
186
+ end
187
+
188
+ def get_template_settings(template)
189
+ if ESHelper.es_version_satisfies?(">=8")
190
+ template['template']['settings']
191
+ else
192
+ template['settings']
193
+ end
194
+ end
195
+
196
+ def get_template_mappings(template)
197
+ if ESHelper.es_version_satisfies?(">=8")
198
+ template['template']['mappings']
199
+ elsif ESHelper.es_version_satisfies?(">=7")
200
+ template['mappings']
201
+ else
202
+ template['mappings']["_default_"]
203
+ end
204
+ end
185
205
  end
186
206
 
187
207
  RSpec.configure do |config|
@@ -0,0 +1,50 @@
1
+ {
2
+ "index_patterns" : "overwrite-*",
3
+ "version" : 80001,
4
+ "template" : {
5
+ "settings" : {
6
+ "index.refresh_interval" : "1s",
7
+ "number_of_shards": 1
8
+ },
9
+ "mappings" : {
10
+ "dynamic_templates" : [ {
11
+ "message_field" : {
12
+ "path_match" : "message",
13
+ "match_mapping_type" : "string",
14
+ "mapping" : {
15
+ "type" : "text",
16
+ "norms" : false
17
+ }
18
+ }
19
+ }, {
20
+ "string_fields" : {
21
+ "match" : "*",
22
+ "match_mapping_type" : "string",
23
+ "mapping" : {
24
+ "type" : "text", "norms" : false,
25
+ "fields" : {
26
+ "keyword" : { "type": "keyword", "ignore_above": 256 }
27
+ }
28
+ }
29
+ }
30
+ } ],
31
+ "properties" : {
32
+ "@timestamp": { "type": "date" },
33
+ "@version": { "type": "keyword" },
34
+ "geoip" : {
35
+ "dynamic": true,
36
+ "properties" : {
37
+ "ip": { "type": "ip" },
38
+ "location" : { "type" : "geo_point" },
39
+ "latitude" : { "type" : "half_float" },
40
+ "longitude" : { "type" : "half_float" }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ },
46
+ "priority": 200,
47
+ "_meta" : {
48
+ "description": "index template for logstash-output-elasticsearch"
49
+ }
50
+ }
@@ -8,7 +8,7 @@ shared_examples_for 'an ILM enabled Logstash' do
8
8
  let (:settings) { super.merge("ilm_policy" => ilm_policy_name)}
9
9
 
10
10
  it 'should rollover when the policy max docs is reached' do
11
- put_policy(@es,ilm_policy_name, policy)
11
+ put_policy(@es, ilm_policy_name, policy)
12
12
  subject.register
13
13
 
14
14
  subject.multi_receive([
@@ -108,9 +108,11 @@ shared_examples_for 'an ILM disabled Logstash' do
108
108
  it 'should not write the ILM settings into the template' do
109
109
  subject.register
110
110
  sleep(1)
111
- expect(@es.indices.get_template(name: "logstash")["logstash"]).to have_index_pattern("logstash-*")
111
+
112
+ template = get_template(@es, "logstash")
113
+ expect(template).to have_index_pattern("logstash-*")
112
114
  if ESHelper.es_version_satisfies?(">= 2")
113
- expect(@es.indices.get_template(name: "logstash")["logstash"]["settings"]['index']['lifecycle']).to be_nil
115
+ expect(get_template_settings(template)['index']['lifecycle']).to be_nil
114
116
  end
115
117
  end
116
118
 
@@ -152,16 +154,17 @@ shared_examples_for 'an ILM disabled Logstash' do
152
154
  end
153
155
 
154
156
  context 'with a custom template name' do
155
- let (:template_name) { "custom_template_name" }
157
+ let (:template_name) { "logstash_custom_template_name" }
156
158
  let (:settings) { super.merge('template_name' => template_name)}
157
159
 
158
160
  it 'should not write the ILM settings into the template' do
159
161
  subject.register
160
162
  sleep(1)
161
163
 
162
- expect(@es.indices.get_template(name: template_name)[template_name]).to have_index_pattern("logstash-*")
164
+ template = get_template(@es, template_name)
165
+ expect(template).to have_index_pattern("logstash-*")
163
166
  if ESHelper.es_version_satisfies?(">= 2")
164
- expect(@es.indices.get_template(name: template_name)[template_name]["settings"]['index']['lifecycle']).to be_nil
167
+ expect(get_template_settings(template)['index']['lifecycle']).to be_nil
165
168
  end
166
169
  end
167
170
  end
@@ -387,16 +390,20 @@ if ESHelper.es_version_satisfies?(">= 6.6")
387
390
  it 'should write the ILM settings into the template' do
388
391
  subject.register
389
392
  sleep(1)
390
- expect(@es.indices.get_template(name: "logstash")["logstash"]).to have_index_pattern("logstash-*")
391
- expect(@es.indices.get_template(name: "logstash")["logstash"]["settings"]['index']['lifecycle']['name']).to eq("logstash-policy")
392
- expect(@es.indices.get_template(name: "logstash")["logstash"]["settings"]['index']['lifecycle']['rollover_alias']).to eq("logstash")
393
+
394
+ template = get_template(@es, "logstash")
395
+ expect(template).to have_index_pattern("logstash-*")
396
+ expect(get_template_settings(template)['index']['lifecycle']['name']).to eq("logstash-policy")
397
+ expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq("logstash")
393
398
  end
394
399
 
395
400
  it_behaves_like 'an ILM enabled Logstash'
396
401
  end
397
402
 
398
403
  context 'with a set index and a custom index pattern' do
399
- if ESHelper.es_version_satisfies?(">= 7.0")
404
+ if ESHelper.es_version_satisfies?(">= 8.0")
405
+ let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
406
+ elsif ESHelper.es_version_satisfies?(">= 7.0")
400
407
  let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
401
408
  else
402
409
  let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
@@ -408,13 +415,15 @@ if ESHelper.es_version_satisfies?(">= 6.6")
408
415
  it 'should not overwrite the index patterns' do
409
416
  subject.register
410
417
  sleep(1)
411
- expect(@es.indices.get_template(name: "logstash")["logstash"]).to have_index_pattern("overwrite-*")
418
+
419
+ template = get_template(@es, "logstash")
420
+ expect(template).to have_index_pattern("overwrite-*")
412
421
  end
413
422
  end
414
423
 
415
424
 
416
425
  context 'with a custom template' do
417
- let (:ilm_rollover_alias) { "the_cat_in_the_hat" }
426
+ let (:ilm_rollover_alias) { "logstash_the_cat_in_the_hat" }
418
427
  let (:index) { ilm_rollover_alias }
419
428
  let(:expected_index) { index }
420
429
  let (:settings) { super.merge("ilm_policy" => ilm_policy_name,
@@ -422,7 +431,9 @@ if ESHelper.es_version_satisfies?(">= 6.6")
422
431
  "ilm_rollover_alias" => ilm_rollover_alias)}
423
432
 
424
433
 
425
- if ESHelper.es_version_satisfies?(">= 7.0")
434
+ if ESHelper.es_version_satisfies?(">= 8.0")
435
+ let (:template) { "spec/fixtures/template-with-policy-es8x.json" }
436
+ elsif ESHelper.es_version_satisfies?(">= 7.0")
426
437
  let (:template) { "spec/fixtures/template-with-policy-es7x.json" }
427
438
  else
428
439
  let (:template) { "spec/fixtures/template-with-policy-es6x.json" }
@@ -460,13 +471,15 @@ if ESHelper.es_version_satisfies?(">= 6.6")
460
471
  it 'should write the ILM settings into the template' do
461
472
  subject.register
462
473
  sleep(1)
463
- expect(@es.indices.get_template(name: ilm_rollover_alias)[ilm_rollover_alias]).to have_index_pattern("#{ilm_rollover_alias}-*")
464
- expect(@es.indices.get_template(name: ilm_rollover_alias)[ilm_rollover_alias]["settings"]['index']['lifecycle']['name']).to eq(ilm_policy_name)
465
- expect(@es.indices.get_template(name: ilm_rollover_alias)[ilm_rollover_alias]["settings"]['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
474
+
475
+ template = get_template(@es, ilm_rollover_alias)
476
+ expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
477
+ expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
478
+ expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
466
479
  end
467
480
 
468
481
  context 'with a different template_name' do
469
- let (:template_name) { "custom_template_name" }
482
+ let (:template_name) { "logstash_custom_template_name" }
470
483
  let (:settings) { super.merge('template_name' => template_name)}
471
484
 
472
485
  it_behaves_like 'an ILM enabled Logstash'
@@ -474,9 +487,10 @@ if ESHelper.es_version_satisfies?(">= 6.6")
474
487
  it 'should write the ILM settings into the template' do
475
488
  subject.register
476
489
  sleep(1)
477
- expect(@es.indices.get_template(name: template_name)[template_name]).to have_index_pattern("#{ilm_rollover_alias}-*")
478
- expect(@es.indices.get_template(name: template_name)[template_name]["settings"]['index']['lifecycle']['name']).to eq(ilm_policy_name)
479
- expect(@es.indices.get_template(name: template_name)[template_name]["settings"]['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
490
+ template = get_template(@es, template_name)
491
+ expect(template).to have_index_pattern("#{ilm_rollover_alias}-*")
492
+ expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name)
493
+ expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias)
480
494
  end
481
495
  end
482
496