Skip to content

Commit

Permalink
[Index Management] Add support for index mode (#197874)
Browse files Browse the repository at this point in the history
Closes #195772

## Summary

This PR displays the index mode setting in Index templates (at Review
step in creation flow and at template details flyout) and Data streams
(in ds table and ds details flyout).

<img width="1523" alt="Screenshot 2024-10-28 at 14 39 18"
src="https://github.com/user-attachments/assets/9d40c1cd-d08a-4950-a679-29d9910ee845">
<img width="1523" alt="Screenshot 2024-10-28 at 19 05 29"
src="https://github.com/user-attachments/assets/463e549d-68cd-4ddf-ae0a-cfe43e47af10">

<img width="1523" alt="Screenshot 2024-10-28 at 14 41 01"
src="https://github.com/user-attachments/assets/4ccf8727-5913-4857-9dc2-48c40da3a356">
<img width="1523" alt="Screenshot 2024-10-28 at 14 41 09"
src="https://github.com/user-attachments/assets/a6b6a0a9-7ae2-4201-8ff9-3bead915fb2a">

### How to test:
**Creating a Logsdb index template and data stream:**
1. Go to Index Managament -> Index templates and start creating a new
template
2. Add a name and an index pattern `test-logsdb` and then go to the
Settings step
3. Add the setting `"index.mode": "logsdb`.
4. Go to last step (review) and verify that the index mode is correctly
displayed in Summary. Save the template.
5. In the template flyout, verify that the index mode displays the
correct label.
6. Go to Console and create a data stream that mathes the index pattern
of the created index template: `PUT _data_stream/test-logsdb`
7. Go to Index Management -> Data streams
8. In the data streams table, verify that the index mode column is
correct for the new data stream.
9. Open the new data stream and verify that the details flyout displays
the correct index mode.

**Creating a Time series index template and data stream:**
1. Go to Index Managament -> Index templates and start creating a new
template
2. Add a name and an index pattern `test-tsds` and then go to the
Settings step
3. Add the setting `"index.mode": "time_series`.
4. For time series index template, we also need to add a mapping with a
`time_series_dimension` property. Go to the Mappings step, click on
"Load JSON" and add the following mappings object:
```
{
  "properties": {
    "id": {
      "type": "keyword",
      "time_series_dimension": true
    }
  }
}
```
6. Go to last step (review) and verify that the index mode is correctly
displayed in Summary. Save the template.
7. In the template flyout, verify that the index mode displays the
correct label.
8. Go to Console and create a data stream that mathes the index pattern
of the created index template: `PUT _data_stream/test-tsds`
9. Go to Index Management -> Data streams
10. In the data streams table, verify that the index mode column is
correct for the new data stream.
11. Open the new data stream and verify that the details flyout displays
the correct index mode.

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7288
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 40ddfbc)
  • Loading branch information
ElenaStoeva committed Oct 31, 2024
1 parent fe3a0ff commit 8aaad32
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 50 deletions.
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
4 changes: 4 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 @@ -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 {
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
)}
</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:
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>({
tableId: 'indices',
initialPageSize: pager.itemsPerPage,
pageSizeOptions: PAGE_SIZE_OPTIONS,
Expand Down
Loading

0 comments on commit 8aaad32

Please sign in to comment.