[8.x] [Index Management] Add support for index mode (#197874) (#198481)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Index Management] Add support for index mode
(#197874)](https://github.com/elastic/kibana/pull/197874)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-31T09:25:16Z","message":"[Index
Management] Add support for index mode (#197874)\n\nCloses
https://github.com/elastic/kibana/issues/195772\r\n\r\n##
Summary\r\n\r\nThis PR displays the index mode setting in Index
templates (at Review\r\nstep in creation flow and at template details
flyout) and Data streams\r\n(in ds table and ds details
flyout).\r\n\r\n<img width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 39
18\"\r\nsrc=\"https://github.com/user-attachments/assets/9d40c1cd-d08a-4950-a679-29d9910ee845\">\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 19 05
29\"\r\nsrc=\"https://github.com/user-attachments/assets/463e549d-68cd-4ddf-ae0a-cfe43e47af10\">\r\n\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 41
01\"\r\nsrc=\"https://github.com/user-attachments/assets/4ccf8727-5913-4857-9dc2-48c40da3a356\">\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 41
09\"\r\nsrc=\"https://github.com/user-attachments/assets/a6b6a0a9-7ae2-4201-8ff9-3bead915fb2a\">\r\n\r\n###
How to test:\r\n**Creating a Logsdb index template and data
stream:**\r\n1. Go to Index Managament -> Index templates and start
creating a new\r\ntemplate\r\n2. Add a name and an index pattern
`test-logsdb` and then go to the\r\nSettings step\r\n3. Add the setting
`\"index.mode\": \"logsdb`.\r\n4. Go to last step (review) and verify
that the index mode is correctly\r\ndisplayed in Summary. Save the
template.\r\n5. In the template flyout, verify that the index mode
displays the\r\ncorrect label.\r\n6. Go to Console and create a data
stream that mathes the index pattern\r\nof the created index template:
`PUT _data_stream/test-logsdb`\r\n7. Go to Index Management -> Data
streams\r\n8. In the data streams table, verify that the index mode
column is\r\ncorrect for the new data stream.\r\n9. Open the new data
stream and verify that the details flyout displays\r\nthe correct index
mode.\r\n\r\n**Creating a Time series index template and data
stream:**\r\n1. Go to Index Managament -> Index templates and start
creating a new\r\ntemplate\r\n2. Add a name and an index pattern
`test-tsds` and then go to the\r\nSettings step\r\n3. Add the setting
`\"index.mode\": \"time_series`.\r\n4. For time series index template,
we also need to add a mapping with a\r\n`time_series_dimension`
property. Go to the Mappings step, click on\r\n\"Load JSON\" and add the
following mappings object:\r\n```\r\n{\r\n \"properties\": {\r\n \"id\":
{\r\n \"type\": \"keyword\",\r\n \"time_series_dimension\": true\r\n
}\r\n }\r\n}\r\n```\r\n6. Go to last step (review) and verify that the
index mode is correctly\r\ndisplayed in Summary. Save the
template.\r\n7. In the template flyout, verify that the index mode
displays the\r\ncorrect label.\r\n8. Go to Console and create a data
stream that mathes the index pattern\r\nof the created index template:
`PUT _data_stream/test-tsds`\r\n9. Go to Index Management -> Data
streams\r\n10. In the data streams table, verify that the index mode
column is\r\ncorrect for the new data stream.\r\n11. Open the new data
stream and verify that the details flyout displays\r\nthe correct index
mode.\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7288\r\n-
[x] Any UI touched in this PR is usable by keyboard only (learn
more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"40ddfbc044c7f9fed5cc39b57ecc7d0c479ea36d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index
Management","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.17.0"],"title":"[Index
Management] Add support for index
mode","number":197874,"url":"https://github.com/elastic/kibana/pull/197874","mergeCommit":{"message":"[Index
Management] Add support for index mode (#197874)\n\nCloses
https://github.com/elastic/kibana/issues/195772\r\n\r\n##
Summary\r\n\r\nThis PR displays the index mode setting in Index
templates (at Review\r\nstep in creation flow and at template details
flyout) and Data streams\r\n(in ds table and ds details
flyout).\r\n\r\n<img width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 39
18\"\r\nsrc=\"https://github.com/user-attachments/assets/9d40c1cd-d08a-4950-a679-29d9910ee845\">\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 19 05
29\"\r\nsrc=\"https://github.com/user-attachments/assets/463e549d-68cd-4ddf-ae0a-cfe43e47af10\">\r\n\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 41
01\"\r\nsrc=\"https://github.com/user-attachments/assets/4ccf8727-5913-4857-9dc2-48c40da3a356\">\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 41
09\"\r\nsrc=\"https://github.com/user-attachments/assets/a6b6a0a9-7ae2-4201-8ff9-3bead915fb2a\">\r\n\r\n###
How to test:\r\n**Creating a Logsdb index template and data
stream:**\r\n1. Go to Index Managament -> Index templates and start
creating a new\r\ntemplate\r\n2. Add a name and an index pattern
`test-logsdb` and then go to the\r\nSettings step\r\n3. Add the setting
`\"index.mode\": \"logsdb`.\r\n4. Go to last step (review) and verify
that the index mode is correctly\r\ndisplayed in Summary. Save the
template.\r\n5. In the template flyout, verify that the index mode
displays the\r\ncorrect label.\r\n6. Go to Console and create a data
stream that mathes the index pattern\r\nof the created index template:
`PUT _data_stream/test-logsdb`\r\n7. Go to Index Management -> Data
streams\r\n8. In the data streams table, verify that the index mode
column is\r\ncorrect for the new data stream.\r\n9. Open the new data
stream and verify that the details flyout displays\r\nthe correct index
mode.\r\n\r\n**Creating a Time series index template and data
stream:**\r\n1. Go to Index Managament -> Index templates and start
creating a new\r\ntemplate\r\n2. Add a name and an index pattern
`test-tsds` and then go to the\r\nSettings step\r\n3. Add the setting
`\"index.mode\": \"time_series`.\r\n4. For time series index template,
we also need to add a mapping with a\r\n`time_series_dimension`
property. Go to the Mappings step, click on\r\n\"Load JSON\" and add the
following mappings object:\r\n```\r\n{\r\n \"properties\": {\r\n \"id\":
{\r\n \"type\": \"keyword\",\r\n \"time_series_dimension\": true\r\n
}\r\n }\r\n}\r\n```\r\n6. Go to last step (review) and verify that the
index mode is correctly\r\ndisplayed in Summary. Save the
template.\r\n7. In the template flyout, verify that the index mode
displays the\r\ncorrect label.\r\n8. Go to Console and create a data
stream that mathes the index pattern\r\nof the created index template:
`PUT _data_stream/test-tsds`\r\n9. Go to Index Management -> Data
streams\r\n10. In the data streams table, verify that the index mode
column is\r\ncorrect for the new data stream.\r\n11. Open the new data
stream and verify that the details flyout displays\r\nthe correct index
mode.\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7288\r\n-
[x] Any UI touched in this PR is usable by keyboard only (learn
more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"40ddfbc044c7f9fed5cc39b57ecc7d0c479ea36d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197874","number":197874,"mergeCommit":{"message":"[Index
Management] Add support for index mode (#197874)\n\nCloses
https://github.com/elastic/kibana/issues/195772\r\n\r\n##
Summary\r\n\r\nThis PR displays the index mode setting in Index
templates (at Review\r\nstep in creation flow and at template details
flyout) and Data streams\r\n(in ds table and ds details
flyout).\r\n\r\n<img width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 39
18\"\r\nsrc=\"https://github.com/user-attachments/assets/9d40c1cd-d08a-4950-a679-29d9910ee845\">\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 19 05
29\"\r\nsrc=\"https://github.com/user-attachments/assets/463e549d-68cd-4ddf-ae0a-cfe43e47af10\">\r\n\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 41
01\"\r\nsrc=\"https://github.com/user-attachments/assets/4ccf8727-5913-4857-9dc2-48c40da3a356\">\r\n<img
width=\"1523\" alt=\"Screenshot 2024-10-28 at 14 41
09\"\r\nsrc=\"https://github.com/user-attachments/assets/a6b6a0a9-7ae2-4201-8ff9-3bead915fb2a\">\r\n\r\n###
How to test:\r\n**Creating a Logsdb index template and data
stream:**\r\n1. Go to Index Managament -> Index templates and start
creating a new\r\ntemplate\r\n2. Add a name and an index pattern
`test-logsdb` and then go to the\r\nSettings step\r\n3. Add the setting
`\"index.mode\": \"logsdb`.\r\n4. Go to last step (review) and verify
that the index mode is correctly\r\ndisplayed in Summary. Save the
template.\r\n5. In the template flyout, verify that the index mode
displays the\r\ncorrect label.\r\n6. Go to Console and create a data
stream that mathes the index pattern\r\nof the created index template:
`PUT _data_stream/test-logsdb`\r\n7. Go to Index Management -> Data
streams\r\n8. In the data streams table, verify that the index mode
column is\r\ncorrect for the new data stream.\r\n9. Open the new data
stream and verify that the details flyout displays\r\nthe correct index
mode.\r\n\r\n**Creating a Time series index template and data
stream:**\r\n1. Go to Index Managament -> Index templates and start
creating a new\r\ntemplate\r\n2. Add a name and an index pattern
`test-tsds` and then go to the\r\nSettings step\r\n3. Add the setting
`\"index.mode\": \"time_series`.\r\n4. For time series index template,
we also need to add a mapping with a\r\n`time_series_dimension`
property. Go to the Mappings step, click on\r\n\"Load JSON\" and add the
following mappings object:\r\n```\r\n{\r\n \"properties\": {\r\n \"id\":
{\r\n \"type\": \"keyword\",\r\n \"time_series_dimension\": true\r\n
}\r\n }\r\n}\r\n```\r\n6. Go to last step (review) and verify that the
index mode is correctly\r\ndisplayed in Summary. Save the
template.\r\n7. In the template flyout, verify that the index mode
displays the\r\ncorrect label.\r\n8. Go to Console and create a data
stream that mathes the index pattern\r\nof the created index template:
`PUT _data_stream/test-tsds`\r\n9. Go to Index Management -> Data
streams\r\n10. In the data streams table, verify that the index mode
column is\r\ncorrect for the new data stream.\r\n11. Open the new data
stream and verify that the details flyout displays\r\nthe correct index
mode.\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests
changed:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7288\r\n-
[x] Any UI touched in this PR is usable by keyboard only (learn
more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"40ddfbc044c7f9fed5cc39b57ecc7d0c479ea36d"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2024-10-31 22:07:10 +11:00 committed by GitHub
parent 44df1bbf9a
commit 35113f89cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 246 additions and 50 deletions

View file

@ -298,6 +298,7 @@ export const createDataStreamPayload = (dataStream: Partial<DataStream>): DataSt
enabled: true,
data_retention: '7d',
},
indexMode: 'standard',
...dataStream,
});

View file

@ -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'],
]);
});
@ -254,6 +254,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
@ -264,6 +265,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
@ -289,6 +291,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
@ -299,6 +302,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
@ -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'],
]);
});
@ -378,6 +382,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
@ -388,6 +393,7 @@ describe('Data Streams tab', () => {
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
@ -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);
@ -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'],
]);
});
@ -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'],
]);
});
});
@ -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',
],
]);
});
});
@ -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'],
]);
});

View file

@ -73,6 +73,8 @@ export function deserializeTemplate(
type = 'managed';
}
const ilmPolicyName = settings?.index?.lifecycle?.name;
const deserializedTemplate: TemplateDeserialized = {
name,
version,
@ -80,7 +82,7 @@ export function deserializeTemplate(
...(template.lifecycle ? { lifecycle: deserializeESLifecycle(template.lifecycle) } : {}),
indexPatterns: indexPatterns.sort(),
template,
ilmPolicy: settings?.index?.lifecycle,
ilmPolicy: ilmPolicyName ? { name: ilmPolicyName } : undefined,
composedOf: composedOf ?? [],
ignoreMissingComponentTemplates: ignoreMissingComponentTemplates ?? [],
dataStream,

View file

@ -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'];
@ -45,6 +47,7 @@ export interface EnhancedDataStreamFromEs extends IndicesDataStream {
delete_index: boolean;
manage_data_stream_lifecycle: boolean;
};
index_mode?: string | null;
}
export interface DataStream {
@ -71,6 +74,7 @@ export interface DataStream {
retention_determined_by?: string;
globalMaxRetention?: string;
};
indexMode: IndexMode;
}
export interface DataStreamIndex {

View file

@ -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: {
@ -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;
}

View file

@ -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';
@ -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

View file

@ -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;
}
};

View file

@ -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';
@ -166,6 +167,7 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
meteringStorageSize,
meteringDocsCount,
lifecycle,
indexMode,
} = dataStream;
const getManagementDetails = () => {
@ -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',

View file

@ -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';
@ -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: (

View file

@ -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;
@ -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,

View file

@ -28,6 +28,7 @@ import { TemplateDeserialized } from '../../../../../../../common';
import { ILM_PAGES_POLICY_EDIT } from '../../../../../constants';
import { useIlmLocator } from '../../../../../services/use_ilm_locator';
import { allowAutoCreateRadioIds } from '../../../../../../../common/constants';
import { getIndexModeLabel } from '../../../../../lib/index_mode_labels';
interface Props {
templateDetails: TemplateDeserialized;
@ -57,6 +58,7 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })
_meta,
_kbnMeta: { isLegacy, hasDatastream },
allowAutoCreate,
template,
} = templateDetails;
const numIndexPatterns = indexPatterns.length;
@ -221,6 +223,17 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })
</>
)}
{/* Index mode */}
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.idxMgmt.templateDetails.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{getIndexModeLabel(template?.settings?.index?.mode)}
</EuiDescriptionListDescription>
{/* Allow auto create */}
{isLegacy !== true &&
allowAutoCreate !== allowAutoCreateRadioIds.NO_OVERWRITE_RADIO_OPTION && (

View file

@ -6,6 +6,7 @@
*/
import { ByteSizeValue } from '@kbn/config-schema';
import { IndexMode } from '../../common/types/data_streams';
import type { DataStream, EnhancedDataStreamFromEs, Health } from '../../common';
export function deserializeDataStream(dataStreamFromEs: EnhancedDataStreamFromEs): DataStream {
@ -28,6 +29,7 @@ export function deserializeDataStream(dataStreamFromEs: EnhancedDataStreamFromEs
lifecycle,
global_max_retention: globalMaxRetention,
next_generation_managed_by: nextGenerationManagedBy,
index_mode: indexMode,
} = dataStreamFromEs;
const meteringStorageSize =
meteringStorageSizeBytes !== undefined
@ -73,6 +75,7 @@ export function deserializeDataStream(dataStreamFromEs: EnhancedDataStreamFromEs
globalMaxRetention,
},
nextGenerationManagedBy,
indexMode: (indexMode ?? 'standard') as IndexMode,
};
}

View file

@ -11,6 +11,7 @@ import { IScopedClusterClient } from '@kbn/core/server';
import {
IndicesDataStream,
IndicesDataStreamsStatsDataStreamsStatsItem,
IndicesGetIndexTemplateIndexTemplateItem,
SecurityHasPrivilegesResponse,
} from '@elastic/elasticsearch/lib/api/types';
import type { MeteringStats } from '../../../lib/types';
@ -31,12 +32,14 @@ const enhanceDataStreams = ({
meteringStats,
dataStreamsPrivileges,
globalMaxRetention,
indexTemplates,
}: {
dataStreams: IndicesDataStream[];
dataStreamsStats?: IndicesDataStreamsStatsDataStreamsStatsItem[];
meteringStats?: MeteringStats[];
dataStreamsPrivileges?: SecurityHasPrivilegesResponse;
globalMaxRetention?: string;
indexTemplates?: IndicesGetIndexTemplateIndexTemplateItem[];
}): EnhancedDataStreamFromEs[] => {
return dataStreams.map((dataStream) => {
const enhancedDataStream: EnhancedDataStreamFromEs = {
@ -71,6 +74,16 @@ const enhanceDataStreams = ({
}
}
if (indexTemplates) {
const indexTemplate = indexTemplates.find(
(template) => template.name === dataStream.template
);
if (indexTemplate) {
enhancedDataStream.index_mode =
indexTemplate.index_template?.template?.settings?.index?.mode;
}
}
return enhancedDataStream;
});
};
@ -152,11 +165,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) });
@ -199,17 +216,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 });

View file

@ -94,6 +94,7 @@ function toMissingDataStream({
privileges: { delete_index: true, manage_data_stream_lifecycle: true },
hidden: false,
nextGenerationManagedBy: 'Data stream lifecycle',
indexMode: 'standard',
};
}

View file

@ -73,6 +73,7 @@ export default function ({ getService }: FtrProviderContext) {
health: 'yellow',
indexTemplateName: testDataStreamName,
hidden: false,
indexMode: 'standard',
});
});
@ -120,6 +121,7 @@ export default function ({ getService }: FtrProviderContext) {
lifecycle: {
enabled: true,
},
indexMode: 'standard',
});
});
@ -158,8 +160,25 @@ export default function ({ getService }: FtrProviderContext) {
lifecycle: {
enabled: true,
},
indexMode: 'standard',
});
});
it('correctly returns index mode property', async () => {
const logsdbDataStreamName = 'logsdb-test-data-stream';
const indexMode = 'logsdb';
await createDataStream(logsdbDataStreamName, indexMode);
const { body: dataStream } = await supertest
.get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`)
.set('kbn-xsrf', 'xxx')
.expect(200);
expect(dataStream.indexMode).to.eql(indexMode);
await deleteDataStream(logsdbDataStreamName);
});
});
describe('Update', () => {

View file

@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';
export function datastreamsHelpers(getService: FtrProviderContext['getService']) {
const es = getService('es');
const createDataStream = async (name: string) => {
const createDataStream = async (name: string, indexMode?: string) => {
// A data stream requires an index template before it can be created.
await es.indices.putIndexTemplate({
name,
@ -26,6 +26,11 @@ export function datastreamsHelpers(getService: FtrProviderContext['getService'])
},
},
},
settings: {
index: {
mode: indexMode,
},
},
lifecycle: {
// @ts-expect-error @elastic/elasticsearch enabled prop is not typed yet
enabled: true,

View file

@ -88,6 +88,47 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.click('closeDetailsButton');
});
describe('shows the correct index mode in the details flyout', function () {
it('standard index mode', async () => {
// Open details flyout of existing data stream - it has standard index mode
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME);
// Check that index mode detail exists and its label is "Standard"
expect(await testSubjects.exists('indexModeDetail')).to.be(true);
expect(await testSubjects.getVisibleText('indexModeDetail')).to.be('Standard');
// Close flyout
await testSubjects.click('closeDetailsButton');
});
it('logsdb index mode', async () => {
// Create an index template with a logsdb index mode
await es.indices.putIndexTemplate({
name: `logsdb_index_template`,
index_patterns: ['test-logsdb'],
data_stream: {},
template: {
settings: { mode: 'logsdb' },
},
});
// Create a data stream matching the index pattern of the index template above
await es.indices.createDataStream({
name: 'test-logsdb',
});
await browser.refresh();
// Open details flyout of data stream
await pageObjects.indexManagement.clickDataStreamNameLink('test-logsdb');
// Check that index mode detail exists and its label is "LogsDB"
expect(await testSubjects.exists('indexModeDetail')).to.be(true);
expect(await testSubjects.getVisibleText('indexModeDetail')).to.be('LogsDB');
// Close flyout
await testSubjects.click('closeDetailsButton');
// Delete data stream and index template
await es.indices.deleteDataStream({ name: 'test-logsdb' });
await es.indices.deleteIndexTemplate({
name: `logsdb_index_template`,
});
});
});
it('allows to update data retention', async () => {
// Open details flyout
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME);

View file

@ -98,6 +98,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const summaryTabContent = await testSubjects.exists('summaryTabContent');
expect(summaryTabContent).to.be(true);
// Verify that index mode is set to "Standard"
expect(await testSubjects.exists('indexModeTitle')).to.be(true);
expect(await testSubjects.getVisibleText('indexModeValue')).to.be('Standard');
// Click Create template
await pageObjects.indexManagement.clickNextButton();
});

View file

@ -61,6 +61,7 @@ export default function ({ getService }: FtrProviderContext) {
nextGenerationManagedBy: 'Index Lifecycle Management',
storageSize: expect.any(String),
storageSizeBytes: expect.any(Number),
indexMode: 'standard',
});
});
});

View file

@ -80,6 +80,7 @@ export default function ({ getService }: FtrProviderContext) {
health: 'green',
indexTemplateName: testDataStreamName,
hidden: false,
indexMode: 'standard',
});
});
@ -121,6 +122,7 @@ export default function ({ getService }: FtrProviderContext) {
meteringDocsCount: 0,
meteringStorageSize: '0b',
meteringStorageSizeBytes: 0,
indexMode: 'standard',
});
});
});