Skip to content

Commit d4aa1e6

Browse files
authored
Rename deprecation index template (#125606)
The dataset name for the deprecation logs index was previously renamed from `deprecation.elasticsearch` to `elasticsearch.deprecation` in order to follow the pattern of `product.group`. The deprecation index template, however, was not updated. This causes indexing errors once upgraded to 9.0 due to the dataset name having changed on a constant_keyword field. In order to avoid that mismatch, this commit renames the deprecation indexing datastream to match the dataset name. The old template is kept in place, but marked as deprecated, so that any deprecation logs written during upgrading to 9.x will continue to be indexed into the old datastream. closes #125445
1 parent 24734e6 commit d4aa1e6

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

docs/changelog/125606.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pr: 125606
2+
summary: Rename deprecation index template
3+
area: Infra/Logging
4+
type: breaking
5+
issues:
6+
- 125445
7+
breaking:
8+
title: Rename deprecation index template
9+
area: Logging
10+
details: The deprecation datastream contains log entries for deprecations that
11+
occured while Elasticsearch is running. The deprecation log entries had a
12+
mismatch in their dataset name. In order to avoid changing the dataset
13+
name in the existing datastream, a new datastream now exists.
14+
impact: If querying for deprecations previously using the
15+
`.logs-deprecation.elasticsearch-default` datastream, you should now use the
16+
`.logs-elasticsearch.deprecation-default` datastream.
17+
notable: false

x-pack/plugin/core/template-resources/src/main/resources/deprecation/deprecation-indexing-template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"index_patterns": [".logs-deprecation.*"],
2+
"index_patterns": ["${xpack.deprecation.indexing.template.pattern}"],
33
"priority": 1000,
44
"data_stream": {
55
"hidden": true
@@ -13,5 +13,6 @@
1313
"description": "default template for Stack deprecation logs index template installed by x-pack",
1414
"managed": true
1515
},
16+
"deprecated": ${xpack.deprecation.indexing.template.deprecated},
1617
"version": ${xpack.deprecation.indexing.template.version}
1718
}

x-pack/plugin/deprecation/qa/common/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class DeprecationTestUtils {
2323
/**
2424
* Same as <code>DeprecationIndexingAppender#DEPRECATION_MESSAGES_DATA_STREAM</code>, but that class isn't visible from here.
2525
*/
26-
public static final String DATA_STREAM_NAME = ".logs-deprecation.elasticsearch-default";
26+
public static final String DATA_STREAM_NAME = ".logs-elasticsearch.deprecation-default";
2727

2828
static List<Map<String, Object>> getIndexedDeprecations(RestClient client) throws IOException {
2929
return getIndexedDeprecations(client, null);

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingAppender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@Plugin(name = "DeprecationIndexingAppender", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE)
3333
public class DeprecationIndexingAppender extends AbstractAppender {
3434
private static final Logger logger = LogManager.getLogger(DeprecationIndexingAppender.class);
35-
public static final String DEPRECATION_MESSAGES_DATA_STREAM = ".logs-deprecation.elasticsearch-default";
35+
public static final String DEPRECATION_MESSAGES_DATA_STREAM = ".logs-elasticsearch.deprecation-default";
3636

3737
private final Consumer<IndexRequest> requestConsumer;
3838

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void clusterChanged(ClusterChangedEvent event) {
137137
}
138138
final IndexLifecycleMetadata indexLifecycleMetadata = event.state().metadata().getProject().custom(IndexLifecycleMetadata.TYPE);
139139

140-
if (event.state().getMetadata().getProject().templatesV2().containsKey(".deprecation-indexing-template")
140+
if (event.state().getMetadata().getProject().templatesV2().containsKey(".deprecation-indexing-template-9")
141141
&& indexLifecycleMetadata != null
142142
&& indexLifecycleMetadata.getPolicies().containsKey(".deprecation-indexing-ilm-policy")) {
143143
flushEnabled.set(true);

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingTemplateRegistry.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@
3333
public class DeprecationIndexingTemplateRegistry extends IndexTemplateRegistry {
3434
// history (please add a comment why you increased the version here)
3535
// version 1: initial
36-
public static final int INDEX_TEMPLATE_VERSION = 1;
36+
// version 2: deprecated old name and renamed index pattern
37+
public static final int INDEX_TEMPLATE_VERSION = 2;
3738

3839
public static final String DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE = "xpack.deprecation.indexing.template.version";
3940

4041
public static final String DEPRECATION_INDEXING_MAPPINGS_NAME = ".deprecation-indexing-mappings";
4142
public static final String DEPRECATION_INDEXING_SETTINGS_NAME = ".deprecation-indexing-settings";
42-
public static final String DEPRECATION_INDEXING_TEMPLATE_NAME = ".deprecation-indexing-template";
43+
public static final String DEPRECATION_INDEXING_TEMPLATE_NAME_OLD = ".deprecation-indexing-template";
44+
public static final String DEPRECATION_INDEXING_TEMPLATE_NAME = ".deprecation-indexing-template-9";
4345
public static final String DEPRECATION_INDEXING_POLICY_NAME = ".deprecation-indexing-ilm-policy";
4446

4547
public DeprecationIndexingTemplateRegistry(
@@ -89,7 +91,25 @@ protected Map<String, ComponentTemplate> getComponentTemplateConfigs() {
8991
DEPRECATION_INDEXING_TEMPLATE_NAME,
9092
"/deprecation/deprecation-indexing-template.json",
9193
INDEX_TEMPLATE_VERSION,
92-
DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE
94+
DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE,
95+
Map.of(
96+
"xpack.deprecation.indexing.template.deprecated",
97+
"false",
98+
"xpack.deprecation.indexing.template.pattern",
99+
".logs-elasticsearch.deprecation-*"
100+
)
101+
),
102+
new IndexTemplateConfig(
103+
DEPRECATION_INDEXING_TEMPLATE_NAME_OLD,
104+
"/deprecation/deprecation-indexing-template.json",
105+
INDEX_TEMPLATE_VERSION,
106+
DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE,
107+
Map.of(
108+
"xpack.deprecation.indexing.template.deprecated",
109+
"true",
110+
"xpack.deprecation.indexing.template.pattern",
111+
".logs-deprecation.*"
112+
)
93113
)
94114
);
95115

0 commit comments

Comments
 (0)