[Index Management] Disable data stream stats in serverless (#186420)

Closes https://github.com/elastic/kibana/issues/184671
Fixes https://github.com/elastic/kibana/issues/186245
Fixes https://github.com/elastic/kibana/issues/186243
Fixes https://github.com/elastic/kibana/issues/186242

## Summary

This PR disables the data stream stats API request in serverless and the
stats toggle in the Data stream list view. It adds a new config
`enableDataStreamStats` and removes the `enableDataStreamsStorageColumn`
one as it is now redundant (since the storage size property is part of
the data stream stats).

### How to test:

**In serverless:**
1. Start serverless Es and Kibana
2. Go to Stack Management -> Index Management and open the Data Streams
tab.
3. Verify that the stats toggle is not displayed and the data stream
detail panels don't include any of the stats (`storageSizeBytes` and
`maxTimeStamp`).

**In stateful:**
1. Start stateful Es and Kibana
2. Go to Stack Management -> Index Management and open the Data Streams
tab.
3. Verify that the stats toggle is displayed and switching it adds the
stats columns to the table.
4. Verify that the data stream detail panels include the stats.


<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] 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))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] 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))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->
This commit is contained in:
Elena Stoeva 2024-06-21 21:45:23 +01:00 committed by GitHub
parent 6d94d89c57
commit 781db4507d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 77 additions and 131 deletions

View file

@ -100,10 +100,10 @@ xpack.index_management.enableIndexActions: false
xpack.index_management.enableLegacyTemplates: false
# Disable index stats information from Index Management UI
xpack.index_management.enableIndexStats: false
# Disable data stream stats information from Index Management UI
xpack.index_management.enableDataStreamStats: false
# Only limited index settings can be edited
xpack.index_management.editableIndexSettings: limited
# Disable Storage size column in the Data streams table from Index Management UI
xpack.index_management.enableDataStreamsStorageColumn: false
# Disable _source field in the Mappings editor's advanced options form from Index Management UI
xpack.index_management.enableMappingsSourceFieldSection: false
# Disable toggle for enabling data retention in DSL form from Index Management UI

View file

@ -291,8 +291,8 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.index_management.enableIndexActions (any)',
'xpack.index_management.enableLegacyTemplates (any)',
'xpack.index_management.enableIndexStats (any)',
'xpack.index_management.enableDataStreamStats (any)',
'xpack.index_management.editableIndexSettings (any)',
'xpack.index_management.enableDataStreamsStorageColumn (any)',
'xpack.index_management.enableMappingsSourceFieldSection (any)',
'xpack.index_management.dev.enableSemanticText (boolean)',
'xpack.license_management.ui.enabled (boolean)',

View file

@ -82,8 +82,8 @@ const appDependencies = {
enableLegacyTemplates: true,
enableIndexActions: true,
enableIndexStats: true,
enableDataStreamStats: true,
editableIndexSettings: 'all',
enableDataStreamsStorageColumn: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
enableSemanticText: false,

View file

@ -303,14 +303,14 @@ describe('Data Streams tab', () => {
]);
});
test('hides Storage size column from stats if enableDataStreamsStorageColumn===false', async () => {
test('hides stats toggle if enableDataStreamStats===false', async () => {
testBed = await setup(httpSetup, {
config: {
enableDataStreamsStorageColumn: false,
enableDataStreamStats: false,
},
});
const { actions, component, table } = testBed;
const { actions, component, exists } = testBed;
await act(async () => {
actions.goToDataStreamsList();
@ -318,18 +318,7 @@ describe('Data Streams tab', () => {
component.update();
// Switching the stats on
await act(async () => {
actions.clickIncludeStatsSwitch();
});
component.update();
// The table renders with the stats columns except the Storage size column
const { tableCellsValues } = table.getMetaData('dataStreamTable');
expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', 'December 31st, 1969 7:00:00 PM', '1', '7 days', 'Delete'],
['', 'dataStream2', 'green', 'December 31st, 1969 7:00:00 PM', '1', '5 days ', 'Delete'],
]);
expect(exists('includeStatsSwitch')).toBeFalsy();
});
test('clicking the indices count navigates to the backing indices', async () => {

View file

@ -62,8 +62,8 @@ export interface AppDependencies {
enableIndexActions: boolean;
enableLegacyTemplates: boolean;
enableIndexStats: boolean;
enableDataStreamStats: boolean;
editableIndexSettings: 'all' | 'limited';
enableDataStreamsStorageColumn: boolean;
enableMappingsSourceFieldSection: boolean;
enableTogglingDataRetention: boolean;
enableSemanticText: boolean;

View file

@ -60,8 +60,11 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
const {
core: { getUrlForApp, executionContext },
plugins: { isFleetEnabled },
config,
} = useAppContext();
const { enableDataStreamStats: isDataStreamStatsEnabled } = config;
useExecutionContext(executionContext, {
type: 'application',
page: 'indexManagementDataStreamsTab',
@ -146,35 +149,37 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false}>
<EuiSwitch
label={i18n.translate(
'xpack.idxMgmt.dataStreamListControls.includeStatsSwitchLabel',
{
defaultMessage: 'Include stats',
}
)}
checked={isIncludeStatsChecked}
onChange={(e) => setIsIncludeStatsChecked(e.target.checked)}
data-test-subj="includeStatsSwitch"
/>
</EuiFlexItem>
{isDataStreamStatsEnabled && (
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false}>
<EuiSwitch
label={i18n.translate(
'xpack.idxMgmt.dataStreamListControls.includeStatsSwitchLabel',
{
defaultMessage: 'Include stats',
}
)}
checked={isIncludeStatsChecked}
onChange={(e) => setIsIncludeStatsChecked(e.target.checked)}
data-test-subj="includeStatsSwitch"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip
content={i18n.translate(
'xpack.idxMgmt.dataStreamListControls.includeStatsSwitchToolTip',
{
defaultMessage: 'Including stats can increase reload times',
}
)}
position="top"
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip
content={i18n.translate(
'xpack.idxMgmt.dataStreamListControls.includeStatsSwitchToolTip',
{
defaultMessage: 'Including stats can increase reload times',
}
)}
position="top"
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
)}
<EuiFlexItem grow={false}>
<FilterListButton<DataStreamFilterName> filters={filters} onChange={setFilters} />
</EuiFlexItem>

View file

@ -116,18 +116,16 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({
}),
});
if (config.enableDataStreamsStorageColumn) {
columns.push({
field: 'storageSizeBytes',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.storageSizeColumnTitle', {
defaultMessage: 'Storage size',
}),
truncateText: true,
sortable: true,
render: (storageSizeBytes: DataStream['storageSizeBytes'], dataStream: DataStream) =>
dataStream.storageSize,
});
}
columns.push({
field: 'storageSizeBytes',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.storageSizeColumnTitle', {
defaultMessage: 'Storage size',
}),
truncateText: true,
sortable: true,
render: (storageSizeBytes: DataStream['storageSizeBytes'], dataStream: DataStream) =>
dataStream.storageSize,
});
}
columns.push({

View file

@ -41,8 +41,8 @@ export class IndexMgmtUIPlugin
enableIndexActions: boolean;
enableLegacyTemplates: boolean;
enableIndexStats: boolean;
enableDataStreamStats: boolean;
editableIndexSettings: 'all' | 'limited';
enableDataStreamsStorageColumn: boolean;
isIndexManagementUiEnabled: boolean;
enableMappingsSourceFieldSection: boolean;
enableTogglingDataRetention: boolean;
@ -59,8 +59,8 @@ export class IndexMgmtUIPlugin
enableIndexActions,
enableLegacyTemplates,
enableIndexStats,
enableDataStreamStats,
editableIndexSettings,
enableDataStreamsStorageColumn,
enableMappingsSourceFieldSection,
enableTogglingDataRetention,
dev: { enableSemanticText },
@ -70,8 +70,8 @@ export class IndexMgmtUIPlugin
enableIndexActions: enableIndexActions ?? true,
enableLegacyTemplates: enableLegacyTemplates ?? true,
enableIndexStats: enableIndexStats ?? true,
enableDataStreamStats: enableDataStreamStats ?? true,
editableIndexSettings: editableIndexSettings ?? 'all',
enableDataStreamsStorageColumn: enableDataStreamsStorageColumn ?? true,
enableMappingsSourceFieldSection: enableMappingsSourceFieldSection ?? true,
enableTogglingDataRetention: enableTogglingDataRetention ?? true,
enableSemanticText: enableSemanticText ?? false,

View file

@ -52,8 +52,8 @@ export interface ClientConfigType {
enableIndexActions?: boolean;
enableLegacyTemplates?: boolean;
enableIndexStats?: boolean;
enableDataStreamStats?: boolean;
editableIndexSettings?: 'all' | 'limited';
enableDataStreamsStorageColumn?: boolean;
enableMappingsSourceFieldSection?: boolean;
enableTogglingDataRetention?: boolean;
dev: {

View file

@ -43,17 +43,17 @@ const schemaLatest = schema.object(
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
serverless: schema.boolean({ defaultValue: true }),
}),
enableDataStreamStats: offeringBasedSchema({
// Data stream stats information is disabled in serverless; refer to the serverless.yml file as the source of truth
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
serverless: schema.boolean({ defaultValue: true }),
}),
editableIndexSettings: offeringBasedSchema({
// on serverless only a limited set of index settings can be edited
serverless: schema.oneOf([schema.literal('all'), schema.literal('limited')], {
defaultValue: 'all',
}),
}),
enableDataStreamsStorageColumn: offeringBasedSchema({
// The Storage size column in Data streams is disabled in serverless; refer to the serverless.yml file as the source of truth
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
serverless: schema.boolean({ defaultValue: true }),
}),
enableMappingsSourceFieldSection: offeringBasedSchema({
// The _source field in the Mappings editor's advanced options form is disabled in serverless; refer to the serverless.yml file as the source of truth
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
@ -77,8 +77,8 @@ const configLatest: PluginConfigDescriptor<IndexManagementConfig> = {
enableIndexActions: true,
enableLegacyTemplates: true,
enableIndexStats: true,
enableDataStreamStats: true,
editableIndexSettings: true,
enableDataStreamsStorageColumn: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
},

View file

@ -56,7 +56,7 @@ export class IndexMgmtServerPlugin implements Plugin<IndexManagementPluginSetup,
isSecurityEnabled: () => security !== undefined && security.license.isEnabled(),
isLegacyTemplatesEnabled: this.config.enableLegacyTemplates,
isIndexStatsEnabled: this.config.enableIndexStats,
isDataStreamsStorageColumnEnabled: this.config.enableDataStreamsStorageColumn,
isDataStreamStatsEnabled: this.config.enableDataStreamStats,
enableMappingsSourceFieldSection: this.config.enableMappingsSourceFieldSection,
enableTogglingDataRetention: this.config.enableTogglingDataRetention,
},

View file

@ -48,7 +48,7 @@ describe('GET privileges', () => {
isSecurityEnabled: () => true,
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
},
@ -119,7 +119,7 @@ describe('GET privileges', () => {
isSecurityEnabled: () => false,
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
},

View file

@ -100,7 +100,7 @@ export function registerGetAllRoute({ router, lib: { handleEsError }, config }:
let dataStreamsStats;
let dataStreamsPrivileges;
if (includeStats) {
if (includeStats && config.isDataStreamStatsEnabled !== false) {
({ data_streams: dataStreamsStats } = await getDataStreamsStats(client));
}
@ -137,9 +137,14 @@ export function registerGetOneRoute({ router, lib: { handleEsError }, config }:
async (context, request, response) => {
const { name } = request.params as TypeOf<typeof paramsSchema>;
const { client } = (await context.core).elasticsearch;
let dataStreamsStats;
try {
const [{ data_streams: dataStreams }, { data_streams: dataStreamsStats }] =
await Promise.all([getDataStreams(client, name), getDataStreamsStats(client, name)]);
const { data_streams: dataStreams } = await getDataStreams(client, name);
if (config.isDataStreamStatsEnabled !== false) {
({ data_streams: dataStreamsStats } = await getDataStreamsStats(client, name));
}
if (dataStreams[0]) {
let dataStreamsPrivileges;

View file

@ -48,7 +48,7 @@ describe('GET privileges', () => {
isSecurityEnabled: () => true,
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
},
@ -119,7 +119,7 @@ describe('GET privileges', () => {
isSecurityEnabled: () => false,
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
},

View file

@ -14,7 +14,7 @@ export const routeDependencies: Omit<RouteDependencies, 'router'> = {
isSecurityEnabled: jest.fn().mockReturnValue(true),
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isDataStreamsStorageColumnEnabled: true,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
},

View file

@ -25,7 +25,7 @@ export interface RouteDependencies {
isSecurityEnabled: () => boolean;
isLegacyTemplatesEnabled: boolean;
isIndexStatsEnabled: boolean;
isDataStreamsStorageColumnEnabled: boolean;
isDataStreamStatsEnabled: boolean;
enableMappingsSourceFieldSection: boolean;
enableTogglingDataRetention: boolean;
};

View file

@ -88,53 +88,6 @@ export default function ({ getService }: FtrProviderContext) {
});
});
it('includes stats when provided the includeStats query parameter', async () => {
const { body: dataStreams } = await supertest
.get(`${API_BASE_PATH}/data_streams?includeStats=true`)
.set('kbn-xsrf', 'xxx')
.set('x-elastic-internal-origin', 'xxx')
.expect(200);
expect(dataStreams).to.be.an('array');
// returned array can contain automatically created data streams
const testDataStream = dataStreams.find(
(dataStream: DataStream) => dataStream.name === testDataStreamName
);
expect(testDataStream).to.be.ok();
// ES determines these values so we'll just echo them back.
const { name: indexName, uuid } = testDataStream!.indices[0];
const { storageSize, storageSizeBytes, ...dataStreamWithoutStorageSize } = testDataStream!;
expect(dataStreamWithoutStorageSize).to.eql({
name: testDataStreamName,
privileges: {
delete_index: true,
manage_data_stream_lifecycle: true,
},
timeStampField: { name: '@timestamp' },
indices: [
{
name: indexName,
managedBy: 'Data stream lifecycle',
preferILM: true,
uuid,
},
],
generation: 1,
health: 'green',
indexTemplateName: testDataStreamName,
nextGenerationManagedBy: 'Data stream lifecycle',
maxTimeStamp: 0,
hidden: false,
lifecycle: {
enabled: true,
},
});
});
it('returns a single data stream by ID', async () => {
const { body: dataStream } = await supertest
.get(`${API_BASE_PATH}/data_streams/${testDataStreamName}`)
@ -165,7 +118,6 @@ export default function ({ getService }: FtrProviderContext) {
health: 'green',
indexTemplateName: testDataStreamName,
nextGenerationManagedBy: 'Data stream lifecycle',
maxTimeStamp: 0,
hidden: false,
lifecycle: {
enabled: true,

View file

@ -89,12 +89,9 @@ export default function ({ getService }: FtrProviderContext) {
},
],
lifecycle: { enabled: true },
maxTimeStamp: 0,
nextGenerationManagedBy: 'Data stream lifecycle',
privileges: { delete_index: true, manage_data_stream_lifecycle: true },
timeStampField: { name: '@timestamp' },
storageSize: expect.any(String),
storageSizeBytes: expect.any(Number),
});
});
});