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
Install a Graylog index template instead of set mappings on index creation #1628
Conversation
…ation In commit edf0d8b we changed the index creation process from "create index" + "install index mapping" to one operation to avoid race conditions. This broke setups where users had installed custom Elasticsearch index templates because the user templates where applied after our mapping was installed into the index. Before edf0d8b the user templates have been applied before we installed our mapping because the index creation was split into two steps. We now install a "graylog-internal" index template into Elasticsearch with a "order" or -99 to make sure user templates are able to override our settings. Fixes #1624
- Pass the ES config object intot the IndexCreatingLoadStrategyFactory to make sure the index is created with the correct settings. - Adjust index name in all fixtures.
public boolean createIndexTemplate() { | ||
final Map<String, Object> template = indexMapping.messageTemplate(allIndicesAlias(), configuration.getAnalyzer()); | ||
final PutIndexTemplateRequest itr = c.admin().indices().preparePutTemplate(GRAYLOG_INTERNAL_TEMPLATE_NAME) | ||
.setOrder(-99) // Make sure templates with "order: 0" are applied after our template! |
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.
Why -99 and not -1 or Integer.MIN_VALUE
?
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.
I chose -99 because I didn't want to use -1 because we might need some space in the future. 😉
I will change it to Integer.MIN_VALUE
.
This is needed to ensure that the template is created under all circumstances. This still leaves a race condition where the template is not propagated throughout the cluster when a new index gets created. Not much we can do about this right now.
Updated after some discussions. |
LGTM. 👍 |
Install a Graylog index template instead of set mappings on index creation
Install a Graylog index template instead of set mappings on index creation (cherry picked from commit 14db43e)
Merged into |
In commit edf0d8b we changed the index creation process from "create index" + "install index mapping" to one operation to avoid race conditions.
This broke setups where users had installed custom Elasticsearch index templates because the user templates where applied after our mapping was installed into the index. Before edf0d8b the user templates have been applied before we installed our mapping because the index creation was split into two steps.
We now install a "graylog-internal" index template into Elasticsearch with a "order" or -99 to make sure user templates are able to override our settings.
Fixes #1624