Skip to content

Commit 3348eaa

Browse files
kibanamachineElenaStoevaelasticmachine
authored
[8.19] [Data Streams] Fix displayed index mode (#215683) (#221182)
# Backport This will backport the following commits from `main` to `8.19`: - [[Data Streams] Fix displayed index mode (#215683)](#215683) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Elena Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-16T13:09:33Z","message":"[Data Streams] Fix displayed index mode (#215683)\n\nFixes https://github.com/elastic/kibana/issues/208671\n\n## Summary\n\nBefore this PR, the displayed index mode of the data streams was\ndetermined based on the index mode of the associated index template.\nHowever, the index mode can also be set through the component template,\nso that logic is not reliable and can cause incorrectly displayed index\nmode like described in https://github.com/elastic/kibana/issues/208671.\n\nIn this PR, we replace this logic with the recently added `index_mode`\nfield to the Es Get Data Streams API (see\nhttps://github.com/elastic/elasticsearch/pull/122486).\n\n**How to test:**\n1. Create a component template with a LogsDB index mode (you can also\ntest with other index modes):\n```\nPUT _component_template/my-component-template\n{\n \"template\": {\n \"settings\": {\n \"index\": {\n \"mode\": \"logsdb\"\n }\n }\n }\n}\n```\n2. Create an index template that is composed of the component template\nabove:\n```\nPUT _index_template/my-index-template\n{\n \"index_patterns\": [\n \"my-ds-*\"\n ],\n \"data_stream\": {},\n \"composed_of\": [\n \"my-component-template\"\n ]\n}\n```\n3. Create a data stream that matched the index pattern from the index\ntemplate above:\n```\nPUT _data_stream/my-ds-1\n```\n4. Go to the data streams table and verify that the index mode is\ndisplayed correctly in the table.\n\n<img width=\"1165\" alt=\"Screenshot 2025-03-24 at 18 12 04\"\nsrc=\"https://github.com/user-attachments/assets/ea211c14-3d03-49c7-ace7-88b15e294d1f\"\n/>\n\n\n5. Click on the created data stream and verify that the displayed index\nmode in the details panel is correct:\n\n<img width=\"1165\" alt=\"Screenshot 2025-03-06 at 14 36 12\"\nsrc=\"https://github.com/user-attachments/assets/954864e2-ae2a-4cb8-9eef-2c5f8b417f52\"\n/>\n\n---------\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"dec6a17ec02ffea5669ffcf8431009aef1e99cfa","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index Management","Team:Kibana Management","release_note:skip","backport:version","v9.1.0","v8.19.0"],"title":"[Data Streams] Fix displayed index mode","number":215683,"url":"https://github.com/elastic/kibana/pull/215683","mergeCommit":{"message":"[Data Streams] Fix displayed index mode (#215683)\n\nFixes https://github.com/elastic/kibana/issues/208671\n\n## Summary\n\nBefore this PR, the displayed index mode of the data streams was\ndetermined based on the index mode of the associated index template.\nHowever, the index mode can also be set through the component template,\nso that logic is not reliable and can cause incorrectly displayed index\nmode like described in https://github.com/elastic/kibana/issues/208671.\n\nIn this PR, we replace this logic with the recently added `index_mode`\nfield to the Es Get Data Streams API (see\nhttps://github.com/elastic/elasticsearch/pull/122486).\n\n**How to test:**\n1. Create a component template with a LogsDB index mode (you can also\ntest with other index modes):\n```\nPUT _component_template/my-component-template\n{\n \"template\": {\n \"settings\": {\n \"index\": {\n \"mode\": \"logsdb\"\n }\n }\n }\n}\n```\n2. Create an index template that is composed of the component template\nabove:\n```\nPUT _index_template/my-index-template\n{\n \"index_patterns\": [\n \"my-ds-*\"\n ],\n \"data_stream\": {},\n \"composed_of\": [\n \"my-component-template\"\n ]\n}\n```\n3. Create a data stream that matched the index pattern from the index\ntemplate above:\n```\nPUT _data_stream/my-ds-1\n```\n4. Go to the data streams table and verify that the index mode is\ndisplayed correctly in the table.\n\n<img width=\"1165\" alt=\"Screenshot 2025-03-24 at 18 12 04\"\nsrc=\"https://github.com/user-attachments/assets/ea211c14-3d03-49c7-ace7-88b15e294d1f\"\n/>\n\n\n5. Click on the created data stream and verify that the displayed index\nmode in the details panel is correct:\n\n<img width=\"1165\" alt=\"Screenshot 2025-03-06 at 14 36 12\"\nsrc=\"https://github.com/user-attachments/assets/954864e2-ae2a-4cb8-9eef-2c5f8b417f52\"\n/>\n\n---------\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"dec6a17ec02ffea5669ffcf8431009aef1e99cfa"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215683","number":215683,"mergeCommit":{"message":"[Data Streams] Fix displayed index mode (#215683)\n\nFixes https://github.com/elastic/kibana/issues/208671\n\n## Summary\n\nBefore this PR, the displayed index mode of the data streams was\ndetermined based on the index mode of the associated index template.\nHowever, the index mode can also be set through the component template,\nso that logic is not reliable and can cause incorrectly displayed index\nmode like described in https://github.com/elastic/kibana/issues/208671.\n\nIn this PR, we replace this logic with the recently added `index_mode`\nfield to the Es Get Data Streams API (see\nhttps://github.com/elastic/elasticsearch/pull/122486).\n\n**How to test:**\n1. Create a component template with a LogsDB index mode (you can also\ntest with other index modes):\n```\nPUT _component_template/my-component-template\n{\n \"template\": {\n \"settings\": {\n \"index\": {\n \"mode\": \"logsdb\"\n }\n }\n }\n}\n```\n2. Create an index template that is composed of the component template\nabove:\n```\nPUT _index_template/my-index-template\n{\n \"index_patterns\": [\n \"my-ds-*\"\n ],\n \"data_stream\": {},\n \"composed_of\": [\n \"my-component-template\"\n ]\n}\n```\n3. Create a data stream that matched the index pattern from the index\ntemplate above:\n```\nPUT _data_stream/my-ds-1\n```\n4. Go to the data streams table and verify that the index mode is\ndisplayed correctly in the table.\n\n<img width=\"1165\" alt=\"Screenshot 2025-03-24 at 18 12 04\"\nsrc=\"https://github.com/user-attachments/assets/ea211c14-3d03-49c7-ace7-88b15e294d1f\"\n/>\n\n\n5. Click on the created data stream and verify that the displayed index\nmode in the details panel is correct:\n\n<img width=\"1165\" alt=\"Screenshot 2025-03-06 at 14 36 12\"\nsrc=\"https://github.com/user-attachments/assets/954864e2-ae2a-4cb8-9eef-2c5f8b417f52\"\n/>\n\n---------\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"dec6a17ec02ffea5669ffcf8431009aef1e99cfa"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Elena Stoeva <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 0123be6 commit 3348eaa

File tree

3 files changed

+18
-34
lines changed

3 files changed

+18
-34
lines changed

x-pack/platform/plugins/shared/index_management/server/routes/api/data_streams/register_get_route.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { IScopedClusterClient } from '@kbn/core/server';
1111
import {
1212
IndicesDataStream,
1313
IndicesDataStreamsStatsDataStreamsStatsItem,
14-
IndicesGetIndexTemplateIndexTemplateItem,
1514
SecurityHasPrivilegesResponse,
1615
} from '@elastic/elasticsearch/lib/api/types';
1716
import type { MeteringStats } from '../../../lib/types';
@@ -32,14 +31,12 @@ const enhanceDataStreams = ({
3231
meteringStats,
3332
dataStreamsPrivileges,
3433
globalMaxRetention,
35-
indexTemplates,
3634
}: {
3735
dataStreams: IndicesDataStream[];
3836
dataStreamsStats?: IndicesDataStreamsStatsDataStreamsStatsItem[];
3937
meteringStats?: MeteringStats[];
4038
dataStreamsPrivileges?: SecurityHasPrivilegesResponse;
4139
globalMaxRetention?: string;
42-
indexTemplates?: IndicesGetIndexTemplateIndexTemplateItem[];
4340
}): EnhancedDataStreamFromEs[] => {
4441
return dataStreams.map((dataStream) => {
4542
const enhancedDataStream: EnhancedDataStreamFromEs = {
@@ -74,16 +71,6 @@ const enhanceDataStreams = ({
7471
}
7572
}
7673

77-
if (indexTemplates) {
78-
const indexTemplate = indexTemplates.find(
79-
(template) => template.name === dataStream.template
80-
);
81-
if (indexTemplate) {
82-
enhancedDataStream.index_mode =
83-
indexTemplate.index_template?.template?.settings?.index?.mode;
84-
}
85-
}
86-
8774
return enhancedDataStream;
8875
});
8976
};
@@ -174,9 +161,6 @@ export function registerGetAllRoute({ router, lib: { handleEsError }, config }:
174161
);
175162
}
176163

177-
const { index_templates: indexTemplates } =
178-
await client.asCurrentUser.indices.getIndexTemplate();
179-
180164
const { persistent, defaults } = await client.asInternalUser.cluster.getSettings({
181165
include_defaults: true,
182166
});
@@ -194,7 +178,6 @@ export function registerGetAllRoute({ router, lib: { handleEsError }, config }:
194178
meteringStats,
195179
dataStreamsPrivileges,
196180
globalMaxRetention,
197-
indexTemplates,
198181
});
199182

200183
return response.ok({
@@ -245,30 +228,17 @@ export function registerGetOneRoute({ router, lib: { handleEsError }, config }:
245228

246229
if (dataStreams[0]) {
247230
let dataStreamsPrivileges;
248-
let indexTemplates;
249231

250232
if (config.isSecurityEnabled()) {
251233
dataStreamsPrivileges = await getDataStreamsPrivileges(client, [dataStreams[0].name]);
252234
}
253235

254-
if (dataStreams[0].template) {
255-
const { index_templates: templates } =
256-
await client.asCurrentUser.indices.getIndexTemplate({
257-
name: dataStreams[0].template,
258-
});
259-
260-
if (templates) {
261-
indexTemplates = templates;
262-
}
263-
}
264-
265236
const enhancedDataStreams = enhanceDataStreams({
266237
dataStreams,
267238
dataStreamsStats,
268239
meteringStats,
269240
dataStreamsPrivileges,
270241
globalMaxRetention,
271-
indexTemplates,
272242
});
273243

274244
const { persistent, defaults } = await client.asInternalUser.cluster.getSettings({

x-pack/test/functional/apps/index_management/data_streams_tab/data_streams_tab.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
287287
expect(await testSubjects.getVisibleText('indexModeValue')).to.be(indexModeName);
288288
await testSubjects.click('closeDetailsButton');
289289

290+
// Perform rollover so that index mode of data stream is updated
291+
await es.indices.rollover({
292+
alias: TEST_DS_NAME,
293+
});
294+
290295
// Navigate to the data streams tab
291296
await pageObjects.indexManagement.changeTabs('data_streamsTab');
292297
await pageObjects.header.waitUntilLoadingHasFinished();
@@ -342,7 +347,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
342347
await verifyModeHasBeenChanged(INDEX_MODE.STANDARD);
343348
});
344349

345-
it('allows to upgrade data stream from time series to logsdb index mode', async () => {
350+
// Fails because of https://github.com/elastic/elasticsearch/issues/126473
351+
it.skip('allows to upgrade data stream from time series to logsdb index mode', async () => {
346352
await setIndexModeTemplate({
347353
mode: 'time_series',
348354
routing_path: 'test',
@@ -364,7 +370,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
364370
await verifyModeHasBeenChanged(INDEX_MODE.LOGSDB);
365371
});
366372

367-
it('allows to downgrade data stream from logsdb to time series index mode', async () => {
373+
// Fails because of https://github.com/elastic/elasticsearch/issues/126473
374+
it.skip('allows to downgrade data stream from logsdb to time series index mode', async () => {
368375
await setIndexModeTemplate({
369376
mode: 'logsdb',
370377
});

x-pack/test_serverless/functional/test_suites/common/management/index_management/data_streams.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
204204
expect(await testSubjects.getVisibleText('indexModeValue')).to.be(indexModeName);
205205
await testSubjects.click('closeDetailsButton');
206206

207+
// Perform rollover so that index mode of data stream is updated
208+
await es.indices.rollover({
209+
alias: TEST_DS_NAME_INDEX_MODE,
210+
});
211+
207212
// Navigate to the data streams tab
208213
await pageObjects.indexManagement.changeTabs('data_streamsTab');
209214
await pageObjects.header.waitUntilLoadingHasFinished();
@@ -266,7 +271,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
266271
await verifyModeHasBeenChanged(INDEX_MODE.STANDARD);
267272
});
268273

269-
it('allows to upgrade data stream from time series to logsdb index mode', async () => {
274+
// Fails because of https://github.com/elastic/elasticsearch/issues/126473
275+
it.skip('allows to upgrade data stream from time series to logsdb index mode', async () => {
270276
await setIndexModeTemplate({
271277
mode: 'time_series',
272278
routing_path: 'test',
@@ -287,7 +293,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
287293
await verifyModeHasBeenChanged(INDEX_MODE.LOGSDB);
288294
});
289295

290-
it('allows to downgrade data stream from logsdb to time series index mode', async () => {
296+
// Fails because of https://github.com/elastic/elasticsearch/issues/126473
297+
it.skip('allows to downgrade data stream from logsdb to time series index mode', async () => {
291298
await setIndexModeTemplate({
292299
mode: 'logsdb',
293300
});

0 commit comments

Comments
 (0)