Skip to content
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

[Index Management] Add support for index mode #197874

Merged
merged 19 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export const createDataStreamPayload = (dataStream: Partial<DataStream>): DataSt
enabled: true,
data_retention: '7d',
},
indexMode: 'standard',
...dataStream,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ describe('Data Streams tab', () => {
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', '1', '7 days', 'Delete'],
['', 'dataStream2', 'green', '1', '5 days ', 'Delete'],
['', 'dataStream1', 'green', '1', 'Standard', '7 days', 'Delete'],
['', 'dataStream2', 'green', '1', 'Standard', '5 days ', 'Delete'],
]);
});

Expand Down Expand Up @@ -254,6 +254,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
Expand All @@ -264,6 +265,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
Expand All @@ -289,6 +291,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
Expand All @@ -299,6 +302,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
Expand Down Expand Up @@ -346,8 +350,8 @@ describe('Data Streams tab', () => {

const { tableCellsValues } = table.getMetaData('dataStreamTable');
expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', '156kb', '10000', '1', '7 days', 'Delete'],
['', 'dataStream2', 'green', '156kb', '10000', '1', '5 days ', 'Delete'],
['', 'dataStream1', 'green', '156kb', '10000', '1', 'Standard', '7 days', 'Delete'],
['', 'dataStream2', 'green', '156kb', '10000', '1', 'Standard', '5 days ', 'Delete'],
]);
});

Expand Down Expand Up @@ -378,6 +382,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
Expand All @@ -388,6 +393,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
Expand Down Expand Up @@ -509,8 +515,8 @@ describe('Data Streams tab', () => {
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', '1', 'Disabled', 'Delete'],
['', 'dataStream2', 'green', '1', '', 'Delete'],
['', 'dataStream1', 'green', '1', 'Standard', 'Disabled', 'Delete'],
['', 'dataStream2', 'green', '1', 'Standard', '', 'Delete'],
]);

await actions.clickNameAt(0);
Expand Down Expand Up @@ -892,8 +898,16 @@ describe('Data Streams tab', () => {
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', `managed-data-stream${nonBreakingSpace}Managed`, 'green', '1', '7 days', 'Delete'],
['', 'non-managed-data-stream', 'green', '1', '7 days', 'Delete'],
[
'',
`managed-data-stream${nonBreakingSpace}Managed`,
'green',
'1',
'Standard',
'7 days',
'Delete',
],
['', 'non-managed-data-stream', 'green', '1', 'Standard', '7 days', 'Delete'],
]);
});

Expand All @@ -902,15 +916,23 @@ describe('Data Streams tab', () => {
let { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', `managed-data-stream${nonBreakingSpace}Managed`, 'green', '1', '7 days', 'Delete'],
['', 'non-managed-data-stream', 'green', '1', '7 days', 'Delete'],
[
'',
`managed-data-stream${nonBreakingSpace}Managed`,
'green',
'1',
'Standard',
'7 days',
'Delete',
],
['', 'non-managed-data-stream', 'green', '1', 'Standard', '7 days', 'Delete'],
]);

actions.toggleViewFilterAt(0);

({ tableCellsValues } = table.getMetaData('dataStreamTable'));
expect(tableCellsValues).toEqual([
['', 'non-managed-data-stream', 'green', '1', '7 days', 'Delete'],
['', 'non-managed-data-stream', 'green', '1', 'Standard', '7 days', 'Delete'],
]);
});
});
Expand Down Expand Up @@ -942,7 +964,15 @@ describe('Data Streams tab', () => {
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', `hidden-data-stream${nonBreakingSpace}Hidden`, 'green', '1', '7 days', 'Delete'],
[
'',
`hidden-data-stream${nonBreakingSpace}Hidden`,
'green',
'1',
'Standard',
'7 days',
'Delete',
],
]);
});
});
Expand Down Expand Up @@ -989,10 +1019,10 @@ describe('Data Streams tab', () => {
const { tableCellsValues } = table.getMetaData('dataStreamTable');

expect(tableCellsValues).toEqual([
['', 'dataStreamNoDelete', 'green', '1', '7 days', ''],
['', 'dataStreamNoEditRetention', 'green', '1', '7 days', 'Delete'],
['', 'dataStreamNoPermissions', 'green', '1', '7 days', ''],
['', 'dataStreamWithDelete', 'green', '1', '7 days', 'Delete'],
['', 'dataStreamNoDelete', 'green', '1', 'Standard', '7 days', ''],
['', 'dataStreamNoEditRetention', 'green', '1', 'Standard', '7 days', 'Delete'],
['', 'dataStreamNoPermissions', 'green', '1', 'Standard', '7 days', ''],
['', 'dataStreamWithDelete', 'green', '1', 'Standard', '7 days', 'Delete'],
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ export function deserializeTemplate(
type = 'managed';
}

const ilmPolicyName = settings?.index?.lifecycle?.name;

const deserializedTemplate: TemplateDeserialized = {
name,
version,
priority,
...(template.lifecycle ? { lifecycle: deserializeESLifecycle(template.lifecycle) } : {}),
indexPatterns: indexPatterns.sort(),
template,
ilmPolicy: settings?.index?.lifecycle,
ilmPolicy: ilmPolicyName ? { name: ilmPolicyName } : undefined,
composedOf: composedOf ?? [],
ignoreMissingComponentTemplates: ignoreMissingComponentTemplates ?? [],
dataStream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type DataStreamIndexFromEs = IndicesDataStreamIndex;

export type Health = 'green' | 'yellow' | 'red';

export type IndexMode = 'standard' | 'logsdb' | 'time_series';

export interface EnhancedDataStreamFromEs extends IndicesDataStream {
global_max_retention?: string;
store_size?: IndicesDataStreamsStatsDataStreamsStatsItem['store_size'];
Expand All @@ -45,6 +47,7 @@ export interface EnhancedDataStreamFromEs extends IndicesDataStream {
delete_index: boolean;
manage_data_stream_lifecycle: boolean;
};
index_mode?: string | null;
}

export interface DataStream {
Expand All @@ -71,6 +74,7 @@ export interface DataStream {
retention_determined_by?: string;
globalMaxRetention?: string;
};
indexMode: IndexMode;
}

export interface DataStreamIndex {
Expand Down
33 changes: 3 additions & 30 deletions x-pack/plugins/index_management/common/types/indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,9 @@
* 2.0.
*/

export type { Index } from '@kbn/index-management-shared-types';
import { IndicesIndexSettingsKeys } from '@elastic/elasticsearch/lib/api/types';

export interface IndexModule {
Copy link
Contributor Author

@ElenaStoeva ElenaStoeva Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this manual type in favor of IndicesIndexSettingsKeys type from Es client since the manual one has missing properties (e.g. mode).

number_of_shards: number | string;
codec: string;
routing_partition_size: number;
refresh_interval: string;
load_fixed_bitset_filters_eagerly: boolean;
shard: {
check_on_startup: boolean | 'checksum';
};
number_of_replicas: number;
auto_expand_replicas: false | string;
lifecycle: LifecycleModule;
routing: {
allocation: {
enable: 'all' | 'primaries' | 'new_primaries' | 'none';
};
rebalance: {
enable: 'all' | 'primaries' | 'replicas' | 'none';
};
};
}
export type { Index } from '@kbn/index-management-shared-types';

interface AnalysisModule {
analyzer: {
Expand All @@ -41,15 +21,8 @@ interface AnalysisModule {
};
}

interface LifecycleModule {
name: string;
rollover_alias?: string;
parse_origination_date?: boolean;
origination_date?: number;
}

export interface IndexSettings {
index?: Partial<IndexModule>;
index?: IndicesIndexSettingsKeys;
analysis?: AnalysisModule;
[key: string]: any;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
EuiCodeBlock,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { getIndexModeLabel } from '../../../lib/index_mode_labels';
import { allowAutoCreateRadioIds } from '../../../../../common/constants';
import { serializers } from '../../../../shared_imports';

Expand Down Expand Up @@ -268,6 +269,19 @@ export const StepReview: React.FunctionComponent<Props> = React.memo(
{getDescriptionText(serializedSettings)}
</EuiDescriptionListDescription>

{/* Index mode */}
<EuiDescriptionListTitle data-test-subj="indexModeTitle">
<FormattedMessage
id="xpack.idxMgmt.templateForm.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription data-test-subj="indexModeValue">
{getIndexModeLabel(
serializedSettings?.['index.mode'] ?? serializedSettings?.index?.mode
mattkime marked this conversation as resolved.
Show resolved Hide resolved
)}
</EuiDescriptionListDescription>

{/* Mappings */}
<EuiDescriptionListTitle>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';

export const getIndexModeLabel = (mode?: string | null) => {
switch (mode) {
case 'standard':
case null:
mattkime marked this conversation as resolved.
Show resolved Hide resolved
case undefined:
return i18n.translate('xpack.idxMgmt.indexModeLabels.standardModeLabel', {
defaultMessage: 'Standard',
});
case 'logsdb':
return i18n.translate('xpack.idxMgmt.indexModeLabels.logsdbModeLabel', {
defaultMessage: 'LogsDB',
});
case 'time_series':
return i18n.translate('xpack.idxMgmt.indexModeLabels.tsdbModeLabel', {
defaultMessage: 'Time series',
});
default:
return mode;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
EuiSpacer,
} from '@elastic/eui';

import { getIndexModeLabel } from '../../../../lib/index_mode_labels';
import { DiscoverLink } from '../../../../lib/discover_link';
import { getLifecycleValue } from '../../../../lib/data_streams';
import { SectionLoading, reactRouterNavigate } from '../../../../../shared_imports';
Expand Down Expand Up @@ -166,6 +167,7 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
meteringStorageSize,
meteringDocsCount,
lifecycle,
indexMode,
} = dataStream;

const getManagementDetails = () => {
Expand Down Expand Up @@ -345,6 +347,17 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
),
dataTestSubj: 'indexTemplateDetail',
},
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.indexModeTitle', {
defaultMessage: 'Index mode',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.indexModeToolTip', {
defaultMessage:
"The index mode applied to the data stream's backing indices, as defined in its associated index template.",
}),
content: getIndexModeLabel(indexMode),
dataTestSubj: 'indexModeDetail',
},
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.dataRetentionTitle', {
defaultMessage: 'Effective data retention',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { humanizeTimeStamp } from '../humanize_time_stamp';
import { DataStreamsBadges } from '../data_stream_badges';
import { ConditionalWrap } from '../data_stream_detail_panel';
import { isDataStreamFullyManagedByILM } from '../../../../lib/data_streams';
import { getIndexModeLabel } from '../../../../lib/index_mode_labels';
import { FilterListButton, Filters } from '../../components';
import { type DataStreamFilterName } from '../data_stream_list';

Expand Down Expand Up @@ -184,6 +185,16 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({
),
});

columns.push({
field: 'indexMode',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.indexModeColumnTitle', {
defaultMessage: 'Index mode',
}),
truncateText: true,
sortable: true,
render: (indexMode: DataStream['indexMode']) => getIndexModeLabel(indexMode),
});

columns.push({
field: 'lifecycle',
name: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { EuiTablePagination } from '@elastic/eui';
import { useEuiTablePersist } from '@kbn/shared-ux-table-persist';
import { IndexModule } from '../../../../../../common';
import { Index } from '../../../../../../common';

interface IndexTablePaginationProps {
pager: any;
Expand All @@ -27,7 +27,7 @@ export const IndexTablePagination = ({
readURLParams,
setURLParam,
}: IndexTablePaginationProps) => {
const { pageSize, onTableChange } = useEuiTablePersist<IndexModule>({
const { pageSize, onTableChange } = useEuiTablePersist<Index>({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems here we used an incorrect type - it should be Index.

tableId: 'indices',
initialPageSize: pager.itemsPerPage,
pageSizeOptions: PAGE_SIZE_OPTIONS,
Expand Down
Loading