From 2a32915daa3292dcc5bef6d25afd50763978a98b Mon Sep 17 00:00:00 2001 From: iblancof Date: Tue, 15 Oct 2024 15:33:28 +0200 Subject: [PATCH 01/18] Create useEntityManager --- .../observability_solution/apm/kibana.jsonc | 3 ++- .../apm/public/hooks/use_entity_manager.ts | 23 +++++++++++++++++++ .../apm/public/plugin.ts | 2 ++ .../observability_solution/apm/tsconfig.json | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/observability_solution/apm/public/hooks/use_entity_manager.ts diff --git a/x-pack/plugins/observability_solution/apm/kibana.jsonc b/x-pack/plugins/observability_solution/apm/kibana.jsonc index e12b22a43d60..0e305bc449c0 100644 --- a/x-pack/plugins/observability_solution/apm/kibana.jsonc +++ b/x-pack/plugins/observability_solution/apm/kibana.jsonc @@ -30,7 +30,8 @@ "lens", "maps", "uiActions", - "logsDataAccess" + "logsDataAccess", + "entityManager" ], "optionalPlugins": [ "actions", diff --git a/x-pack/plugins/observability_solution/apm/public/hooks/use_entity_manager.ts b/x-pack/plugins/observability_solution/apm/public/hooks/use_entity_manager.ts new file mode 100644 index 000000000000..b8f90bc673f8 --- /dev/null +++ b/x-pack/plugins/observability_solution/apm/public/hooks/use_entity_manager.ts @@ -0,0 +1,23 @@ +/* + * 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 { useAbortableAsync } from '@kbn/observability-utils/hooks/use_abortable_async'; +import { useKibana } from '../context/kibana_context/use_kibana'; + +export const useEntityManager = () => { + const { + services: { entityManager }, + } = useKibana(); + + const { value = { enabled: false } } = useAbortableAsync(() => { + return entityManager.entityClient.isManagedEntityDiscoveryEnabled(); + }, [entityManager]); + + return { + isEntityManagerEnabled: value.enabled, + }; +}; diff --git a/x-pack/plugins/observability_solution/apm/public/plugin.ts b/x-pack/plugins/observability_solution/apm/public/plugin.ts index b21bdedac9ef..8b267bf0b03d 100644 --- a/x-pack/plugins/observability_solution/apm/public/plugin.ts +++ b/x-pack/plugins/observability_solution/apm/public/plugin.ts @@ -70,6 +70,7 @@ import { map } from 'rxjs'; import type { CloudSetup } from '@kbn/cloud-plugin/public'; import type { ServerlessPluginStart } from '@kbn/serverless/public'; import { LogsSharedClientStartExports } from '@kbn/logs-shared-plugin/public'; +import { EntityManagerPublicPluginStart } from '@kbn/entityManager-plugin/public'; import type { ConfigSchema } from '.'; import { registerApmRuleTypes } from './components/alerting/rule_types/register_apm_rule_types'; import { registerEmbeddables } from './embeddable/register_embeddables'; @@ -144,6 +145,7 @@ export interface ApmPluginStartDeps { metricsDataAccess: MetricsDataPluginStart; uiSettings: IUiSettingsClient; logsShared: LogsSharedClientStartExports; + entityManager: EntityManagerPublicPluginStart; } const applicationsTitle = i18n.translate('xpack.apm.navigation.rootTitle', { diff --git a/x-pack/plugins/observability_solution/apm/tsconfig.json b/x-pack/plugins/observability_solution/apm/tsconfig.json index 0f08bf3143cd..47ab49953451 100644 --- a/x-pack/plugins/observability_solution/apm/tsconfig.json +++ b/x-pack/plugins/observability_solution/apm/tsconfig.json @@ -128,6 +128,7 @@ "@kbn/router-utils", "@kbn/react-hooks", "@kbn/alerting-comparators", + "@kbn/entityManager-plugin" ], "exclude": ["target/**/*"] } From 2344dca7ed6392f21ab4b2f47ab436809e43eac7 Mon Sep 17 00:00:00 2001 From: iblancof Date: Tue, 15 Oct 2024 15:35:53 +0200 Subject: [PATCH 02/18] Hide noDataConfig when logs are present and EEM is enabled --- .../templates/apm_main_template/index.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx index f4ef2044a38c..c9301016b83f 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx @@ -13,6 +13,9 @@ import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-templat import React, { useContext } from 'react'; import { useLocation } from 'react-router-dom'; import { FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; +import { useEntityManager } from '../../../../hooks/use_entity_manager'; +import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; +import { isLogsSignal } from '../../../../utils/get_signal_type'; import { useLocalStorage } from '../../../../hooks/use_local_storage'; import { useDefaultAiAssistantStarterPromptsForAPM } from '../../../../hooks/use_default_ai_assistant_starter_prompts_for_apm'; import { KibanaEnvironmentContext } from '../../../../context/kibana_environment_context/kibana_environment_context'; @@ -76,8 +79,9 @@ export function ApmMainTemplate({ entityCentricExperience, true ); - + const { serviceEntitySummary } = useApmServiceContext(); const { isEntityCentricExperienceEnabled } = useEntityCentricExperienceSetting(); + const { isEntityManagerEnabled } = useEntityManager(); const ObservabilityPageTemplate = observabilityShared.navigation.PageTemplate; @@ -101,6 +105,8 @@ export function ApmMainTemplate({ location.pathname.includes(path) ); + const isEntityExperienceFullyEnabled = isEntityCentricExperienceEnabled && isEntityManagerEnabled; + const { data: fleetApmPoliciesData, status: fleetApmPoliciesStatus } = useFetcher( (callApmApi) => { if (!data?.hasData && !shouldBypassNoDataScreen) { @@ -114,6 +120,10 @@ export function ApmMainTemplate({ status === FETCH_STATUS.LOADING || fleetApmPoliciesStatus === FETCH_STATUS.LOADING; const hasApmData = !!data?.hasData; + const hasLogsData = + serviceEntitySummary?.dataStreamTypes && + serviceEntitySummary?.dataStreamTypes?.length > 0 && + isLogsSignal(serviceEntitySummary.dataStreamTypes); const hasApmIntegrations = !!fleetApmPoliciesData?.hasApmPolicies; const noDataConfig = getNoDataConfig({ @@ -164,7 +174,11 @@ export function ApmMainTemplate({ return ( Date: Tue, 15 Oct 2024 15:37:24 +0200 Subject: [PATCH 03/18] Remove duplicated EEM setting const --- .../routing/templates/apm_main_template/index.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx index c9301016b83f..1e0c656145b6 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx @@ -7,7 +7,6 @@ import { EuiFlexGroup, EuiPageHeaderProps } from '@elastic/eui'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { entityCentricExperience } from '@kbn/observability-plugin/common'; import { ObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public'; import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template'; import React, { useContext } from 'react'; @@ -74,11 +73,7 @@ export function ApmMainTemplate({ const { http, docLinks, observabilityShared, application } = services; const { kibanaVersion, isCloudEnv, isServerlessEnv } = kibanaEnvironment; const basePath = http?.basePath.get(); - const { config, core } = useApmPluginContext(); - const isEntityCentricExperienceSettingEnabled = core.uiSettings.get( - entityCentricExperience, - true - ); + const { config } = useApmPluginContext(); const { serviceEntitySummary } = useApmServiceContext(); const { isEntityCentricExperienceEnabled } = useEntityCentricExperienceSetting(); const { isEntityManagerEnabled } = useEntityManager(); @@ -168,7 +163,7 @@ export function ApmMainTemplate({ const showEntitiesInventoryCallout = !dismissedEntitiesInventoryCallout && - isEntityCentricExperienceSettingEnabled && + isEntityCentricExperienceEnabled && selectedNavButton !== undefined; return ( From e77cb124367ce81eee29cdcb1e56c72b84eab660 Mon Sep 17 00:00:00 2001 From: iblancof Date: Tue, 15 Oct 2024 18:08:35 +0200 Subject: [PATCH 04/18] Create useEntityCentricExperienceSetting --- .../use_entity_centric_experience_setting.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 x-pack/plugins/observability_solution/infra/public/hooks/use_entity_centric_experience_setting.tsx diff --git a/x-pack/plugins/observability_solution/infra/public/hooks/use_entity_centric_experience_setting.tsx b/x-pack/plugins/observability_solution/infra/public/hooks/use_entity_centric_experience_setting.tsx new file mode 100644 index 000000000000..1cbc4680405e --- /dev/null +++ b/x-pack/plugins/observability_solution/infra/public/hooks/use_entity_centric_experience_setting.tsx @@ -0,0 +1,17 @@ +/* + * 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 { entityCentricExperience } from '@kbn/observability-plugin/common'; +import { useKibanaContextForPlugin } from './use_kibana'; + +export function useEntityCentricExperienceSetting() { + const { uiSettings } = useKibanaContextForPlugin().services; + + const isEntityCentricExperienceEnabled = uiSettings.get(entityCentricExperience, true); + + return { isEntityCentricExperienceEnabled }; +} From ac3580cb34d9083665d30552039a7f6b0593ddc5 Mon Sep 17 00:00:00 2001 From: iblancof Date: Tue, 15 Oct 2024 18:10:34 +0200 Subject: [PATCH 05/18] Create isLogsSignal --- .../components/asset_details/utils/get_data_stream_types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/utils/get_data_stream_types.ts b/x-pack/plugins/observability_solution/infra/public/components/asset_details/utils/get_data_stream_types.ts index 899fd164c8e0..fd12a4352f12 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/utils/get_data_stream_types.ts +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/utils/get_data_stream_types.ts @@ -10,3 +10,7 @@ import { EntityDataStreamType } from '@kbn/observability-shared-plugin/common'; export function isMetricsSignal(dataStreamTypes: EntityDataStreamType[] = []) { return dataStreamTypes?.includes(EntityDataStreamType.METRICS); } + +export function isLogsSignal(dataStreamTypes: EntityDataStreamType[] = []) { + return dataStreamTypes?.includes(EntityDataStreamType.LOGS); +} From 1a9512fd38eb195fed9e68659c13f81c207196c8 Mon Sep 17 00:00:00 2001 From: iblancof Date: Tue, 15 Oct 2024 18:11:53 +0200 Subject: [PATCH 06/18] Hide noDataConfig when logs are present and EEM is enabled --- .../shared/templates/infra_page_template.tsx | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx index a20c32b42b7d..3747fed52278 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public'; import React, { useEffect } from 'react'; +import { useEntityCentricExperienceSetting } from '../../../hooks/use_entity_centric_experience_setting'; import { GetHasDataResponse } from '../../../../common/metrics_sources/get_has_data'; import { NoRemoteCluster } from '../../empty_states'; import { SourceErrorPage } from '../../source_error_page'; @@ -16,6 +17,9 @@ import { useKibanaContextForPlugin } from '../../../hooks/use_kibana'; import { ErrorCallout } from '../../error_callout'; import { isPending, useFetcher } from '../../../hooks/use_fetcher'; import { OnboardingFlow, getNoDataConfig } from './no_data_config'; +import { useAssetDetailsRenderPropsContext } from '../../asset_details/hooks/use_asset_details_render_props'; +import { useEntitySummary } from '../../asset_details/hooks/use_entity_summary'; +import { isLogsSignal } from '../../asset_details/utils/get_data_stream_types'; export const InfraPageTemplate = ({ 'data-test-subj': _dataTestSubj, @@ -50,7 +54,15 @@ export const InfraPageTemplate = ({ }); }); + const { isEntityCentricExperienceEnabled } = useEntityCentricExperienceSetting(); + const { asset } = useAssetDetailsRenderPropsContext(); + const { dataStreams, status: entitySummaryStatus } = useEntitySummary({ + entityType: asset?.type, + entityId: asset?.id, + }); + const hasData = !!data?.hasData; + const hasLogsData = isLogsSignal(dataStreams); const noDataConfig = getNoDataConfig({ hasData, loading: isPending(status), @@ -118,10 +130,22 @@ export const InfraPageTemplate = ({ />; } + const evaluateNoDataConfig = () => { + if (entitySummaryStatus === 'failure') { + return noDataConfig; + } + + if (entitySummaryStatus !== 'success') { + return undefined; + } + + return isEntityCentricExperienceEnabled && hasLogsData ? undefined : noDataConfig; + }; + return ( ); From 63b9114779a3fff9116b0938143347be3d894dd9 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:48:37 +0000 Subject: [PATCH 07/18] [CI] Auto-commit changed files from 'node scripts/yarn_deduplicate' --- x-pack/plugins/observability_solution/apm/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/apm/tsconfig.json b/x-pack/plugins/observability_solution/apm/tsconfig.json index 47ab49953451..706cf11040c7 100644 --- a/x-pack/plugins/observability_solution/apm/tsconfig.json +++ b/x-pack/plugins/observability_solution/apm/tsconfig.json @@ -128,7 +128,8 @@ "@kbn/router-utils", "@kbn/react-hooks", "@kbn/alerting-comparators", - "@kbn/entityManager-plugin" + "@kbn/entityManager-plugin", + "@kbn/observability-utils" ], "exclude": ["target/**/*"] } From 1fbf28db41eddd17885bf6a6c00018342a14515b Mon Sep 17 00:00:00 2001 From: iblancof Date: Wed, 16 Oct 2024 10:31:24 +0200 Subject: [PATCH 08/18] Remove EntityManager usage in apm --- .../observability_solution/apm/kibana.jsonc | 3 +-- .../templates/apm_main_template/index.tsx | 6 +---- .../apm/public/hooks/use_entity_manager.ts | 23 ------------------- .../apm/public/plugin.ts | 2 -- .../observability_solution/apm/tsconfig.json | 1 - 5 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 x-pack/plugins/observability_solution/apm/public/hooks/use_entity_manager.ts diff --git a/x-pack/plugins/observability_solution/apm/kibana.jsonc b/x-pack/plugins/observability_solution/apm/kibana.jsonc index 0e305bc449c0..e12b22a43d60 100644 --- a/x-pack/plugins/observability_solution/apm/kibana.jsonc +++ b/x-pack/plugins/observability_solution/apm/kibana.jsonc @@ -30,8 +30,7 @@ "lens", "maps", "uiActions", - "logsDataAccess", - "entityManager" + "logsDataAccess" ], "optionalPlugins": [ "actions", diff --git a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx index 1e0c656145b6..b063de1c364c 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx @@ -12,7 +12,6 @@ import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-templat import React, { useContext } from 'react'; import { useLocation } from 'react-router-dom'; import { FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; -import { useEntityManager } from '../../../../hooks/use_entity_manager'; import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context'; import { isLogsSignal } from '../../../../utils/get_signal_type'; import { useLocalStorage } from '../../../../hooks/use_local_storage'; @@ -76,7 +75,6 @@ export function ApmMainTemplate({ const { config } = useApmPluginContext(); const { serviceEntitySummary } = useApmServiceContext(); const { isEntityCentricExperienceEnabled } = useEntityCentricExperienceSetting(); - const { isEntityManagerEnabled } = useEntityManager(); const ObservabilityPageTemplate = observabilityShared.navigation.PageTemplate; @@ -100,8 +98,6 @@ export function ApmMainTemplate({ location.pathname.includes(path) ); - const isEntityExperienceFullyEnabled = isEntityCentricExperienceEnabled && isEntityManagerEnabled; - const { data: fleetApmPoliciesData, status: fleetApmPoliciesStatus } = useFetcher( (callApmApi) => { if (!data?.hasData && !shouldBypassNoDataScreen) { @@ -170,7 +166,7 @@ export function ApmMainTemplate({ { - const { - services: { entityManager }, - } = useKibana(); - - const { value = { enabled: false } } = useAbortableAsync(() => { - return entityManager.entityClient.isManagedEntityDiscoveryEnabled(); - }, [entityManager]); - - return { - isEntityManagerEnabled: value.enabled, - }; -}; diff --git a/x-pack/plugins/observability_solution/apm/public/plugin.ts b/x-pack/plugins/observability_solution/apm/public/plugin.ts index 8b267bf0b03d..b21bdedac9ef 100644 --- a/x-pack/plugins/observability_solution/apm/public/plugin.ts +++ b/x-pack/plugins/observability_solution/apm/public/plugin.ts @@ -70,7 +70,6 @@ import { map } from 'rxjs'; import type { CloudSetup } from '@kbn/cloud-plugin/public'; import type { ServerlessPluginStart } from '@kbn/serverless/public'; import { LogsSharedClientStartExports } from '@kbn/logs-shared-plugin/public'; -import { EntityManagerPublicPluginStart } from '@kbn/entityManager-plugin/public'; import type { ConfigSchema } from '.'; import { registerApmRuleTypes } from './components/alerting/rule_types/register_apm_rule_types'; import { registerEmbeddables } from './embeddable/register_embeddables'; @@ -145,7 +144,6 @@ export interface ApmPluginStartDeps { metricsDataAccess: MetricsDataPluginStart; uiSettings: IUiSettingsClient; logsShared: LogsSharedClientStartExports; - entityManager: EntityManagerPublicPluginStart; } const applicationsTitle = i18n.translate('xpack.apm.navigation.rootTitle', { diff --git a/x-pack/plugins/observability_solution/apm/tsconfig.json b/x-pack/plugins/observability_solution/apm/tsconfig.json index 706cf11040c7..f4a5dc88fd39 100644 --- a/x-pack/plugins/observability_solution/apm/tsconfig.json +++ b/x-pack/plugins/observability_solution/apm/tsconfig.json @@ -128,7 +128,6 @@ "@kbn/router-utils", "@kbn/react-hooks", "@kbn/alerting-comparators", - "@kbn/entityManager-plugin", "@kbn/observability-utils" ], "exclude": ["target/**/*"] From 1572b828b0318fb05276a7df276e22b9811d8786 Mon Sep 17 00:00:00 2001 From: iblancof Date: Wed, 16 Oct 2024 10:35:21 +0200 Subject: [PATCH 09/18] Add new logic to shouldBypassNoDataScreen --- .../templates/apm_main_template/index.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx index b063de1c364c..3f05d872f6d1 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/routing/templates/apm_main_template/index.tsx @@ -94,9 +94,14 @@ export function ApmMainTemplate({ [application?.capabilities.savedObjectsManagement.edit] ); - const shouldBypassNoDataScreen = bypassNoDataScreenPaths.some((path) => - location.pathname.includes(path) - ); + const hasLogsData = serviceEntitySummary?.dataStreamTypes + ? serviceEntitySummary?.dataStreamTypes?.length > 0 && + isLogsSignal(serviceEntitySummary.dataStreamTypes) + : false; + + const shouldBypassNoDataScreen = + bypassNoDataScreenPaths.some((path) => location.pathname.includes(path)) || + (isEntityCentricExperienceEnabled && hasLogsData); const { data: fleetApmPoliciesData, status: fleetApmPoliciesStatus } = useFetcher( (callApmApi) => { @@ -111,10 +116,6 @@ export function ApmMainTemplate({ status === FETCH_STATUS.LOADING || fleetApmPoliciesStatus === FETCH_STATUS.LOADING; const hasApmData = !!data?.hasData; - const hasLogsData = - serviceEntitySummary?.dataStreamTypes && - serviceEntitySummary?.dataStreamTypes?.length > 0 && - isLogsSignal(serviceEntitySummary.dataStreamTypes); const hasApmIntegrations = !!fleetApmPoliciesData?.hasApmPolicies; const noDataConfig = getNoDataConfig({ @@ -165,11 +166,7 @@ export function ApmMainTemplate({ return ( Date: Wed, 16 Oct 2024 08:49:08 +0000 Subject: [PATCH 10/18] [CI] Auto-commit changed files from 'node scripts/yarn_deduplicate' --- x-pack/plugins/observability_solution/apm/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/apm/tsconfig.json b/x-pack/plugins/observability_solution/apm/tsconfig.json index f4a5dc88fd39..0f08bf3143cd 100644 --- a/x-pack/plugins/observability_solution/apm/tsconfig.json +++ b/x-pack/plugins/observability_solution/apm/tsconfig.json @@ -128,7 +128,6 @@ "@kbn/router-utils", "@kbn/react-hooks", "@kbn/alerting-comparators", - "@kbn/observability-utils" ], "exclude": ["target/**/*"] } From 3ee8a24c10da4a3d4046509c27d99f01a8e0442e Mon Sep 17 00:00:00 2001 From: iblancof Date: Wed, 16 Oct 2024 14:24:46 +0200 Subject: [PATCH 11/18] Move noDataConfig new logic --- .../shared/templates/infra_page_template.tsx | 18 ++++-------------- .../shared/templates/no_data_config.ts | 6 +++++- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx index 3747fed52278..15b3f71302a3 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx @@ -65,7 +65,9 @@ export const InfraPageTemplate = ({ const hasLogsData = isLogsSignal(dataStreams); const noDataConfig = getNoDataConfig({ hasData, - loading: isPending(status), + hasLogsData, + isEntityCentricExperienceEnabled, + loading: isPending(status) || isPending(entitySummaryStatus), onboardingFlow, docsLink: docLinks.links.observability.guide, locators: share.url.locators, @@ -130,22 +132,10 @@ export const InfraPageTemplate = ({ />; } - const evaluateNoDataConfig = () => { - if (entitySummaryStatus === 'failure') { - return noDataConfig; - } - - if (entitySummaryStatus !== 'success') { - return undefined; - } - - return isEntityCentricExperienceEnabled && hasLogsData ? undefined : noDataConfig; - }; - return ( ); diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts index faf53cccca4c..309eb74a3a26 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts @@ -101,18 +101,22 @@ const getNoDataConfigDetails = ({ export const getNoDataConfig = ({ hasData, + hasLogsData, loading, locators, onboardingFlow, docsLink, + isEntityCentricExperienceEnabled, }: { hasData: boolean; + hasLogsData?: boolean; loading: boolean; onboardingFlow: OnboardingFlow; locators: LocatorClient; docsLink?: string; + isEntityCentricExperienceEnabled?: boolean; }): NoDataConfig | undefined => { - if (hasData || loading) { + if (hasData || loading || (isEntityCentricExperienceEnabled && hasLogsData)) { return; } From fdf0ef3fde13bae23c9e90cd53ca24bd90040a5c Mon Sep 17 00:00:00 2001 From: iblancof Date: Wed, 16 Oct 2024 17:34:44 +0200 Subject: [PATCH 12/18] Add both logs and metrics check to bypass empty state --- .../components/shared/templates/infra_page_template.tsx | 5 ++--- .../public/components/shared/templates/no_data_config.ts | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx index 15b3f71302a3..c7ebd5332866 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx @@ -19,7 +19,7 @@ import { isPending, useFetcher } from '../../../hooks/use_fetcher'; import { OnboardingFlow, getNoDataConfig } from './no_data_config'; import { useAssetDetailsRenderPropsContext } from '../../asset_details/hooks/use_asset_details_render_props'; import { useEntitySummary } from '../../asset_details/hooks/use_entity_summary'; -import { isLogsSignal } from '../../asset_details/utils/get_data_stream_types'; +import { isLogsSignal, isMetricsSignal } from '../../asset_details/utils/get_data_stream_types'; export const InfraPageTemplate = ({ 'data-test-subj': _dataTestSubj, @@ -62,10 +62,9 @@ export const InfraPageTemplate = ({ }); const hasData = !!data?.hasData; - const hasLogsData = isLogsSignal(dataStreams); const noDataConfig = getNoDataConfig({ hasData, - hasLogsData, + hasEemData: isLogsSignal(dataStreams) || isMetricsSignal(dataStreams), isEntityCentricExperienceEnabled, loading: isPending(status) || isPending(entitySummaryStatus), onboardingFlow, diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts index 309eb74a3a26..d6090817fce1 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts @@ -101,7 +101,7 @@ const getNoDataConfigDetails = ({ export const getNoDataConfig = ({ hasData, - hasLogsData, + hasEemData, loading, locators, onboardingFlow, @@ -109,14 +109,14 @@ export const getNoDataConfig = ({ isEntityCentricExperienceEnabled, }: { hasData: boolean; - hasLogsData?: boolean; + hasEemData?: boolean; loading: boolean; onboardingFlow: OnboardingFlow; locators: LocatorClient; docsLink?: string; isEntityCentricExperienceEnabled?: boolean; }): NoDataConfig | undefined => { - if (hasData || loading || (isEntityCentricExperienceEnabled && hasLogsData)) { + if (hasData || loading || (isEntityCentricExperienceEnabled && hasEemData)) { return; } From 8bf92b45a9f3d8b12a6762665a8f456dc8039830 Mon Sep 17 00:00:00 2001 From: iblancof Date: Thu, 17 Oct 2024 14:36:40 +0200 Subject: [PATCH 13/18] Modify onboarding logic for asset detail --- .../components/asset_details/template/page.tsx | 17 ++++++++++++++--- .../shared/templates/infra_page_template.tsx | 17 ++--------------- .../shared/templates/no_data_config.ts | 6 ++---- .../pages/metrics/inventory_view/index.tsx | 2 ++ .../components/node_details_page.tsx | 2 ++ .../metric_detail/metric_detail_page.tsx | 3 ++- .../pages/metrics/metrics_explorer/index.tsx | 2 ++ 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx index 363fc88c8a49..799da1228379 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx @@ -8,6 +8,8 @@ import React, { useEffect } from 'react'; import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; import { EuiLoadingSpinner } from '@elastic/eui'; +import { useEntityCentricExperienceSetting } from '../../../hooks/use_entity_centric_experience_setting'; +import { isPending } from '../../../hooks/use_fetcher'; import { SYSTEM_INTEGRATION } from '../../../../common/constants'; import { useMetricsBreadcrumbs } from '../../../hooks/use_metrics_breadcrumbs'; import { useParentBreadcrumbResolver } from '../../../hooks/use_parent_breadcrumb_resolver'; @@ -24,7 +26,7 @@ import { InfraPageTemplate } from '../../shared/templates/infra_page_template'; import { OnboardingFlow } from '../../shared/templates/no_data_config'; import { PageTitleWithPopover } from '../header/page_title_with_popover'; import { useEntitySummary } from '../hooks/use_entity_summary'; -import { isMetricsSignal } from '../utils/get_data_stream_types'; +import { isLogsSignal, isMetricsSignal } from '../utils/get_data_stream_types'; const DATA_AVAILABILITY_PER_TYPE: Partial> = { host: [SYSTEM_INTEGRATION], @@ -36,10 +38,11 @@ export const Page = ({ tabs = [], links = [] }: ContentTemplateProps) => { const { rightSideItems, tabEntries, breadcrumbs: headerBreadcrumbs } = usePageHeader(tabs, links); const { asset } = useAssetDetailsRenderPropsContext(); const trackOnlyOnce = React.useRef(false); - const { dataStreams } = useEntitySummary({ + const { dataStreams, status: entitySummaryStatus } = useEntitySummary({ entityType: asset.type, entityId: asset.id, }); + const { isEntityCentricExperienceEnabled } = useEntityCentricExperienceSetting(); const { activeTabId } = useTabSwitcherContext(); const { services: { telemetry }, @@ -85,10 +88,18 @@ export const Page = ({ tabs = [], links = [] }: ContentTemplateProps) => { }, [activeTabId, asset.type, metadata, metadataLoading, telemetry]); const showPageTitleWithPopover = asset.type === 'host' && !isMetricsSignal(dataStreams); + const hasEEM = + (isEntityCentricExperienceEnabled && isLogsSignal(dataStreams)) || isMetricsSignal(dataStreams); return ( & { dataAvailabilityModules?: string[]; @@ -54,19 +50,10 @@ export const InfraPageTemplate = ({ }); }); - const { isEntityCentricExperienceEnabled } = useEntityCentricExperienceSetting(); - const { asset } = useAssetDetailsRenderPropsContext(); - const { dataStreams, status: entitySummaryStatus } = useEntitySummary({ - entityType: asset?.type, - entityId: asset?.id, - }); - const hasData = !!data?.hasData; const noDataConfig = getNoDataConfig({ hasData, - hasEemData: isLogsSignal(dataStreams) || isMetricsSignal(dataStreams), - isEntityCentricExperienceEnabled, - loading: isPending(status) || isPending(entitySummaryStatus), + loading: isPending(status), onboardingFlow, docsLink: docLinks.links.observability.guide, locators: share.url.locators, diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts index d6090817fce1..d4a35d6e2176 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts @@ -101,22 +101,20 @@ const getNoDataConfigDetails = ({ export const getNoDataConfig = ({ hasData, - hasEemData, loading, locators, onboardingFlow, docsLink, - isEntityCentricExperienceEnabled, }: { hasData: boolean; hasEemData?: boolean; loading: boolean; - onboardingFlow: OnboardingFlow; + onboardingFlow?: OnboardingFlow; locators: LocatorClient; docsLink?: string; isEntityCentricExperienceEnabled?: boolean; }): NoDataConfig | undefined => { - if (hasData || loading || (isEntityCentricExperienceEnabled && hasEemData)) { + if (!onboardingFlow || hasData || loading) { return; } diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/index.tsx b/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/index.tsx index c013cebb42e7..b3d82e0c8fc2 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/index.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/inventory_view/index.tsx @@ -10,6 +10,7 @@ import React from 'react'; import { useTrackPageview } from '@kbn/observability-shared-plugin/public'; import { APP_WRAPPER_CLASS } from '@kbn/core/public'; import { css } from '@emotion/react'; +import { OnboardingFlow } from '../../../components/shared/templates/no_data_config'; import { InfraPageTemplate } from '../../../components/shared/templates/infra_page_template'; import { useMetricsBreadcrumbs } from '../../../hooks/use_metrics_breadcrumbs'; import { inventoryTitle } from '../../../translations'; @@ -38,6 +39,7 @@ export const SnapshotPage = () => {
, ], diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx index 3934abb5478f..0de2ae8f6fbe 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx @@ -11,6 +11,7 @@ import moment from 'moment'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { InventoryMetric, InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; import { decodeOrThrow } from '@kbn/io-ts-utils'; +import { OnboardingFlow } from '../../../../components/shared/templates/no_data_config'; import { InfraPageTemplate } from '../../../../components/shared/templates/infra_page_template'; import { NodeDetailsMetricDataResponseRT } from '../../../../../common/http_api/node_details_api'; import { isPending, useFetcher } from '../../../../hooks/use_fetcher'; @@ -91,6 +92,7 @@ export const NodeDetailsPage = (props: Props) => { return ( { if (metadataLoading && !filteredRequiredMetrics.length) { return ( - + { return ( Date: Thu, 17 Oct 2024 14:43:42 +0200 Subject: [PATCH 14/18] Prevent calling hasData if onboardingFlow is undefined --- .../public/components/shared/templates/infra_page_template.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx index 1c7be164a43b..7446732b959a 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx @@ -42,6 +42,7 @@ export const InfraPageTemplate = ({ const { remoteClustersExist } = source?.status ?? {}; const { data, status } = useFetcher(async (callApi) => { + if (!onboardingFlow) return; return await callApi('/api/metrics/source/hasData', { method: 'GET', query: { From 753476db2abd0d64fb188508acafd2cb38e5db31 Mon Sep 17 00:00:00 2001 From: Irene Blanco Date: Thu, 17 Oct 2024 14:45:38 +0200 Subject: [PATCH 15/18] Update x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: CauĂȘ Marcondes <55978943+cauemarcondes@users.noreply.github.com> --- .../infra/public/components/asset_details/template/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx index 799da1228379..c8c9c73fa597 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx @@ -89,7 +89,7 @@ export const Page = ({ tabs = [], links = [] }: ContentTemplateProps) => { const showPageTitleWithPopover = asset.type === 'host' && !isMetricsSignal(dataStreams); const hasEEM = - (isEntityCentricExperienceEnabled && isLogsSignal(dataStreams)) || isMetricsSignal(dataStreams); + isEntityCentricExperienceEnabled && (isLogsSignal(dataStreams) || isMetricsSignal(dataStreams)); return ( Date: Thu, 17 Oct 2024 14:51:20 +0200 Subject: [PATCH 16/18] Rename has EEM to shouldBypassOnboarding --- .../infra/public/components/asset_details/template/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx index c8c9c73fa597..c6e8790eeff6 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/template/page.tsx @@ -88,13 +88,13 @@ export const Page = ({ tabs = [], links = [] }: ContentTemplateProps) => { }, [activeTabId, asset.type, metadata, metadataLoading, telemetry]); const showPageTitleWithPopover = asset.type === 'host' && !isMetricsSignal(dataStreams); - const hasEEM = + const shouldBypassOnboarding = isEntityCentricExperienceEnabled && (isLogsSignal(dataStreams) || isMetricsSignal(dataStreams)); return ( Date: Thu, 17 Oct 2024 15:25:27 +0200 Subject: [PATCH 17/18] Remove unused attributes in getNoDataConfig --- .../infra/public/components/shared/templates/no_data_config.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts index d4a35d6e2176..3859f93ddc43 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/no_data_config.ts @@ -107,12 +107,10 @@ export const getNoDataConfig = ({ docsLink, }: { hasData: boolean; - hasEemData?: boolean; loading: boolean; onboardingFlow?: OnboardingFlow; locators: LocatorClient; docsLink?: string; - isEntityCentricExperienceEnabled?: boolean; }): NoDataConfig | undefined => { if (!onboardingFlow || hasData || loading) { return; From 52a4967123598ac7b9c71084bcf7f1096c5aaaa3 Mon Sep 17 00:00:00 2001 From: iblancof Date: Fri, 18 Oct 2024 10:09:15 +0200 Subject: [PATCH 18/18] Add missing onboardingFlow dep when fetching hasData --- .../shared/templates/infra_page_template.tsx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx index 7446732b959a..b7318c736843 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/shared/templates/infra_page_template.tsx @@ -41,15 +41,18 @@ export const InfraPageTemplate = ({ const { error: dataViewLoadError, refetch: loadDataView } = useMetricsDataViewContext(); const { remoteClustersExist } = source?.status ?? {}; - const { data, status } = useFetcher(async (callApi) => { - if (!onboardingFlow) return; - return await callApi('/api/metrics/source/hasData', { - method: 'GET', - query: { - modules: dataAvailabilityModules, - }, - }); - }); + const { data, status } = useFetcher( + async (callApi) => { + if (!onboardingFlow) return; + return await callApi('/api/metrics/source/hasData', { + method: 'GET', + query: { + modules: dataAvailabilityModules, + }, + }); + }, + [onboardingFlow, dataAvailabilityModules] + ); const hasData = !!data?.hasData; const noDataConfig = getNoDataConfig({