From 07c493c46228992761584428386d3bc83a2fe6ac Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 8 Oct 2024 04:30:25 +1100 Subject: [PATCH] [8.x] [ML] AIOps: Cleanup context/embeddingOrigin (#194442) (#195284) # Backport This will backport the following commits from `main` to `8.x`: - [[ML] AIOps: Cleanup context/embeddingOrigin (#194442)](https://github.com/elastic/kibana/pull/194442) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Walter Rafelsberger --- .../pattern_analysis_table.tsx | 8 +++- x-pack/packages/ml/aiops_common/constants.ts | 16 +++++-- .../change_point_detection_root.tsx | 24 +++++----- .../log_categorization_app_state.tsx | 15 +++--- .../log_categorization_for_discover.tsx | 4 +- ...og_categorization_for_discover_wrapper.tsx | 47 ++++--------------- .../log_categorization_for_embeddable.tsx | 4 +- .../log_categorization_for_flyout.tsx | 8 ++-- .../log_categorization_page.tsx | 14 ++---- .../log_categorization/show_flyout.tsx | 10 ++-- .../log_rate_analysis_app_state.tsx | 12 ++--- .../log_rate_analysis_content.tsx | 4 -- .../log_rate_analysis_content_wrapper.tsx | 14 ++---- .../log_rate_analysis_page.tsx | 2 - .../log_rate_analysis_results.tsx | 9 ++-- .../embeddable_change_point_chart_factory.tsx | 8 ++-- .../resolve_change_point_config_input.tsx | 12 ++--- .../embeddable_pattern_analysis_factory.tsx | 7 ++- .../resolve_pattern_analysis_config_input.tsx | 12 ++--- .../public/hooks/use_aiops_app_context.ts | 10 ++-- x-pack/plugins/aiops/public/index.ts | 2 +- .../change_point_detection.tsx | 23 ++++----- .../shared_components/pattern_analysis.tsx | 22 ++++----- .../route_handler_factory.ts | 4 +- .../route_handler_factory.ts | 4 +- .../route_handler_factory.ts | 4 +- x-pack/plugins/aiops/tsconfig.json | 1 - .../aiops/change_point_detection.tsx | 4 +- .../application/aiops/log_categorization.tsx | 43 ++++++++++------- .../application/aiops/log_rate_analysis.tsx | 43 +++++++++-------- x-pack/plugins/ml/tsconfig.json | 3 +- .../components/log_rate_analysis.tsx | 38 ++++++++------- .../log_rate_analysis.tsx | 38 ++++++++------- .../custom_kql/log_rate_analysis_panel.tsx | 38 ++++++++------- 34 files changed, 243 insertions(+), 264 deletions(-) diff --git a/src/plugins/discover/public/application/main/components/pattern_analysis/pattern_analysis_table.tsx b/src/plugins/discover/public/application/main/components/pattern_analysis/pattern_analysis_table.tsx index bc93d2b90c645..0c0236ab60c08 100644 --- a/src/plugins/discover/public/application/main/components/pattern_analysis/pattern_analysis_table.tsx +++ b/src/plugins/discover/public/application/main/components/pattern_analysis/pattern_analysis_table.tsx @@ -12,6 +12,7 @@ import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics'; import { type EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable'; import { pick } from 'lodash'; import type { LogCategorizationEmbeddableProps } from '@kbn/aiops-plugin/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover'; +import type { AiopsAppContextValue } from '@kbn/aiops-plugin/public/hooks/use_aiops_app_context'; import { useDiscoverServices } from '../../../../hooks/use_discover_services'; import type { DiscoverStateContainer } from '../../state_management/discover_state'; import { PATTERN_ANALYSIS_LOADED } from './constants'; @@ -63,8 +64,11 @@ export const PatternAnalysisTable = (props: PatternAnalysisTableProps) => { return ( ); }; diff --git a/x-pack/packages/ml/aiops_common/constants.ts b/x-pack/packages/ml/aiops_common/constants.ts index ba33439f32221..39a0fdc5842c8 100644 --- a/x-pack/packages/ml/aiops_common/constants.ts +++ b/x-pack/packages/ml/aiops_common/constants.ts @@ -16,9 +16,15 @@ export const AIOPS_API_ENDPOINT = { CATEGORIZATION_FIELD_VALIDATION: '/internal/aiops/categorization_field_validation', } as const; -export const AIOPS_TELEMETRY_ID = { - AIOPS_DEFAULT_SOURCE: 'ml_aiops_labs', - AIOPS_ANALYSIS_RUN_ORIGIN: 'aiops-analysis-run-origin', -} as const; +/** + * Used for telemetry purposes to track the origin of the analysis run. + */ +export const AIOPS_ANALYSIS_RUN_ORIGIN = 'aiops-analysis-run-origin'; -export const EMBEDDABLE_ORIGIN = 'embeddable'; +export const AIOPS_EMBEDDABLE_ORIGIN = { + CASES: 'cases', + DASHBOARD: 'dashboard', + DEFAULT: 'embeddable', + DISCOVER: 'discover', + ML_AIOPS_LABS: 'ml_aiops_labs', +} as const; diff --git a/x-pack/plugins/aiops/public/components/change_point_detection/change_point_detection_root.tsx b/x-pack/plugins/aiops/public/components/change_point_detection/change_point_detection_root.tsx index a259e3debfb04..36f8f3e2ddaf6 100644 --- a/x-pack/plugins/aiops/public/components/change_point_detection/change_point_detection_root.tsx +++ b/x-pack/plugins/aiops/public/components/change_point_detection/change_point_detection_root.tsx @@ -24,10 +24,10 @@ import { mlTimefilterRefresh$, } from '@kbn/ml-date-picker'; import { UI_SETTINGS } from '@kbn/data-plugin/common'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; import { DataSourceContext } from '../../hooks/use_data_source'; -import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context'; +import type { AiopsAppContextValue } from '../../hooks/use_aiops_app_context'; import { AiopsAppContext } from '../../hooks/use_aiops_app_context'; import { AIOPS_STORAGE_KEYS } from '../../types/storage'; @@ -52,8 +52,8 @@ export interface ChangePointDetectionAppStateProps { dataView: DataView; /** The saved search to analyze. */ savedSearch: SavedSearch | null; - /** App dependencies */ - appDependencies: AiopsAppDependencies; + /** App context value */ + appContextValue: AiopsAppContextValue; /** Optional flag to indicate whether kibana is running in serverless */ showFrozenDataTierChoice?: boolean; } @@ -61,11 +61,11 @@ export interface ChangePointDetectionAppStateProps { export const ChangePointDetectionAppState: FC = ({ dataView, savedSearch, - appDependencies, + appContextValue, showFrozenDataTierChoice = true, }) => { const datePickerDeps: DatePickerDependencies = { - ...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), + ...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), uiSettingsKeys: UI_SETTINGS, showFrozenDataTierChoice, }; @@ -80,19 +80,19 @@ export const ChangePointDetectionAppState: FC return <>{warning}; } - appDependencies.embeddingOrigin = AIOPS_TELEMETRY_ID.AIOPS_DEFAULT_SOURCE; + appContextValue.embeddingOrigin = AIOPS_EMBEDDABLE_ORIGIN.ML_AIOPS_LABS; const PresentationContextProvider = - appDependencies.presentationUtil?.ContextProvider ?? React.Fragment; + appContextValue.presentationUtil?.ContextProvider ?? React.Fragment; - const CasesContext = appDependencies.cases?.ui.getCasesContext() ?? React.Fragment; - const casesPermissions = appDependencies.cases?.helpers.canUseCases(); + const CasesContext = appContextValue.cases?.ui.getCasesContext() ?? React.Fragment; + const casesPermissions = appContextValue.cases?.helpers.canUseCases(); return ( - + - + diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_app_state.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_app_state.tsx index dc9d8c8c0dba2..85e81ec0f2996 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_app_state.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_app_state.tsx @@ -15,10 +15,9 @@ import { UrlStateProvider } from '@kbn/ml-url-state'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml-date-picker'; import { UI_SETTINGS } from '@kbn/data-plugin/common'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; import { DataSourceContext } from '../../hooks/use_data_source'; -import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context'; +import type { AiopsAppContextValue } from '../../hooks/use_aiops_app_context'; import { AIOPS_STORAGE_KEYS } from '../../types/storage'; import { AiopsAppContext } from '../../hooks/use_aiops_app_context'; @@ -35,8 +34,8 @@ export interface LogCategorizationAppStateProps { dataView: DataView; /** The saved search to analyze. */ savedSearch: SavedSearch | null; - /** App dependencies */ - appDependencies: AiopsAppDependencies; + /** App context value */ + appContextValue: AiopsAppContextValue; /** Optional flag to indicate whether kibana is running in serverless */ showFrozenDataTierChoice?: boolean; } @@ -44,7 +43,7 @@ export interface LogCategorizationAppStateProps { export const LogCategorizationAppState: FC = ({ dataView, savedSearch, - appDependencies, + appContextValue, showFrozenDataTierChoice = true, }) => { if (!dataView) return null; @@ -56,18 +55,18 @@ export const LogCategorizationAppState: FC = ({ } const datePickerDeps: DatePickerDependencies = { - ...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), + ...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), uiSettingsKeys: UI_SETTINGS, showFrozenDataTierChoice, }; return ( - + - + diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover.tsx index 27d680fc1769c..db2135e94ab74 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover.tsx @@ -19,7 +19,7 @@ import type { FieldValidationResults } from '@kbn/ml-category-validator'; import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants'; import type { EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable'; import { css } from '@emotion/react'; import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state'; @@ -270,7 +270,7 @@ export const LogCategorizationDiscover: FC = ( searchQuery, runtimeMappings, { - [AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, + [AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, } ), runCategorizeRequest( diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover_wrapper.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover_wrapper.tsx index 1af4f03a06bb3..6582ba5333b40 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover_wrapper.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover_wrapper.tsx @@ -7,67 +7,40 @@ import type { FC } from 'react'; import React, { Suspense } from 'react'; -import type { ThemeServiceStart } from '@kbn/core-theme-browser'; -import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import type { IUiSettingsClient } from '@kbn/core/public'; -import type { CoreStart } from '@kbn/core/public'; -import type { LensPublicStart } from '@kbn/lens-plugin/public'; -import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; -import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; -import type { UiActionsStart } from '@kbn/ui-actions-plugin/public'; +import { pick } from 'lodash'; + import { DatePickerContextProvider } from '@kbn/ml-date-picker'; import { StorageContextProvider } from '@kbn/ml-local-storage'; - -import { pick } from 'lodash'; import { UI_SETTINGS } from '@kbn/data-plugin/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; + import { AIOPS_STORAGE_KEYS } from '../../../types/storage'; -import type { AiopsAppDependencies } from '../../../hooks/use_aiops_app_context'; -import { AiopsAppContext } from '../../../hooks/use_aiops_app_context'; +import { AiopsAppContext, type AiopsAppContextValue } from '../../../hooks/use_aiops_app_context'; + import type { LogCategorizationEmbeddableProps } from './log_categorization_for_discover'; import { LogCategorizationDiscover } from './log_categorization_for_discover'; -export interface EmbeddableLogCategorizationDeps { - theme: ThemeServiceStart; - data: DataPublicPluginStart; - uiSettings: IUiSettingsClient; - http: CoreStart['http']; - notifications: CoreStart['notifications']; - i18n: CoreStart['i18n']; - lens: LensPublicStart; - fieldFormats: FieldFormatsStart; - application: CoreStart['application']; - charts: ChartsPluginStart; - uiActions: UiActionsStart; -} - export interface LogCategorizationEmbeddableWrapperProps { - deps: EmbeddableLogCategorizationDeps; + appContextValue: AiopsAppContextValue; props: LogCategorizationEmbeddableProps; - embeddingOrigin?: string; } const localStorage = new Storage(window.localStorage); export const LogCategorizationDiscoverWrapper: FC = ({ - deps, + appContextValue, props, - embeddingOrigin, }) => { - const I18nContext = deps.i18n.Context; - const aiopsAppContextValue = { - embeddingOrigin, - ...deps, - } as unknown as AiopsAppDependencies; + const I18nContext = appContextValue.i18n.Context; const datePickerDeps = { - ...pick(deps, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), + ...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), uiSettingsKeys: UI_SETTINGS, }; return ( - + diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_embeddable.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_embeddable.tsx index 0d4cf093019cd..9178ac7428664 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_embeddable.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_embeddable.tsx @@ -18,7 +18,7 @@ import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request'; import type { EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable'; import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants'; import datemath from '@elastic/datemath'; import useMountedState from 'react-use/lib/useMountedState'; import { useFilterQueryUpdates } from '../../../hooks/use_filters_query'; @@ -224,7 +224,7 @@ export const LogCategorizationEmbeddable: FC = searchQuery, runtimeMappings, { - [AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, + [AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, } ), runCategorizeRequest( diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_flyout.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_flyout.tsx index ec61dca179da2..2036c5d3a24e9 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_flyout.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_for_flyout.tsx @@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { usePageUrlState } from '@kbn/ml-url-state'; import type { FieldValidationResults } from '@kbn/ml-category-validator'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants'; import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request'; import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; @@ -64,8 +64,6 @@ export interface LogCategorizationPageProps { savedSearch: SavedSearch | null; selectedField: DataViewField; onClose: () => void; - /** Identifier to indicate the plugin utilizing the component */ - embeddingOrigin: string; additionalFilter?: CategorizationAdditionalFilter; } @@ -76,7 +74,6 @@ export const LogCategorizationFlyout: FC = ({ savedSearch, selectedField, onClose, - embeddingOrigin, additionalFilter, }) => { const { @@ -85,6 +82,7 @@ export const LogCategorizationFlyout: FC = ({ query: { getState }, }, uiSettings, + embeddingOrigin, } = useAiopsAppContext(); const { runValidateFieldRequest, cancelRequest: cancelValidationRequest } = @@ -198,7 +196,7 @@ export const LogCategorizationFlyout: FC = ({ searchQuery, runtimeMappings, { - [AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, + [AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, } ), runCategorizeRequest( diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx index 567201fff0dd2..4c31f4df1e044 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx @@ -28,10 +28,10 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { usePageUrlState, useUrlState } from '@kbn/ml-url-state'; import type { FieldValidationResults } from '@kbn/ml-category-validator'; import type { SearchQueryLanguage } from '@kbn/ml-query-utils'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants'; import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; - import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state'; + import { useDataSource } from '../../hooks/use_data_source'; import { useData } from '../../hooks/use_data'; import { useSearch } from '../../hooks/use_search'; @@ -59,14 +59,10 @@ import { useActions } from './category_table/use_actions'; const BAR_TARGET = 20; const DEFAULT_SELECTED_FIELD = 'message'; -interface LogCategorizationPageProps { - /** Identifier to indicate the plugin utilizing the component */ - embeddingOrigin: string; -} - -export const LogCategorizationPage: FC = ({ embeddingOrigin }) => { +export const LogCategorizationPage: FC = () => { const { notifications: { toasts }, + embeddingOrigin, } = useAiopsAppContext(); const { dataView, savedSearch } = useDataSource(); @@ -229,7 +225,7 @@ export const LogCategorizationPage: FC = ({ embeddin searchQuery, runtimeMappings, { - [AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, + [AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin, } ), diff --git a/x-pack/plugins/aiops/public/components/log_categorization/show_flyout.tsx b/x-pack/plugins/aiops/public/components/log_categorization/show_flyout.tsx index 87a2e9e934cc3..a97f4c7f7fe79 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/show_flyout.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/show_flyout.tsx @@ -21,7 +21,7 @@ import { StorageContextProvider } from '@kbn/ml-local-storage'; import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request'; import type { AiopsPluginStartDeps } from '../../types'; import { LogCategorizationFlyout } from './log_categorization_for_flyout'; -import { AiopsAppContext, type AiopsAppDependencies } from '../../hooks/use_aiops_app_context'; +import { AiopsAppContext, type AiopsAppContextValue } from '../../hooks/use_aiops_app_context'; import { AIOPS_STORAGE_KEYS } from '../../types/storage'; const localStorage = new Storage(window.localStorage); @@ -43,13 +43,14 @@ export async function showCategorizeFlyout( resolve(); }; - const appDependencies: AiopsAppDependencies = { + const appContextValue: AiopsAppContextValue = { + embeddingOrigin: originatingApp, ...coreStart, ...plugins, }; const startServices = pick(coreStart, 'analytics', 'i18n', 'theme'); const datePickerDeps: DatePickerDependencies = { - ...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings']), + ...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings']), i18n, uiSettingsKeys: UI_SETTINGS, }; @@ -61,7 +62,7 @@ export async function showCategorizeFlyout( ...coreStart, }} > - + diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx index 740bc87ef9cb3..89a8c9aee19ae 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_app_state.tsx @@ -18,7 +18,7 @@ import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml- import { UI_SETTINGS } from '@kbn/data-plugin/common'; import { LogRateAnalysisReduxProvider } from '@kbn/aiops-log-rate-analysis/state'; -import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context'; +import type { AiopsAppContextValue } from '../../hooks/use_aiops_app_context'; import { AiopsAppContext } from '../../hooks/use_aiops_app_context'; import { DataSourceContext } from '../../hooks/use_data_source'; import { AIOPS_STORAGE_KEYS } from '../../types/storage'; @@ -36,8 +36,8 @@ export interface LogRateAnalysisAppStateProps { dataView: DataView; /** The saved search to analyze. */ savedSearch: SavedSearch | null; - /** App dependencies */ - appDependencies: AiopsAppDependencies; + /** App context value */ + appContextValue: AiopsAppContextValue; /** Optional flag to indicate whether to show contextual insights */ showContextualInsights?: boolean; /** Optional flag to indicate whether kibana is running in serverless */ @@ -47,7 +47,7 @@ export interface LogRateAnalysisAppStateProps { export const LogRateAnalysisAppState: FC = ({ dataView, savedSearch, - appDependencies, + appContextValue, showContextualInsights = false, showFrozenDataTierChoice = true, }) => { @@ -60,13 +60,13 @@ export const LogRateAnalysisAppState: FC = ({ } const datePickerDeps: DatePickerDependencies = { - ...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), + ...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']), uiSettingsKeys: UI_SETTINGS, showFrozenDataTierChoice, }; return ( - + diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx index e7c33dd43d18f..7bf43037f45c0 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content.tsx @@ -60,8 +60,6 @@ export interface LogRateAnalysisContentProps { onAnalysisCompleted?: (d: LogRateAnalysisResultsData) => void; /** Optional callback that exposes current window parameters */ onWindowParametersChange?: (wp?: WindowParameters, replace?: boolean) => void; - /** Identifier to indicate the plugin utilizing the component */ - embeddingOrigin: string; } export const LogRateAnalysisContent: FC = ({ @@ -70,7 +68,6 @@ export const LogRateAnalysisContent: FC = ({ barHighlightColorOverride, onAnalysisCompleted, onWindowParametersChange, - embeddingOrigin, }) => { const dispatch = useAppDispatch(); @@ -218,7 +215,6 @@ export const LogRateAnalysisContent: FC = ({ searchQuery={searchQuery} barColorOverride={barColorOverride} barHighlightColorOverride={barHighlightColorOverride} - embeddingOrigin={embeddingOrigin} /> )} {showNoAutoRunEmptyPrompt && ( diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx index dace975115deb..96b1f3f2c80e4 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper.tsx @@ -21,7 +21,7 @@ import { UI_SETTINGS } from '@kbn/data-plugin/common'; import { LogRateAnalysisReduxProvider } from '@kbn/aiops-log-rate-analysis/state'; import { timeSeriesDataViewWarning } from '../../../application/utils/time_series_dataview_check'; -import { AiopsAppContext, type AiopsAppDependencies } from '../../../hooks/use_aiops_app_context'; +import { AiopsAppContext, type AiopsAppContextValue } from '../../../hooks/use_aiops_app_context'; import { DataSourceContext } from '../../../hooks/use_data_source'; import { AIOPS_STORAGE_KEYS } from '../../../types/storage'; @@ -39,7 +39,7 @@ export interface LogRateAnalysisContentWrapperProps { /** The data view to analyze. */ dataView: DataView; /** App dependencies */ - appDependencies: AiopsAppDependencies; + appContextValue: AiopsAppContextValue; /** Timestamp for start of initial analysis */ initialAnalysisStart?: number | WindowParameters; /** Optional time range */ @@ -57,13 +57,11 @@ export interface LogRateAnalysisContentWrapperProps { onAnalysisCompleted?: (d: LogRateAnalysisResultsData) => void; /** Optional flag to indicate whether kibana is running in serverless */ showFrozenDataTierChoice?: boolean; - /** Identifier to indicate the plugin utilizing the component */ - embeddingOrigin: string; } export const LogRateAnalysisContentWrapper: FC = ({ dataView, - appDependencies, + appContextValue, initialAnalysisStart, timeRange, esSearchQuery, @@ -71,7 +69,6 @@ export const LogRateAnalysisContentWrapper: FC { if (!dataView) return null; @@ -82,13 +79,13 @@ export const LogRateAnalysisContentWrapper: FC + @@ -103,7 +100,6 @@ export const LogRateAnalysisContentWrapper: FC diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx index acaa2fb27d998..862de229958f0 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_page.tsx @@ -19,7 +19,6 @@ import { FilterStateStore } from '@kbn/es-query'; import { useUrlState, usePageUrlState } from '@kbn/ml-url-state'; import type { SearchQueryLanguage } from '@kbn/ml-query-utils'; import type { WindowParameters } from '@kbn/aiops-log-rate-analysis'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; import { useAppDispatch, useCurrentSelectedSignificantItem, @@ -311,7 +310,6 @@ export const LogRateAnalysisPage: FC = ({ = ({ @@ -162,9 +160,8 @@ export const LogRateAnalysisResults: FC = ({ searchQuery, barColorOverride, barHighlightColorOverride, - embeddingOrigin, }) => { - const { analytics, http } = useAiopsAppContext(); + const { analytics, http, embeddingOrigin } = useAiopsAppContext(); const { dataView } = useDataSource(); const dispatch = useAppDispatch(); @@ -351,7 +348,7 @@ export const LogRateAnalysisResults: FC = ({ overrides, sampleProbability, }, - headers: { [AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin }, + headers: { [AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin }, }; }, [ analysisType, diff --git a/x-pack/plugins/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx b/x-pack/plugins/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx index 7e0e00b7ac02d..7cf39eb1cf4ae 100644 --- a/x-pack/plugins/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx +++ b/x-pack/plugins/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx @@ -23,6 +23,7 @@ import { initializeTitles, useBatchedPublishingSubjects, } from '@kbn/presentation-publishing'; + import fastIsEqual from 'fast-deep-equal'; import { cloneDeep } from 'lodash'; import React, { useMemo } from 'react'; @@ -231,10 +232,9 @@ export const getChangePointChartEmbeddableFactory = ( const lastReloadRequestTime = useObservable(reload$, Date.now()); const timeRange = useObservable(timeRange$, undefined); - let embeddingOrigin; - if (apiHasExecutionContext(parentApi)) { - embeddingOrigin = parentApi.executionContext.type; - } + const embeddingOrigin = apiHasExecutionContext(parentApi) + ? parentApi.executionContext.type + : undefined; return ( (undefined); +export const AiopsAppContext = createContext(undefined); /** * Custom hook to get AIOps app dependency context. */ -export const useAiopsAppContext = (): AiopsAppDependencies => { +export const useAiopsAppContext = (): AiopsAppContextValue => { const aiopsAppContext = useContext(AiopsAppContext); // if `undefined`, throw an error diff --git a/x-pack/plugins/aiops/public/index.ts b/x-pack/plugins/aiops/public/index.ts index 6b34bd1d77c91..a498ce71544f8 100755 --- a/x-pack/plugins/aiops/public/index.ts +++ b/x-pack/plugins/aiops/public/index.ts @@ -15,7 +15,7 @@ export function plugin() { export type { AiopsPluginStart, AiopsPluginSetup } from './types'; -export type { AiopsAppDependencies } from './hooks/use_aiops_app_context'; +export type { AiopsAppContextValue } from './hooks/use_aiops_app_context'; export type { LogRateAnalysisAppStateProps } from './components/log_rate_analysis'; export type { LogRateAnalysisContentWrapperProps } from './components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_content_wrapper'; export type { LogCategorizationAppStateProps } from './components/log_categorization'; diff --git a/x-pack/plugins/aiops/public/shared_components/change_point_detection.tsx b/x-pack/plugins/aiops/public/shared_components/change_point_detection.tsx index 8746730f74134..9afbd9e1c4c8d 100644 --- a/x-pack/plugins/aiops/public/shared_components/change_point_detection.tsx +++ b/x-pack/plugins/aiops/public/shared_components/change_point_detection.tsx @@ -6,7 +6,7 @@ */ import { css } from '@emotion/react'; import type { ChangePointDetectionViewType } from '@kbn/aiops-change-point-detection/constants'; -import { EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; +import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; import type { CoreStart } from '@kbn/core-lifecycle-browser'; import { UI_SETTINGS } from '@kbn/data-service'; import type { TimeRange } from '@kbn/es-query'; @@ -21,7 +21,7 @@ import { type ChangePointAnnotation, } from '../components/change_point_detection/change_point_detection_context'; import { ChartGridEmbeddableWrapper } from '../embeddables/change_point_chart/embeddable_chart_component_wrapper'; -import { AiopsAppContext, type AiopsAppDependencies } from '../hooks/use_aiops_app_context'; +import { AiopsAppContext, type AiopsAppContextValue } from '../hooks/use_aiops_app_context'; import { DataSourceContextProvider } from '../hooks/use_data_source'; import { FilterQueryContextProvider } from '../hooks/use_filters_query'; import { ReloadContextProvider } from '../hooks/use_reload'; @@ -85,18 +85,19 @@ const ChangePointDetectionWrapper: FC = ({ lastReloadRequestTime, }) => { const deps = useMemo(() => { - const { http, uiSettings, notifications, ...startServices } = coreStart; - const { lens, data, usageCollection, fieldFormats } = pluginStart; + const { charts, lens, data, usageCollection, fieldFormats, share, storage, unifiedSearch } = + pluginStart; return { - http, - uiSettings, + charts, data, - notifications, lens, usageCollection, fieldFormats, - ...startServices, + unifiedSearch, + share, + storage, + ...coreStart, }; }, [coreStart, pluginStart]); @@ -105,11 +106,11 @@ const ChangePointDetectionWrapper: FC = ({ uiSettingsKeys: UI_SETTINGS, }; - const aiopsAppContextValue = useMemo(() => { + const aiopsAppContextValue = useMemo(() => { return { - embeddingOrigin: embeddingOrigin ?? EMBEDDABLE_ORIGIN, + embeddingOrigin: embeddingOrigin ?? AIOPS_EMBEDDABLE_ORIGIN.DEFAULT, ...deps, - } as unknown as AiopsAppDependencies; + }; }, [deps, embeddingOrigin]); const [manualReload$] = useState>( diff --git a/x-pack/plugins/aiops/public/shared_components/pattern_analysis.tsx b/x-pack/plugins/aiops/public/shared_components/pattern_analysis.tsx index af474f4f5ef3e..78261cd1f62f0 100644 --- a/x-pack/plugins/aiops/public/shared_components/pattern_analysis.tsx +++ b/x-pack/plugins/aiops/public/shared_components/pattern_analysis.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; +import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; import type { CoreStart } from '@kbn/core-lifecycle-browser'; import { UI_SETTINGS } from '@kbn/data-service'; @@ -21,7 +21,7 @@ import type { RandomSamplerProbability, } from '../components/log_categorization/sampling_menu/random_sampler'; import { PatternAnalysisEmbeddableWrapper } from '../embeddables/pattern_analysis/pattern_analysys_component_wrapper'; -import { AiopsAppContext, type AiopsAppDependencies } from '../hooks/use_aiops_app_context'; +import { AiopsAppContext, type AiopsAppContextValue } from '../hooks/use_aiops_app_context'; import { DataSourceContextProvider } from '../hooks/use_data_source'; import { FilterQueryContextProvider } from '../hooks/use_filters_query'; import { ReloadContextProvider } from '../hooks/use_reload'; @@ -82,19 +82,19 @@ const PatternAnalysisWrapper: FC = ({ onChange, }) => { const deps = useMemo(() => { - const { http, uiSettings, notifications, ...startServices } = coreStart; - const { lens, data, usageCollection, fieldFormats, charts } = pluginStart; + const { lens, data, usageCollection, fieldFormats, charts, share, storage, unifiedSearch } = + pluginStart; return { - http, - uiSettings, data, - notifications, lens, usageCollection, fieldFormats, charts, - ...startServices, + share, + storage, + unifiedSearch, + ...coreStart, }; }, [coreStart, pluginStart]); @@ -103,11 +103,11 @@ const PatternAnalysisWrapper: FC = ({ uiSettingsKeys: UI_SETTINGS, }; - const aiopsAppContextValue = useMemo(() => { + const aiopsAppContextValue = useMemo(() => { return { - embeddingOrigin: embeddingOrigin ?? EMBEDDABLE_ORIGIN, + embeddingOrigin: embeddingOrigin ?? AIOPS_EMBEDDABLE_ORIGIN.DEFAULT, ...deps, - } as unknown as AiopsAppDependencies; + }; }, [deps, embeddingOrigin]); const [manualReload$] = useState>( diff --git a/x-pack/plugins/aiops/server/routes/categorization_field_validation/route_handler_factory.ts b/x-pack/plugins/aiops/server/routes/categorization_field_validation/route_handler_factory.ts index 950b6a9551d68..d0bfc4cb8a2db 100644 --- a/x-pack/plugins/aiops/server/routes/categorization_field_validation/route_handler_factory.ts +++ b/x-pack/plugins/aiops/server/routes/categorization_field_validation/route_handler_factory.ts @@ -13,7 +13,7 @@ import type { } from '@kbn/core/server'; import { categorizationExamplesProvider } from '@kbn/ml-category-validator'; import type { UsageCounter } from '@kbn/usage-collection-plugin/server'; -import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants'; import { AIOPS_API_ENDPOINT } from '@kbn/aiops-common/constants'; import type { CategorizationFieldValidationSchema } from '@kbn/aiops-log-pattern-analysis/schema'; @@ -34,7 +34,7 @@ export const routeHandlerFactory: ( const { headers } = request; trackAIOpsRouteUsage( `POST ${AIOPS_API_ENDPOINT.CATEGORIZATION_FIELD_VALIDATION}`, - headers[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN], + headers[AIOPS_ANALYSIS_RUN_ORIGIN], usageCounter ); diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/route_handler_factory.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/route_handler_factory.ts index e6e680c46a055..4421e8122d86e 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/route_handler_factory.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/route_handler_factory.ts @@ -16,7 +16,7 @@ import { withSpan } from '@kbn/apm-utils'; import type { Logger } from '@kbn/logging'; import { createExecutionContext } from '@kbn/ml-route-utils'; import type { UsageCounter } from '@kbn/usage-collection-plugin/server'; -import { AIOPS_TELEMETRY_ID, AIOPS_PLUGIN_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN, AIOPS_PLUGIN_ID } from '@kbn/aiops-common/constants'; import type { AiopsLogRateAnalysisSchema, AiopsLogRateAnalysisApiVersion as ApiVersion, @@ -50,7 +50,7 @@ export function routeHandlerFactory( trackAIOpsRouteUsage( `POST ${AIOPS_API_ENDPOINT.LOG_RATE_ANALYSIS}`, - headers[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN], + headers[AIOPS_ANALYSIS_RUN_ORIGIN], usageCounter ); diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis_field_candidates/route_handler_factory.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis_field_candidates/route_handler_factory.ts index b640927588ef1..22ab36fa81fb9 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis_field_candidates/route_handler_factory.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis_field_candidates/route_handler_factory.ts @@ -14,7 +14,7 @@ import type { } from '@kbn/core/server'; import { createExecutionContext } from '@kbn/ml-route-utils'; import type { UsageCounter } from '@kbn/usage-collection-plugin/server'; -import { AIOPS_TELEMETRY_ID, AIOPS_PLUGIN_ID } from '@kbn/aiops-common/constants'; +import { AIOPS_ANALYSIS_RUN_ORIGIN, AIOPS_PLUGIN_ID } from '@kbn/aiops-common/constants'; import type { AiopsLogRateAnalysisSchema, AiopsLogRateAnalysisApiVersion as ApiVersion, @@ -44,7 +44,7 @@ export function routeHandlerFactory( trackAIOpsRouteUsage( `POST ${AIOPS_API_ENDPOINT.LOG_RATE_ANALYSIS_FIELD_CANDIDATES}`, - headers[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN], + headers[AIOPS_ANALYSIS_RUN_ORIGIN], usageCounter ); diff --git a/x-pack/plugins/aiops/tsconfig.json b/x-pack/plugins/aiops/tsconfig.json index c606b479284c4..a90c72660f069 100644 --- a/x-pack/plugins/aiops/tsconfig.json +++ b/x-pack/plugins/aiops/tsconfig.json @@ -24,7 +24,6 @@ "@kbn/core-execution-context-browser", "@kbn/core-http-server", "@kbn/core-lifecycle-browser", - "@kbn/core-theme-browser", "@kbn/core-ui-settings-browser-mocks", "@kbn/core", "@kbn/data-plugin", diff --git a/x-pack/plugins/ml/public/application/aiops/change_point_detection.tsx b/x-pack/plugins/ml/public/application/aiops/change_point_detection.tsx index 874183dcc4d2c..146a3efc9cfcd 100644 --- a/x-pack/plugins/ml/public/application/aiops/change_point_detection.tsx +++ b/x-pack/plugins/ml/public/application/aiops/change_point_detection.tsx @@ -13,6 +13,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { ChangePointDetection } from '@kbn/aiops-plugin/public'; +import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; import { useDataSource } from '../contexts/ml/data_source_context'; import { useMlKibana } from '../contexts/kibana'; @@ -48,7 +49,8 @@ export const ChangePointDetectionPage: FC = () => { dataView={dataView} savedSearch={savedSearch} showFrozenDataTierChoice={showNodeInfo} - appDependencies={{ + appContextValue={{ + embeddingOrigin: AIOPS_EMBEDDABLE_ORIGIN.ML_AIOPS_LABS, ...pick(services, [ 'analytics', 'application', diff --git a/x-pack/plugins/ml/public/application/aiops/log_categorization.tsx b/x-pack/plugins/ml/public/application/aiops/log_categorization.tsx index 1ca0fc8ec2ef4..fea9b0d7e8810 100644 --- a/x-pack/plugins/ml/public/application/aiops/log_categorization.tsx +++ b/x-pack/plugins/ml/public/application/aiops/log_categorization.tsx @@ -8,9 +8,13 @@ import type { FC } from 'react'; import React from 'react'; import { pick } from 'lodash'; + import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; + import { FormattedMessage } from '@kbn/i18n-react'; import { LogCategorization } from '@kbn/aiops-plugin/public'; +import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; + import { useDataSource } from '../contexts/ml/data_source_context'; import { useMlKibana } from '../contexts/kibana'; import { useEnabledFeatures } from '../contexts/ml'; @@ -40,24 +44,27 @@ export const LogCategorizationPage: FC = () => { dataView={dataView} savedSearch={savedSearch} showFrozenDataTierChoice={showNodeInfo} - appDependencies={pick(services, [ - 'analytics', - 'application', - 'charts', - 'data', - 'executionContext', - 'fieldFormats', - 'http', - 'i18n', - 'lens', - 'notifications', - 'share', - 'storage', - 'theme', - 'uiActions', - 'uiSettings', - 'unifiedSearch', - ])} + appContextValue={{ + embeddingOrigin: AIOPS_EMBEDDABLE_ORIGIN.ML_AIOPS_LABS, + ...pick(services, [ + 'analytics', + 'application', + 'charts', + 'data', + 'executionContext', + 'fieldFormats', + 'http', + 'i18n', + 'lens', + 'notifications', + 'share', + 'storage', + 'theme', + 'uiActions', + 'uiSettings', + 'unifiedSearch', + ]), + }} /> )} diff --git a/x-pack/plugins/ml/public/application/aiops/log_rate_analysis.tsx b/x-pack/plugins/ml/public/application/aiops/log_rate_analysis.tsx index f97387fa4c50d..d24b5ab8498b0 100644 --- a/x-pack/plugins/ml/public/application/aiops/log_rate_analysis.tsx +++ b/x-pack/plugins/ml/public/application/aiops/log_rate_analysis.tsx @@ -11,6 +11,8 @@ import { pick } from 'lodash'; import { FormattedMessage } from '@kbn/i18n-react'; import { LogRateAnalysis } from '@kbn/aiops-plugin/public'; +import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants'; + import { useDataSource } from '../contexts/ml/data_source_context'; import { useMlKibana } from '../contexts/kibana'; import { HelpMenu } from '../components/help_menu'; @@ -37,25 +39,28 @@ export const LogRateAnalysisPage: FC = () => { savedSearch={savedSearch} showContextualInsights={showContextualInsights} showFrozenDataTierChoice={showNodeInfo} - appDependencies={pick(services, [ - 'analytics', - 'application', - 'charts', - 'data', - 'executionContext', - 'fieldFormats', - 'http', - 'i18n', - 'lens', - 'notifications', - 'share', - 'storage', - 'theme', - 'uiActions', - 'uiSettings', - 'unifiedSearch', - 'observabilityAIAssistant', - ])} + appContextValue={{ + embeddingOrigin: AIOPS_EMBEDDABLE_ORIGIN.ML_AIOPS_LABS, + ...pick(services, [ + 'analytics', + 'application', + 'charts', + 'data', + 'executionContext', + 'fieldFormats', + 'http', + 'i18n', + 'lens', + 'notifications', + 'share', + 'storage', + 'theme', + 'uiActions', + 'uiSettings', + 'unifiedSearch', + 'observabilityAIAssistant', + ]), + }} /> )} diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index b625562ab2674..4f1d63728ab33 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -131,6 +131,7 @@ "@kbn/json-schemas", "@kbn/ml-field-stats-flyout", "@kbn/ml-parse-interval", - "@kbn/ml-validators" + "@kbn/ml-validators", + "@kbn/aiops-common" ] } diff --git a/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/alert_details_app_section/components/log_rate_analysis.tsx b/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/alert_details_app_section/components/log_rate_analysis.tsx index c85a5b072cb7a..a399414f24c54 100644 --- a/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/alert_details_app_section/components/log_rate_analysis.tsx +++ b/x-pack/plugins/observability_solution/infra/public/alerting/log_threshold/components/alert_details_app_section/components/log_rate_analysis.tsx @@ -207,7 +207,6 @@ export const LogRateAnalysis: FC = ({ r = ({ r barColorOverride={colorTransformer(Color.color0)} barHighlightColorOverride={colorTransformer(Color.color1)} onAnalysisCompleted={onAnalysisCompleted} - appDependencies={pick(services, [ - 'analytics', - 'application', - 'data', - 'executionContext', - 'charts', - 'fieldFormats', - 'http', - 'notifications', - 'share', - 'storage', - 'uiSettings', - 'unifiedSearch', - 'theme', - 'lens', - 'i18n', - ])} + appContextValue={{ + embeddingOrigin: 'observability_log_threshold_alert_details', + ...pick(services, [ + 'analytics', + 'application', + 'data', + 'executionContext', + 'charts', + 'fieldFormats', + 'http', + 'notifications', + 'share', + 'storage', + 'uiSettings', + 'unifiedSearch', + 'theme', + 'lens', + 'i18n', + ]), + }} /> diff --git a/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/alert_details_app_section/log_rate_analysis.tsx b/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/alert_details_app_section/log_rate_analysis.tsx index e2cd954087a3b..f2285b3529f65 100644 --- a/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/alert_details_app_section/log_rate_analysis.tsx +++ b/x-pack/plugins/observability_solution/observability/public/components/custom_threshold/components/alert_details_app_section/log_rate_analysis.tsx @@ -185,7 +185,6 @@ export function LogRateAnalysis({ diff --git a/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/components/custom_panels/custom_kql/log_rate_analysis_panel.tsx b/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/components/custom_panels/custom_kql/log_rate_analysis_panel.tsx index 13c2bcf82de82..e94b8d5baed55 100644 --- a/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/components/custom_panels/custom_kql/log_rate_analysis_panel.tsx +++ b/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/components/custom_panels/custom_kql/log_rate_analysis_panel.tsx @@ -279,7 +279,6 @@ export function LogRateAnalysisPanel({ slo, alert, rule }: Props) {