From 8d49631cd7e34ce4fa8517c36f767903de369fff Mon Sep 17 00:00:00 2001 From: neptunian Date: Wed, 14 Sep 2022 15:45:11 -0400 Subject: [PATCH] add tech preview for hosts view --- .../server/collectors/management/schema.ts | 4 + .../server/collectors/management/types.ts | 1 + x-pack/plugins/infra/public/plugin.ts | 77 ++++++++++--------- x-pack/plugins/observability/common/index.ts | 1 + .../observability/common/ui_settings_keys.ts | 1 + x-pack/plugins/observability/public/index.ts | 1 + .../observability/server/ui_settings.ts | 12 +++ 7 files changed, 62 insertions(+), 35 deletions(-) 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 538cc9e66d145..f77eaed0ea32f 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts @@ -530,6 +530,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 0033765eb44db..d4407ae0cac4e 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/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 379404c3a48a1..388ee15b81e6f 100644 --- a/x-pack/plugins/observability/common/index.ts +++ b/x-pack/plugins/observability/common/index.ts @@ -21,6 +21,7 @@ export { apmServiceGroupMaxNumberOfServices, apmTraceExplorerTab, apmOperationsTab, + 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 f3c77c76d4186..18e86eeb55942 100644 --- a/x-pack/plugins/observability/common/ui_settings_keys.ts +++ b/x-pack/plugins/observability/common/ui_settings_keys.ts @@ -18,3 +18,4 @@ export const apmServiceGroupMaxNumberOfServices = 'observability:apmServiceGroupMaxNumberOfServices'; export const apmTraceExplorerTab = 'observability:apmTraceExplorerTab'; export const apmOperationsTab = 'observability:apmOperationsTab'; +export const enableInfrastructureHostsView = 'observability:enableInfrastructureHostsView'; diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index b4e23ce0e83ad..43dead397d7d0 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 f22da4b96e6b9..5c5db892d66a0 100644 --- a/x-pack/plugins/observability/server/ui_settings.ts +++ b/x-pack/plugins/observability/server/ui_settings.ts @@ -21,6 +21,7 @@ import { apmServiceGroupMaxNumberOfServices, apmTraceExplorerTab, apmOperationsTab, + enableInfrastructureHostsView, } from '../common/ui_settings_keys'; const technicalPreviewLabel = i18n.translate( @@ -220,4 +221,15 @@ export const uiSettings: Record