-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ILM injection vs template_api setting #1115
base: main
Are you sure you want to change the base?
Changes from all commits
6038383
1bb2161
37ab2af
0db4015
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,6 +279,8 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base | |
def initialize(*params) | ||
super | ||
setup_ecs_compatibility_related_defaults | ||
|
||
raise LogStash::ConfigurationError("`template_api` is not allowed unless a `template` is also provided") if original_params.include?('template_api') && !original_params.include?('template') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very very small breaking risk. The intent of |
||
end | ||
|
||
def register | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,15 +7,15 @@ class TemplateManager | |||||
def self.install_template(plugin) | ||||||
return unless plugin.manage_template | ||||||
|
||||||
if plugin.maximum_seen_major_version < 8 && plugin.template_api == 'auto' | ||||||
plugin.logger.warn("`template_api => auto` resolved to `legacy` since we are connected to " + "Elasticsearch #{plugin.maximum_seen_major_version}, " + | ||||||
"but will resolve to `composable` the first time it connects to Elasticsearch 8+. " + | ||||||
"We recommend either setting `template_api => legacy` to continue providing legacy-style templates, " + | ||||||
"or migrating your template to the composable style and setting `template_api => composable`. " + | ||||||
"The legacy template API is slated for removal in Elasticsearch 9.") | ||||||
end | ||||||
|
||||||
if plugin.template | ||||||
if plugin.maximum_seen_major_version < 8 && plugin.template_api == 'auto' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review note: since |
||||||
plugin.logger.warn("`template_api => auto` resolved to `legacy` since we are connected to " + "Elasticsearch #{plugin.maximum_seen_major_version}, " + | ||||||
"but will resolve to `composable` the first time it connects to Elasticsearch 8+. " + | ||||||
"We recommend either setting `template_api => legacy` to continue providing legacy-style templates, " + | ||||||
"or migrating your template to the composable style and setting `template_api => composable`. " + | ||||||
"The legacy template API is slated for removal in Elasticsearch 9.") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that |
||||||
end | ||||||
|
||||||
plugin.logger.info("Using mapping template from", :path => plugin.template) | ||||||
template = read_template_file(plugin.template) | ||||||
else | ||||||
|
@@ -42,19 +42,29 @@ def self.install(client, template_endpoint, template_name, template, template_ov | |||||
end | ||||||
|
||||||
def self.add_ilm_settings_to_template(plugin, template) | ||||||
if plugin.template | ||||||
plugin.deprecation_logger.deprecated("Injecting Index Lifecycle Management configuration into a provided `template` is deprecated, and support will be removed in a future version. Please add the configuration directly to your template.") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree with most of changes but this message brings one concern to me. We are asking user to I was thinking following two options, they may be applied together but choosing one would simplify:
Suggested change
In my opinion, option-2 looks better approach. |
||||||
end | ||||||
# Overwrite any index patterns, and use the rollover alias. Use 'index_patterns' rather than 'template' for pattern | ||||||
# definition - remove any existing definition of 'template' | ||||||
template.delete('template') if template.include?('template') if plugin.maximum_seen_major_version < 8 | ||||||
template.delete('template') if template_endpoint(plugin) == LEGACY_TEMPLATE_ENDPOINT | ||||||
template['index_patterns'] = "#{plugin.ilm_rollover_alias}-*" | ||||||
settings = template_settings(plugin, template) | ||||||
if settings && (settings['index.lifecycle.name'] || settings['index.lifecycle.rollover_alias']) | ||||||
plugin.logger.info("Overwriting index lifecycle name and rollover alias as ILM is enabled") | ||||||
end | ||||||
settings.update({ 'index.lifecycle.name' => plugin.ilm_policy, 'index.lifecycle.rollover_alias' => plugin.ilm_rollover_alias}) | ||||||
rescue Exception => e | ||||||
fail("Failed to apply ILM settings to template: #{e.message}") | ||||||
end | ||||||
|
||||||
def self.template_settings(plugin, template) | ||||||
plugin.maximum_seen_major_version < 8 ? template['settings']: template['template']['settings'] | ||||||
if template_endpoint(plugin) == LEGACY_TEMPLATE_ENDPOINT | ||||||
return template['settings'] ||= {} | ||||||
end | ||||||
|
||||||
template['template'] ||= {} | ||||||
template['template']['settings'] ||= {} | ||||||
end | ||||||
|
||||||
# Template name - if template_name set, use it | ||||||
|
@@ -77,12 +87,11 @@ def self.read_template_file(template_path) | |||||
end | ||||||
|
||||||
def self.template_endpoint(plugin) | ||||||
if plugin.template_api == 'auto' | ||||||
plugin.maximum_seen_major_version < 8 ? LEGACY_TEMPLATE_ENDPOINT : INDEX_TEMPLATE_ENDPOINT | ||||||
elsif plugin.template_api.to_s == 'legacy' | ||||||
LEGACY_TEMPLATE_ENDPOINT | ||||||
case plugin.template_api.to_s | ||||||
when 'composable' then INDEX_TEMPLATE_ENDPOINT | ||||||
when 'legacy' then LEGACY_TEMPLATE_ENDPOINT | ||||||
else | ||||||
INDEX_TEMPLATE_ENDPOINT | ||||||
plugin.maximum_seen_major_version < 8 ? LEGACY_TEMPLATE_ENDPOINT : INDEX_TEMPLATE_ENDPOINT | ||||||
end | ||||||
end | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review note: I intentionally don't list
auto
here, because it is not particularly meaningful since it is already the default. Instead, I reveal that the default behavior is the same as eithercomposable
orlegacy
depending on which version of Elasticsearch we are connected to.