Skip to content

Commit 6038383

Browse files
committed
use resolved template_api when injecting ILM
1 parent d341294 commit 6038383

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/logstash/outputs/elasticsearch/template_manager.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.install(client, template_endpoint, template_name, template, template_ov
4444
def self.add_ilm_settings_to_template(plugin, template)
4545
# Overwrite any index patterns, and use the rollover alias. Use 'index_patterns' rather than 'template' for pattern
4646
# definition - remove any existing definition of 'template'
47-
template.delete('template') if template.include?('template') if plugin.maximum_seen_major_version < 8
47+
template.delete('template') if template_endpoint(plugin) == LEGACY_TEMPLATE_ENDPOINT
4848
template['index_patterns'] = "#{plugin.ilm_rollover_alias}-*"
4949
settings = template_settings(plugin, template)
5050
if settings && (settings['index.lifecycle.name'] || settings['index.lifecycle.rollover_alias'])
@@ -54,7 +54,12 @@ def self.add_ilm_settings_to_template(plugin, template)
5454
end
5555

5656
def self.template_settings(plugin, template)
57-
plugin.maximum_seen_major_version < 8 ? template['settings']: template['template']['settings']
57+
if template_endpoint(plugin) == LEGACY_TEMPLATE_ENDPOINT
58+
return template['settings'] ||= {}
59+
end
60+
61+
template['template'] ||= {}
62+
template['template']['settings'] ||= {}
5863
end
5964

6065
# Template name - if template_name set, use it

0 commit comments

Comments
 (0)