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

Enable stream stats in serverless #197038

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ xpack.index_management.enableLegacyTemplates: false
xpack.index_management.enableIndexStats: false
# Enable size and doc count information via metering API from Index Management UI
xpack.index_management.enableSizeAndDocCount: true
# 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 _source field in the Mappings editor's advanced options form from Index Management UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.index_management.enableIndexActions (boolean?|never)',
'xpack.index_management.enableLegacyTemplates (boolean?|never)',
'xpack.index_management.enableIndexStats (boolean?|never)',
'xpack.index_management.enableDataStreamStats (boolean?|never)',
'xpack.index_management.enableSizeAndDocCount (boolean?|never)',
'xpack.index_management.editableIndexSettings (all?|limited?|never)',
'xpack.index_management.enableMappingsSourceFieldSection (boolean?|never)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ const appDependencies = {
enableLegacyTemplates: true,
enableIndexActions: true,
enableIndexStats: true,
enableDataStreamStats: true,
editableIndexSettings: 'all',
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,29 +312,10 @@ describe('Data Streams tab', () => {
actions.sortTableOnName();
});

test(`doesn't hide stats toggle if enableDataStreamStats===false`, async () => {
testBed = await setup(httpSetup, {
config: {
enableDataStreamStats: false,
},
});

const { actions, component, exists } = testBed;

await act(async () => {
actions.goToDataStreamsList();
});

component.update();

expect(exists('includeStatsSwitch')).toBeTruthy();
});

test('shows storage size and documents count if enableSizeAndDocCount===true, enableDataStreamStats==false', async () => {
test('shows storage size, documents count, last updated and storage size if enableSizeAndDocCount===true', async () => {
testBed = await setup(httpSetup, {
config: {
enableSizeAndDocCount: true,
enableDataStreamStats: false,
},
});

Expand All @@ -350,15 +331,38 @@ describe('Data Streams tab', () => {

const { tableCellsValues } = table.getMetaData('dataStreamTable');
expect(tableCellsValues).toEqual([
['', 'dataStream1', 'green', '156kb', '10000', '1', 'Standard', '7 days', 'Delete'],
['', 'dataStream2', 'green', '156kb', '10000', '1', 'Standard', '5 days ', 'Delete'],
[
'',
'dataStream1',
'green',
'156kb',
'10000',
'December 31st, 1969 7:00:00 PM',
'5b',
'1',
'Standard',
'7 days',
'Delete',
],
[
'',
'dataStream2',
'green',
'156kb',
'10000',
'December 31st, 1969 7:00:00 PM',
'1kb',
'1',
'Standard',
'5 days ',
'Delete',
],
]);
});

test('shows last updated and storage size if enableDataStreamStats===true, enableSizeAndDocCount===false', async () => {
test('shows last updated and storage size if enableSizeAndDocCount===false', async () => {
testBed = await setup(httpSetup, {
config: {
enableDataStreamStats: true,
enableSizeAndDocCount: false,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export interface AppDependencies {
enableLegacyTemplates: boolean;
enableIndexStats: boolean;
enableSizeAndDocCount: boolean;
enableDataStreamStats: boolean;
editableIndexSettings: 'all' | 'limited';
enableMappingsSourceFieldSection: boolean;
enableTogglingDataRetention: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,38 +265,37 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
}
);
}
if (config.enableDataStreamStats) {
defaultDetails.push(
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.maxTimeStampTitle', {
defaultMessage: 'Last updated',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.maxTimeStampToolTip', {
defaultMessage: 'The most recent document to be added to the data stream.',
}),
content: maxTimeStamp ? (
humanizeTimeStamp(maxTimeStamp)
) : (
<em>
{i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.maxTimeStampNoneMessage', {
defaultMessage: `Never`,
})}
</em>
),
dataTestSubj: 'lastUpdatedDetail',
},
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.storageSizeTitle', {
defaultMessage: 'Storage size',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.storageSizeToolTip', {
defaultMessage: `The total size of all shards in the data stream’s backing indices.`,
}),
content: storageSize,
dataTestSubj: 'storageSizeDetail',
}
);
}

defaultDetails.push(
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.maxTimeStampTitle', {
defaultMessage: 'Last updated',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.maxTimeStampToolTip', {
defaultMessage: 'The most recent document to be added to the data stream.',
}),
content: maxTimeStamp ? (
humanizeTimeStamp(maxTimeStamp)
) : (
<em>
{i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.maxTimeStampNoneMessage', {
defaultMessage: `Never`,
})}
</em>
),
dataTestSubj: 'lastUpdatedDetail',
},
{
name: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.storageSizeTitle', {
defaultMessage: 'Storage size',
}),
toolTip: i18n.translate('xpack.idxMgmt.dataStreamDetailPanel.storageSizeToolTip', {
defaultMessage: `The total size of all shards in the data stream’s backing indices.`,
}),
content: storageSize,
dataTestSubj: 'storageSizeDetail',
}
);

defaultDetails.push(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,30 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({
sortable: true,
});
}
if (config.enableDataStreamStats) {
columns.push({
field: 'maxTimeStamp',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.maxTimeStampColumnTitle', {
defaultMessage: 'Last updated',
}),
truncateText: true,
sortable: true,
render: (maxTimeStamp: DataStream['maxTimeStamp']) =>
maxTimeStamp
? humanizeTimeStamp(maxTimeStamp)
: i18n.translate('xpack.idxMgmt.dataStreamList.table.maxTimeStampColumnNoneMessage', {
defaultMessage: 'Never',
}),
});
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: 'maxTimeStamp',
name: i18n.translate('xpack.idxMgmt.dataStreamList.table.maxTimeStampColumnTitle', {
defaultMessage: 'Last updated',
}),
truncateText: true,
sortable: true,
render: (maxTimeStamp: DataStream['maxTimeStamp']) =>
maxTimeStamp
? humanizeTimeStamp(maxTimeStamp)
: i18n.translate('xpack.idxMgmt.dataStreamList.table.maxTimeStampColumnNoneMessage', {
defaultMessage: 'Never',
}),
});
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({
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/index_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export class IndexMgmtUIPlugin
enableIndexActions: boolean;
enableLegacyTemplates: boolean;
enableIndexStats: boolean;
enableDataStreamStats: boolean;
enableSizeAndDocCount: boolean;
editableIndexSettings: 'all' | 'limited';
isIndexManagementUiEnabled: boolean;
Expand All @@ -68,7 +67,6 @@ export class IndexMgmtUIPlugin
enableIndexActions,
enableLegacyTemplates,
enableIndexStats,
enableDataStreamStats,
enableSizeAndDocCount,
editableIndexSettings,
enableMappingsSourceFieldSection,
Expand All @@ -81,7 +79,6 @@ export class IndexMgmtUIPlugin
enableIndexActions: enableIndexActions ?? true,
enableLegacyTemplates: enableLegacyTemplates ?? true,
enableIndexStats: enableIndexStats ?? true,
enableDataStreamStats: enableDataStreamStats ?? true,
enableSizeAndDocCount: enableSizeAndDocCount ?? false,
editableIndexSettings: editableIndexSettings ?? 'all',
enableMappingsSourceFieldSection: enableMappingsSourceFieldSection ?? true,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/index_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export interface ClientConfigType {
enableLegacyTemplates?: boolean;
enableIndexStats?: boolean;
enableSizeAndDocCount?: boolean;
enableDataStreamStats?: boolean;
editableIndexSettings?: 'all' | 'limited';
enableMappingsSourceFieldSection?: boolean;
enableTogglingDataRetention?: boolean;
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/index_management/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ 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')], {
Expand Down Expand Up @@ -87,7 +82,6 @@ const configLatest: PluginConfigDescriptor<IndexManagementConfig> = {
enableIndexActions: true,
enableLegacyTemplates: true,
enableIndexStats: true,
enableDataStreamStats: true,
enableSizeAndDocCount: true,
editableIndexSettings: true,
enableMappingsSourceFieldSection: true,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/index_management/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export class IndexMgmtServerPlugin implements Plugin<IndexManagementPluginSetup,
isIndexStatsEnabled: this.config.enableIndexStats ?? true,
isSizeAndDocCountEnabled: this.config.enableSizeAndDocCount ?? false,
enableProjectLevelRetentionChecks: this.config.enableProjectLevelRetentionChecks ?? false,
isDataStreamStatsEnabled: this.config.enableDataStreamStats,
enableMappingsSourceFieldSection: this.config.enableMappingsSourceFieldSection,
enableTogglingDataRetention: this.config.enableTogglingDataRetention,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('GET privileges', () => {
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isSizeAndDocCountEnabled: false,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
enableProjectLevelRetentionChecks: false,
Expand Down Expand Up @@ -122,7 +121,6 @@ describe('GET privileges', () => {
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isSizeAndDocCountEnabled: false,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
enableProjectLevelRetentionChecks: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ const enhanceDataStreams = ({
};

const getDataStreams = (client: IScopedClusterClient, name = '*') => {
return client.asCurrentUser.indices.getDataStream({
name,
expand_wildcards: 'all',
// TODO: Replace this request with the one below when the JS client is updated to 8.16
return client.asCurrentUser.transport.request({
method: 'GET',
path: `/_data_stream/${name}?expand_wildcards=all&verbose=true`,
});

// return client.asCurrentUser.indices.getDataStream({
// name,
// expand_wildcards: 'all',
// verbose: true,
// });
};

const getDataStreamLifecycle = (client: IScopedClusterClient, name: string) => {
Expand All @@ -101,14 +108,6 @@ const getDataStreamLifecycle = (client: IScopedClusterClient, name: string) => {
});
};

const getDataStreamsStats = (client: IScopedClusterClient, name = '*') => {
return client.asCurrentUser.indices.dataStreamsStats({
name,
expand_wildcards: 'all',
human: true,
});
};

const getMeteringStats = (client: IScopedClusterClient, name?: string) => {
let path = `/_metering/stats`;
if (name) {
Expand Down Expand Up @@ -151,9 +150,6 @@ export function registerGetAllRoute({ router, lib: { handleEsError }, config }:
let dataStreamsPrivileges;
let meteringStats;

if (includeStats && config.isDataStreamStatsEnabled !== false) {
({ data_streams: dataStreamsStats } = await getDataStreamsStats(client));
}
if (includeStats && config.isSizeAndDocCountEnabled !== false) {
({ datastreams: meteringStats } = await getMeteringStats(client));
}
Expand Down Expand Up @@ -206,10 +202,6 @@ export function registerGetOneRoute({ router, lib: { handleEsError }, config }:
// @ts-ignore - TS doesn't know about the `global_retention` property yet
const globalMaxRetention = lifecycle?.global_retention?.max_retention;

if (config.isDataStreamStatsEnabled !== false) {
({ data_streams: dataStreamsStats } = await getDataStreamsStats(client, name));
}

if (config.isSizeAndDocCountEnabled !== false) {
({ datastreams: meteringStats } = await getMeteringStats(client, name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('GET privileges', () => {
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isSizeAndDocCountEnabled: false,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
enableProjectLevelRetentionChecks: false,
Expand Down Expand Up @@ -122,7 +121,6 @@ describe('GET privileges', () => {
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isSizeAndDocCountEnabled: false,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
enableProjectLevelRetentionChecks: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const routeDependencies: Omit<RouteDependencies, 'router'> = {
isLegacyTemplatesEnabled: true,
isIndexStatsEnabled: true,
isSizeAndDocCountEnabled: false,
isDataStreamStatsEnabled: true,
enableMappingsSourceFieldSection: true,
enableTogglingDataRetention: true,
enableProjectLevelRetentionChecks: false,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/index_management/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface RouteDependencies {
isLegacyTemplatesEnabled: boolean;
isIndexStatsEnabled: boolean;
isSizeAndDocCountEnabled: boolean;
isDataStreamStatsEnabled: boolean;
enableMappingsSourceFieldSection: boolean;
enableTogglingDataRetention: boolean;
enableProjectLevelRetentionChecks: boolean;
Expand Down
Loading