From 4e105e8684324d7d64c31918ad0bd23eae14aacc Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Tue, 2 Sep 2025 14:02:15 -0400 Subject: [PATCH] Adding _meta.template_version to kibana reporting mappings (#133846) Part of https://github.com/elastic/kibana/issues/231200 . We realized that when the mappings are updated in a version upgrade, the mappings are in fact updated, but not applied to the current reporting datastream. To fix this, we'll make a determination in Kibana that we should roll over the data stream if the version in the template does not match the version in the mappings of the datastream. If they match, we don't need to do anything. If they don't match, or the version of the mappings is not in the datastream (from before this PR), we will need to roll over the data stream to apply the new mappings. To make this happen, we need to add a new field to the mapping `_meta`, which should match the template version. references: - https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field Co-authored-by: Elastic Machine (cherry picked from commit ebb94bd523b8081bb52b5fce1b38f4dc3dfe0afb) # Conflicts: # x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java --- .../src/main/resources/kibana-reporting@template.json | 3 +++ .../org/elasticsearch/xpack/stack/StackTemplateRegistry.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/core/template-resources/src/main/resources/kibana-reporting@template.json b/x-pack/plugin/core/template-resources/src/main/resources/kibana-reporting@template.json index 109979208c496..74256872aa0cf 100644 --- a/x-pack/plugin/core/template-resources/src/main/resources/kibana-reporting@template.json +++ b/x-pack/plugin/core/template-resources/src/main/resources/kibana-reporting@template.json @@ -10,6 +10,9 @@ "template": { "lifecycle": {}, "mappings": { + "_meta": { + "template_version": ${xpack.stack.template.version} + }, "properties": { "meta": { "properties": { diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java index a2f8dd91176e2..384c06ec0850d 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java @@ -37,7 +37,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry { // The stack template registry version. This number must be incremented when we make changes // to built-in templates. - public static final int REGISTRY_VERSION = 16; + public static final int REGISTRY_VERSION = 18; public static final String TEMPLATE_VERSION_VARIABLE = "xpack.stack.template.version"; public static final Setting STACK_TEMPLATES_ENABLED = Setting.boolSetting(