Skip to content
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

Support legacy template api in elasticsearch 8 #1092

Merged

Conversation

kaisecheng
Copy link
Contributor

@kaisecheng kaisecheng commented Oct 5, 2022

Fixed: #1088

Prior to the change, the plugin uses legacy API for ES 7.x and forces to use index template API for ES 8.x. However, legacy template API is still available in ES 8 and user should be allowed to use it.

This commit adds a new flag template_api to control which API to use. The available value is auto, legacy and composable. The default value is auto.

  • auto Logstash detect the version of Elasticsearch. It uses index template API for 8 and legacy API for 7.
  • legacy use legacy API
  • composable use index template API

Copy link
Contributor

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks clean and sensible.

I'd like to take a small step back and discuss the interface that we are exposing to the user

Right now the interface of this centered on the old template api:

  • template_legacy => true: use the old thing
  • template_legacy => false: don't use the old thing
  • template_legacy => auto: use the old thing sometimes?

If we are stuck on a boolean-with-auto, I would prefer to either invert the setting to be centered on the new API, so that a user can tell us:

  • template_modern => true to use the new thing
  • template_modern => false to not use the new thing
  • template_modern => auto to assume which one to use

But even this introduces terminology like "modern" not found in Elasticsearch documentation, and I particularly don't like "boolean" options with 3+ choices.

Elasticsearch mainly describes V2 templates as just plain "Index templates" (often in direct opposition to "legacy templates"), but it also uses "composable" to refer to the v2 templates when describing how they interact with the legacy templates:

Composable templates take precedence over legacy templates. If no composable template matches a given index, a legacy template may still match and be applied.

Maybe template_format with options legacy, composable, and auto?

  • template_format => legacy: use the old thing
  • template_format => composable: use the new thing
  • template_format => auto: idk just do your best?

Or similarly template_api?

  • template_api => legacy: use the old thing
  • template_api => composable: use the new thing
  • template_api => auto: idk just do your best?

Separately, when the effective value is auto, and we are talking to an ES7, I think we should emit a deprecation notice informing the user that they should either "lock in" legacy templates in advance of upgrading any part of their stack, or that they should migrate to composable templates.

logstash-output-elasticsearch.gemspec Outdated Show resolved Hide resolved
spec/unit/outputs/elasticsearch/template_manager_spec.rb Outdated Show resolved Hide resolved
@mashhurs
Copy link
Contributor

mashhurs commented Oct 5, 2022

Implementation looks clean and sensible.

I'd like to take a small step back and discuss the interface that we are exposing to the user

Right now the interface of this centered on the old template api:

  • template_legacy => true: use the old thing
  • template_legacy => false: don't use the old thing
  • template_legacy => auto: use the old thing sometimes?

If we are stuck on a boolean-with-auto, I would prefer to either invert the setting to be centered on the new API, so that a user can tell us:

  • template_modern => true to use the new thing
  • template_modern => false to not use the new thing
  • template_modern => auto to assume which one to use

But even this introduces terminology like "modern" not found in Elasticsearch documentation, and I particularly don't like "boolean" options with 3+ choices.

Elasticsearch mainly describes V2 templates as just plain "Index templates" (often in direct opposition to "legacy templates"), but it also uses "composable" to refer to the v2 templates when describing how they interact with the legacy templates:

Composable templates take precedence over legacy templates. If no composable template matches a given index, a legacy template may still match and be applied.

Maybe template_format with options legacy, composable, and auto?

  • template_format => legacy: use the old thing
  • template_format => composable: use the new thing
  • template_format => auto: idk just do your best?

Or similarly template_api?

  • template_api => legacy: use the old thing
  • template_api => composable: use the new thing
  • template_api => auto: idk just do your best?

Separately, when the effective value is auto, and we are talking to an ES7, I think we should emit a deprecation notice informing the user that they should either "lock in" legacy templates in advance of upgrading any part of their stack, or that they should migrate to composable templates.

template_api looks good for me. And one thing I would like to propose is attaching index prefix to the naming (becomes index_template_api). The actual change of why ES deprecated _template is, new component templates are introduced. Let's make sure in the future we will have a window if something comes up for component templates.

@kaisecheng
Copy link
Contributor Author

template_api with value legacy, composable and auto is my favorite. The keywords align with Elasticsearch, which is very important. Thanks for the suggestion @yaauie

@mashhurs The reason I avoid adding index prefix is to align the name with others template, template_name, template_overwirte and manage_template. They are all meant to manage the index template. Thanks for your input.

@kaisecheng kaisecheng requested a review from yaauie October 6, 2022 11:17
@kaisecheng kaisecheng removed the request for review from yaauie October 6, 2022 13:16
@kaisecheng kaisecheng force-pushed the support_legacy_template_ES8 branch from 45ed6ab to bbd58ee Compare October 6, 2022 17:33
@kaisecheng kaisecheng requested a review from yaauie October 6, 2022 17:52
Copy link
Contributor

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks great. I have a couple of suggestions on wording for both the log warning and the docs page.

lib/logstash/outputs/elasticsearch/template_manager.rb Outdated Show resolved Hide resolved
docs/index.asciidoc Outdated Show resolved Hide resolved
kaisecheng and others added 3 commits October 11, 2022 22:36
Co-authored-by: Ry Biesemeyer <[email protected]>
…asticsearch into support_legacy_template_ES8

# Conflicts:
#	CHANGELOG.md
#	logstash-output-elasticsearch.gemspec
Copy link
Contributor

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐙LGTM

@kaisecheng kaisecheng merged commit 7c24cfa into logstash-plugins:main Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request of using legacy template API in Elasticsearch 8.x
4 participants