Skip to content

Commit d963514

Browse files
kapral18claude
andcommitted
[Index Management] Report the index mode Elasticsearch returns for data streams
deserializeDataStream only let logsdb and standard through and mapped every other index_mode (time_series, lookup, vectordb_document) to standard, so the data streams list and details flyout showed Standard for time series data streams. Pass through any known IndexMode value and keep the logs-* inference only for undefined or unknown values. Unskip the Scout downgrade-to-time-series test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent c1f8fbe commit d963514

3 files changed

Lines changed: 61 additions & 11 deletions

File tree

x-pack/platform/plugins/shared/index_management/server/lib/data_stream_serialization.test.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
import type { EnhancedDataStreamFromEs } from '../../common';
99
import { deserializeDataStream } from './data_stream_serialization';
10-
import { LOGSDB_INDEX_MODE, STANDARD_INDEX_MODE } from '../../common/constants';
10+
import {
11+
LOGSDB_INDEX_MODE,
12+
LOOKUP_INDEX_MODE,
13+
STANDARD_INDEX_MODE,
14+
TIME_SERIES_MODE,
15+
VECTOR_DB_INDEX_MODE,
16+
} from '../../common/constants';
1117

1218
describe('deserializeDataStream', () => {
1319
const mockDataStreamFromEs: EnhancedDataStreamFromEs = {
@@ -353,6 +359,44 @@ describe('deserializeDataStream', () => {
353359
expect(result.indexMode).toBe('logsdb');
354360
});
355361

362+
it.each([TIME_SERIES_MODE, LOOKUP_INDEX_MODE, VECTOR_DB_INDEX_MODE])(
363+
'should use provided %s index mode instead of falling back to standard',
364+
(indexMode) => {
365+
const dataStream = {
366+
...mockDataStreamFromEs,
367+
index_mode: indexMode,
368+
} as EnhancedDataStreamFromEs;
369+
370+
const result = deserializeDataStream(dataStream, false);
371+
372+
expect(result.indexMode).toBe(indexMode);
373+
}
374+
);
375+
376+
it('should keep provided time_series index mode when logsdb is enabled and name matches logs pattern', () => {
377+
const dataStream: EnhancedDataStreamFromEs = {
378+
...mockDataStreamFromEs,
379+
name: 'logs-nginx-production',
380+
index_mode: TIME_SERIES_MODE,
381+
};
382+
383+
const result = deserializeDataStream(dataStream, true);
384+
385+
expect(result.indexMode).toBe(TIME_SERIES_MODE);
386+
});
387+
388+
it('should default to standard mode when the provided index mode is unknown', () => {
389+
const unknownIndexMode: string = 'unknown_mode';
390+
const dataStream = {
391+
...mockDataStreamFromEs,
392+
index_mode: unknownIndexMode,
393+
} as EnhancedDataStreamFromEs;
394+
395+
const result = deserializeDataStream(dataStream, false);
396+
397+
expect(result.indexMode).toBe(STANDARD_INDEX_MODE);
398+
});
399+
356400
it('should default to logsdb mode for logs pattern when logsdb is enabled and no index mode provided', () => {
357401
const dataStream = {
358402
...mockDataStreamFromEs,

x-pack/platform/plugins/shared/index_management/server/lib/data_stream_serialization.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@
66
*/
77

88
import { ByteSizeValue } from '@kbn/config-schema';
9-
import { LOGSDB_INDEX_MODE, STANDARD_INDEX_MODE } from '../../common/constants';
9+
import {
10+
IndexMode as INDEX_MODES,
11+
LOGSDB_INDEX_MODE,
12+
STANDARD_INDEX_MODE,
13+
} from '../../common/constants';
1014
import type { IndexMode } from '../../common/types/data_streams';
1115
import type { DataStream, EnhancedDataStreamFromEs, EsDataRetention, Health } from '../../common';
1216

17+
const INDEX_MODE_VALUES: ReadonlySet<string> = new Set(Object.values(INDEX_MODES));
18+
19+
const isIndexMode = (value: string | undefined): value is IndexMode =>
20+
value !== undefined && INDEX_MODE_VALUES.has(value);
21+
1322
const toLowercaseHealth = (status: EnhancedDataStreamFromEs['status']): Health => {
1423
switch (status) {
1524
case 'green':
@@ -154,12 +163,11 @@ export function deserializeDataStream(
154163
}
155164
const failureStoreLifecycle = failureStore?.lifecycle;
156165

157-
const resolvedIndexMode: IndexMode =
158-
indexMode === LOGSDB_INDEX_MODE || indexMode === STANDARD_INDEX_MODE
159-
? indexMode
160-
: isLogsdbEnabled && /^logs-[^-]+-[^-]+$/.test(name)
161-
? LOGSDB_INDEX_MODE
162-
: STANDARD_INDEX_MODE;
166+
const resolvedIndexMode: IndexMode = isIndexMode(indexMode)
167+
? indexMode
168+
: isLogsdbEnabled && /^logs-[^-]+-[^-]+$/.test(name)
169+
? LOGSDB_INDEX_MODE
170+
: STANDARD_INDEX_MODE;
163171

164172
const resolvedFailureStoreDefaultRetentionPeriod =
165173
failureStoreLifecycle?.retention_determined_by === 'default_failures_retention' &&

x-pack/platform/plugins/shared/index_management/test/scout/ui/tests/data_streams/data_streams_index_mode.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ test.describe('Data streams index mode', { tag: tags.deploymentAgnostic }, () =>
180180
await expect(dataStreamIndexMode(page)).toHaveText(INDEX_MODE.LOGSDB);
181181
});
182182

183-
// Skipped: the details flyout reports "Standard" for a time series data stream.
184-
// See https://github.com/elastic/kibana/issues/283371
185-
test.skip('allows to downgrade data stream from logsdb to time series index mode', async ({
183+
test('allows to downgrade data stream from logsdb to time series index mode', async ({
186184
page,
187185
esClient,
188186
pageObjects,

0 commit comments

Comments
 (0)