Skip to content

Commit

Permalink
[Index Management] Add support for index mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Oct 25, 2024
1 parent e70b533 commit 09a5e42
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 1 deletion.
2 changes: 2 additions & 0 deletions x-pack/plugins/index_management/common/types/data_streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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 +72,7 @@ export interface DataStream {
retention_determined_by?: string;
globalMaxRetention?: string;
};
indexMode: string;
}

export interface DataStreamIndex {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ export const StepReview: React.FunctionComponent<Props> = React.memo(
{getDescriptionText(serializedSettings)}
</EuiDescriptionListDescription>

{/* Index settings */}
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.idxMgmt.templateForm.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{serializedSettings?.index?.mode ?? 'standard'}
</EuiDescriptionListDescription>

{/* Mappings */}
<EuiDescriptionListTitle>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
meteringStorageSize,
meteringDocsCount,
lifecycle,
indexMode,
} = dataStream;

const getManagementDetails = () => {
Expand Down Expand Up @@ -345,6 +346,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 setting of the index template that configured this data stream.',
}),
content: indexMode ?? 'standard',
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 @@ -84,6 +84,8 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
includeStats: isIncludeStatsChecked,
});

console.log(dataStreams);

const [projectLevelRetentionCallout, setprojectLevelRetentionCallout] =
useStateWithLocalStorage<boolean>(SHOW_PROJECT_LEVEL_RETENTION, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ 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,
});

columns.push({
field: 'lifecycle',
name: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function deserializeDataStream(dataStreamFromEs: EnhancedDataStreamFromEs
lifecycle,
global_max_retention: globalMaxRetention,
next_generation_managed_by: nextGenerationManagedBy,
index_mode: indexMode,
} = dataStreamFromEs;
const meteringStorageSize =
meteringStorageSizeBytes !== undefined
Expand Down Expand Up @@ -73,6 +74,7 @@ export function deserializeDataStream(dataStreamFromEs: EnhancedDataStreamFromEs
globalMaxRetention,
},
nextGenerationManagedBy,
indexMode: indexMode ?? 'standard',
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
deserializeDataStream,
deserializeDataStreamList,
} from '../../../lib/data_stream_serialization';
import { EnhancedDataStreamFromEs } from '../../../../common/types';
import { EnhancedDataStreamFromEs, TemplateSerialized } from '../../../../common/types';
import { RouteDependencies } from '../../../types';
import { addBasePath } from '..';

Expand All @@ -31,12 +31,14 @@ const enhanceDataStreams = ({
meteringStats,
dataStreamsPrivileges,
globalMaxRetention,
indexTemplates,
}: {
dataStreams: IndicesDataStream[];
dataStreamsStats?: IndicesDataStreamsStatsDataStreamsStatsItem[];
meteringStats?: MeteringStats[];
dataStreamsPrivileges?: SecurityHasPrivilegesResponse;
globalMaxRetention?: string;
indexTemplates?: Array<{ name: string; index_template: TemplateSerialized }>;
}): EnhancedDataStreamFromEs[] => {
return dataStreams.map((dataStream) => {
const enhancedDataStream: EnhancedDataStreamFromEs = {
Expand Down Expand Up @@ -71,6 +73,11 @@ const enhanceDataStreams = ({
}
}

const indexTemplate = indexTemplates.find((template) => template.name === dataStream.template);
if (indexTemplate) {
enhancedDataStream.index_mode = indexTemplate.index_template?.template?.settings?.index?.mode;
}

return enhancedDataStream;
});
};
Expand Down Expand Up @@ -152,11 +159,15 @@ export function registerGetAllRoute({ router, lib: { handleEsError }, config }:
);
}

const { index_templates: indexTemplates } =
await client.asCurrentUser.indices.getIndexTemplate();

const enhancedDataStreams = enhanceDataStreams({
dataStreams,
dataStreamsStats,
meteringStats,
dataStreamsPrivileges,
indexTemplates,
});

return response.ok({ body: deserializeDataStreamList(enhancedDataStreams) });
Expand Down Expand Up @@ -199,17 +210,30 @@ export function registerGetOneRoute({ router, lib: { handleEsError }, config }:

if (dataStreams[0]) {
let dataStreamsPrivileges;
let indexTemplates;

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

if (dataStreams[0].template) {
const { index_templates: templates } =
await client.asCurrentUser.indices.getIndexTemplate({
name: dataStreams[0].template,
});

if (templates) {
indexTemplates = templates;
}
}

const enhancedDataStreams = enhanceDataStreams({
dataStreams,
dataStreamsStats,
meteringStats,
dataStreamsPrivileges,
globalMaxRetention,
indexTemplates,
});
const body = deserializeDataStream(enhancedDataStreams[0]);
return response.ok({ body });
Expand Down

0 comments on commit 09a5e42

Please sign in to comment.