diff --git a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts index c6ab285863978..b20d0a7c3f3bd 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts @@ -538,6 +538,10 @@ export const stackManagementSchema: MakeSchemaFrom = { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, }, + 'observability:enableInfrastructureHostsView': { + type: 'boolean', + _meta: { description: 'Non-default value of setting.' }, + }, 'securitySolution:enableGroupedNav': { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, diff --git a/src/plugins/kibana_usage_collection/server/collectors/management/types.ts b/src/plugins/kibana_usage_collection/server/collectors/management/types.ts index b37fd8b824816..f6aaf1258c818 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/types.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/types.ts @@ -42,6 +42,7 @@ export interface UsageStats { 'observability:maxSuggestions': number; 'observability:enableComparisonByDefault': boolean; 'observability:enableServiceGroups': boolean; + 'observability:enableInfrastructureHostsView': boolean; 'visualize:enableLabs': boolean; 'visualization:heatmap:maxBuckets': number; 'visualization:colorMapping': string; diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index 4a1840f99c0a0..5d962699345b0 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -8810,6 +8810,12 @@ "description": "Non-default value of setting." } }, + "observability:enableInfrastructureHostsView": { + "type": "boolean", + "_meta": { + "description": "Non-default value of setting." + } + }, "securitySolution:enableGroupedNav": { "type": "boolean", "_meta": { diff --git a/x-pack/plugins/infra/public/plugin.ts b/x-pack/plugins/infra/public/plugin.ts index f02ffcb5167f3..6eb6663b10eeb 100644 --- a/x-pack/plugins/infra/public/plugin.ts +++ b/x-pack/plugins/infra/public/plugin.ts @@ -10,6 +10,7 @@ import { AppMountParameters, PluginInitializerContext } from '@kbn/core/public'; import { from } from 'rxjs'; import { map } from 'rxjs/operators'; import { DEFAULT_APP_CATEGORIES } from '@kbn/core/public'; +import { enableInfrastructureHostsView } from '@kbn/observability-plugin/public'; import { defaultLogViewsStaticConfig } from '../common/log_views'; import { InfraPublicConfig } from '../common/plugin_config_types'; import { createInventoryMetricRuleType } from './alerting/inventory'; @@ -74,6 +75,11 @@ export class Plugin implements InfraClientPluginClass { }); /** !! Need to be kept in sync with the deepLinks in x-pack/plugins/infra/public/plugin.ts */ + const infraEntries = [ + { label: 'Inventory', app: 'metrics', path: '/inventory' }, + { label: 'Metrics Explorer', app: 'metrics', path: '/explorer' }, + ]; + const hostInfraEntry = { label: 'Hosts', app: 'metrics', path: '/hosts' }; pluginsSetup.observability.navigation.registerSections( from(core.getStartServices()).pipe( map( @@ -100,11 +106,9 @@ export class Plugin implements InfraClientPluginClass { { label: 'Infrastructure', sortKey: 300, - entries: [ - { label: 'Hosts', app: 'metrics', path: '/hosts' }, - { label: 'Inventory', app: 'metrics', path: '/inventory' }, - { label: 'Metrics Explorer', app: 'metrics', path: '/explorer' }, - ], + entries: core.uiSettings.get(enableInfrastructureHostsView) + ? [hostInfraEntry, ...infraEntries] + : infraEntries, }, ] : []), @@ -167,6 +171,36 @@ export class Plugin implements InfraClientPluginClass { }, }); + const infraDeepLinks = [ + { + id: 'inventory', + title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', { + defaultMessage: 'Inventory', + }), + path: '/inventory', + }, + { + id: 'metrics-explorer', + title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', { + defaultMessage: 'Metrics Explorer', + }), + path: '/explorer', + }, + { + id: 'settings', + title: i18n.translate('xpack.infra.homePage.settingsTabTitle', { + defaultMessage: 'Settings', + }), + path: '/settings', + }, + ]; + const hostInfraDeepLink = { + id: 'metrics-hosts', + title: i18n.translate('xpack.infra.homePage.metricsHostsTabTitle', { + defaultMessage: 'Hosts', + }), + path: '/hosts', + }; core.application.register({ id: 'metrics', title: i18n.translate('xpack.infra.metrics.pluginTitle', { @@ -177,36 +211,9 @@ export class Plugin implements InfraClientPluginClass { appRoute: '/app/metrics', category: DEFAULT_APP_CATEGORIES.observability, // !! Need to be kept in sync with the routes in x-pack/plugins/infra/public/pages/metrics/index.tsx - deepLinks: [ - { - id: 'inventory', - title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', { - defaultMessage: 'Inventory', - }), - path: '/inventory', - }, - { - id: 'metrics-explorer', - title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', { - defaultMessage: 'Metrics Explorer', - }), - path: '/explorer', - }, - { - id: 'metrics-hosts', - title: i18n.translate('xpack.infra.homePage.metricsHostsTabTitle', { - defaultMessage: 'Hosts', - }), - path: '/hosts', - }, - { - id: 'settings', - title: i18n.translate('xpack.infra.homePage.settingsTabTitle', { - defaultMessage: 'Settings', - }), - path: '/settings', - }, - ], + deepLinks: core.uiSettings.get(enableInfrastructureHostsView) + ? [hostInfraDeepLink, ...infraDeepLinks] + : infraDeepLinks, mount: async (params: AppMountParameters) => { // mount callback should not use setup dependencies, get start dependencies instead const [coreStart, pluginsStart, pluginStart] = await core.getStartServices(); diff --git a/x-pack/plugins/observability/common/index.ts b/x-pack/plugins/observability/common/index.ts index 6bbc6006f7c0c..78262d806bb46 100644 --- a/x-pack/plugins/observability/common/index.ts +++ b/x-pack/plugins/observability/common/index.ts @@ -24,6 +24,7 @@ export { apmTraceExplorerTab, apmOperationsTab, apmLabsButton, + enableInfrastructureHostsView, } from './ui_settings_keys'; export { diff --git a/x-pack/plugins/observability/common/ui_settings_keys.ts b/x-pack/plugins/observability/common/ui_settings_keys.ts index e8550cb39a1aa..d413cd5d79d13 100644 --- a/x-pack/plugins/observability/common/ui_settings_keys.ts +++ b/x-pack/plugins/observability/common/ui_settings_keys.ts @@ -19,3 +19,4 @@ export const apmServiceGroupMaxNumberOfServices = export const apmTraceExplorerTab = 'observability:apmTraceExplorerTab'; export const apmOperationsTab = 'observability:apmOperationsTab'; export const apmLabsButton = 'observability:apmLabsButton'; +export const enableInfrastructureHostsView = 'observability:enableInfrastructureHostsView'; diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index 3b5d34e87df75..9bc1eb7f2a172 100644 --- a/x-pack/plugins/observability/public/index.ts +++ b/x-pack/plugins/observability/public/index.ts @@ -30,6 +30,7 @@ export { enableServiceGroups, enableNewSyntheticsView, apmServiceGroupMaxNumberOfServices, + enableInfrastructureHostsView, } from '../common/ui_settings_keys'; export { uptimeOverviewLocatorID } from '../common'; diff --git a/x-pack/plugins/observability/server/ui_settings.ts b/x-pack/plugins/observability/server/ui_settings.ts index e5c58753e244c..6775a7cf51029 100644 --- a/x-pack/plugins/observability/server/ui_settings.ts +++ b/x-pack/plugins/observability/server/ui_settings.ts @@ -22,6 +22,7 @@ import { apmTraceExplorerTab, apmOperationsTab, apmLabsButton, + enableInfrastructureHostsView, } from '../common/ui_settings_keys'; const technicalPreviewLabel = i18n.translate( @@ -242,4 +243,15 @@ export const uiSettings: Record = { requiresPageReload: true, type: 'boolean', }, + [enableInfrastructureHostsView]: { + category: [observabilityFeatureId], + name: i18n.translate('xpack.observability.enableInfrastructureHostsView', { + defaultMessage: 'Infrastructure Hosts view', + }), + value: false, + description: i18n.translate('xpack.observability.enableInfrastructureHostsViewDescription', { + defaultMessage: 'Enable the Hosts view in the Infrastructure app', + }), + schema: schema.boolean(), + }, };