mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ML][AIOps] Telemetry: Track change point detection runs (#169158)
## Summary This PR adds UI tracking for Change Point Detection for AIOps. - tracks type of analysis and source (where the analysis is being run from) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Quynh Nguyen (Quinn) <43350163+qn895@users.noreply.github.com>
This commit is contained in:
parent
13d1792544
commit
7e97dd90e7
11 changed files with 65 additions and 5 deletions
|
@ -30,3 +30,5 @@ export const AIOPS_TELEMETRY_ID = {
|
|||
AIOPS_DEFAULT_SOURCE: 'ml_aiops_labs',
|
||||
AIOPS_ANALYSIS_RUN_ORIGIN: 'aiops-analysis-run-origin',
|
||||
} as const;
|
||||
|
||||
export const EMBEDDABLE_ORIGIN = 'embeddable';
|
||||
|
|
|
@ -37,6 +37,7 @@ import {
|
|||
} from './change_point_detection_context';
|
||||
import { timeSeriesDataViewWarning } from '../../application/utils/time_series_dataview_check';
|
||||
import { ReloadContextProvider } from '../../hooks/use_reload';
|
||||
import { AIOPS_TELEMETRY_ID } from '../../../common/constants';
|
||||
|
||||
const localStorage = new Storage(window.localStorage);
|
||||
|
||||
|
@ -76,6 +77,8 @@ export const ChangePointDetectionAppState: FC<ChangePointDetectionAppStateProps>
|
|||
return <>{warning}</>;
|
||||
}
|
||||
|
||||
appDependencies.embeddingOrigin = AIOPS_TELEMETRY_ID.AIOPS_DEFAULT_SOURCE;
|
||||
|
||||
const PresentationContextProvider =
|
||||
appDependencies.presentationUtil?.ContextProvider ?? React.Fragment;
|
||||
|
||||
|
|
|
@ -38,3 +38,9 @@ export const EXCLUDED_CHANGE_POINT_TYPES = new Set<ChangePointType>([
|
|||
]);
|
||||
|
||||
export const MAX_CHANGE_POINT_CONFIGS = 6;
|
||||
|
||||
export const CHANGE_POINT_DETECTION_EVENT = {
|
||||
RUN: 'ran_aiops_change_point_detection',
|
||||
SUCCESS: 'aiops_change_point_detection_success',
|
||||
ERROR: 'aiops_change_point_detection_error',
|
||||
} as const;
|
||||
|
|
|
@ -13,6 +13,7 @@ import type {
|
|||
MappingRuntimeFields,
|
||||
SearchRequest,
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import { useReload } from '../../hooks/use_reload';
|
||||
import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
|
||||
import {
|
||||
|
@ -28,6 +29,7 @@ import {
|
|||
COMPOSITE_AGG_SIZE,
|
||||
EXCLUDED_CHANGE_POINT_TYPES,
|
||||
SPLIT_FIELD_CARDINALITY_LIMIT,
|
||||
CHANGE_POINT_DETECTION_EVENT,
|
||||
} from './constants';
|
||||
|
||||
interface RequestOptions {
|
||||
|
@ -122,6 +124,8 @@ export function useChangePointResults(
|
|||
) {
|
||||
const {
|
||||
notifications: { toasts },
|
||||
usageCollection,
|
||||
embeddingOrigin,
|
||||
} = useAiopsAppContext();
|
||||
|
||||
const { dataView } = useDataSource();
|
||||
|
@ -187,11 +191,27 @@ export function useChangePointResults(
|
|||
runtimeMappings
|
||||
);
|
||||
|
||||
if (usageCollection?.reportUiCounter && embeddingOrigin) {
|
||||
usageCollection.reportUiCounter(
|
||||
embeddingOrigin,
|
||||
METRIC_TYPE.COUNT,
|
||||
CHANGE_POINT_DETECTION_EVENT.RUN
|
||||
);
|
||||
}
|
||||
|
||||
const result = await runRequest<
|
||||
{ params: SearchRequest },
|
||||
{ rawResponse: ChangePointAggResponse }
|
||||
>({ params: requestPayload });
|
||||
|
||||
if (usageCollection?.reportUiCounter && embeddingOrigin) {
|
||||
usageCollection.reportUiCounter(
|
||||
embeddingOrigin,
|
||||
METRIC_TYPE.COUNT,
|
||||
CHANGE_POINT_DETECTION_EVENT.SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
if (result === null) {
|
||||
setProgress(null);
|
||||
return;
|
||||
|
@ -257,6 +277,13 @@ export function useChangePointResults(
|
|||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (usageCollection?.reportUiCounter && embeddingOrigin) {
|
||||
usageCollection.reportUiCounter(
|
||||
embeddingOrigin,
|
||||
METRIC_TYPE.COUNT,
|
||||
CHANGE_POINT_DETECTION_EVENT.ERROR
|
||||
);
|
||||
}
|
||||
toasts.addError(e, {
|
||||
title: i18n.translate('xpack.aiops.changePointDetection.fetchErrorTitle', {
|
||||
defaultMessage: 'Failed to fetch change points',
|
||||
|
@ -265,6 +292,7 @@ export function useChangePointResults(
|
|||
}
|
||||
},
|
||||
[
|
||||
embeddingOrigin,
|
||||
isSingleMetric,
|
||||
totalAggPages,
|
||||
dataView,
|
||||
|
@ -278,6 +306,7 @@ export function useChangePointResults(
|
|||
splitFieldsOptions,
|
||||
runRequest,
|
||||
toasts,
|
||||
usageCollection,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -21,9 +21,10 @@ import { DatePickerContextProvider } from '@kbn/ml-date-picker';
|
|||
import { pick } from 'lodash';
|
||||
import { LensPublicStart } from '@kbn/lens-plugin/public';
|
||||
import { Subject } from 'rxjs';
|
||||
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
import type { DataView } from '@kbn/data-views-plugin/common';
|
||||
import { EmbeddableInputTracker } from './embeddable_chart_component_wrapper';
|
||||
import { EMBEDDABLE_CHANGE_POINT_CHART_TYPE } from '../../common/constants';
|
||||
import { EMBEDDABLE_CHANGE_POINT_CHART_TYPE, EMBEDDABLE_ORIGIN } from '../../common/constants';
|
||||
import { AiopsAppContext, type AiopsAppDependencies } from '../hooks/use_aiops_app_context';
|
||||
|
||||
import { EmbeddableChangePointChartProps } from './embeddable_change_point_chart_component';
|
||||
|
@ -40,6 +41,7 @@ export interface EmbeddableChangePointChartDeps {
|
|||
notifications: CoreStart['notifications'];
|
||||
i18n: CoreStart['i18n'];
|
||||
lens: LensPublicStart;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
}
|
||||
|
||||
export type IEmbeddableChangePointChart = typeof EmbeddableChangePointChart;
|
||||
|
@ -121,10 +123,15 @@ export class EmbeddableChangePointChart extends AbstractEmbeddable<
|
|||
const input = this.getInput();
|
||||
const input$ = this.getInput$();
|
||||
|
||||
const aiopsAppContextValue = {
|
||||
...this.deps,
|
||||
embeddingOrigin: this.parent?.type ?? EMBEDDABLE_ORIGIN,
|
||||
} as unknown as AiopsAppDependencies;
|
||||
|
||||
ReactDOM.render(
|
||||
<I18nContext>
|
||||
<KibanaThemeProvider theme$={this.deps.theme.theme$}>
|
||||
<AiopsAppContext.Provider value={this.deps as unknown as AiopsAppDependencies}>
|
||||
<AiopsAppContext.Provider value={aiopsAppContextValue}>
|
||||
<DatePickerContextProvider {...datePickerDeps}>
|
||||
<Suspense fallback={null}>
|
||||
<EmbeddableInputTracker
|
||||
|
|
|
@ -41,7 +41,6 @@ export interface EmbeddableChangePointChartProps {
|
|||
*/
|
||||
lastReloadRequestTime?: number;
|
||||
}
|
||||
|
||||
export function getEmbeddableChangePointChart(core: CoreStart, plugins: AiopsPluginStartDeps) {
|
||||
const { embeddable: embeddableStart } = plugins;
|
||||
const factory = embeddableStart.getEmbeddableFactory<EmbeddableChangePointChartInput>(
|
||||
|
|
|
@ -71,8 +71,10 @@ export class EmbeddableChangePointChartFactory implements EmbeddableFactoryDefin
|
|||
|
||||
async create(input: EmbeddableChangePointChartInput, parent?: IContainer) {
|
||||
try {
|
||||
const [{ i18n: i18nService, theme, http, uiSettings, notifications }, { lens, data }] =
|
||||
await this.getStartServices();
|
||||
const [
|
||||
{ i18n: i18nService, theme, http, uiSettings, notifications },
|
||||
{ lens, data, usageCollection },
|
||||
] = await this.getStartServices();
|
||||
|
||||
return new EmbeddableChangePointChart(
|
||||
{
|
||||
|
@ -83,6 +85,7 @@ export class EmbeddableChangePointChartFactory implements EmbeddableFactoryDefin
|
|||
data,
|
||||
notifications,
|
||||
lens,
|
||||
usageCollection,
|
||||
},
|
||||
input,
|
||||
parent
|
||||
|
|
|
@ -32,6 +32,7 @@ import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
|
|||
import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public';
|
||||
import type { EmbeddableStart } from '@kbn/embeddable-plugin/public';
|
||||
import type { CasesUiStart } from '@kbn/cases-plugin/public';
|
||||
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
|
||||
/**
|
||||
* AIOps App Dependencies to be provided via React context.
|
||||
|
@ -84,6 +85,10 @@ export interface AiopsAppDependencies {
|
|||
* Unified search.
|
||||
*/
|
||||
unifiedSearch: UnifiedSearchPublicPluginStart;
|
||||
/**
|
||||
* Usage collection.
|
||||
*/
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
/**
|
||||
* Used to create deep links to other plugins.
|
||||
*/
|
||||
|
@ -115,6 +120,8 @@ export interface AiopsAppDependencies {
|
|||
embeddable?: EmbeddableStart;
|
||||
cases?: CasesUiStart;
|
||||
isServerless?: boolean;
|
||||
/** Identifier to indicate the plugin utilizing the component */
|
||||
embeddingOrigin?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/
|
|||
import type { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public';
|
||||
import type { CasesUiSetup } from '@kbn/cases-plugin/public';
|
||||
import type { LicensingPluginSetup } from '@kbn/licensing-plugin/public';
|
||||
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
import type { EmbeddableChangePointChartInput } from './embeddable/embeddable_change_point_chart';
|
||||
|
||||
export interface AiopsPluginSetupDeps {
|
||||
|
@ -40,6 +41,7 @@ export interface AiopsPluginStartDeps {
|
|||
licensing: LicensingPluginStart;
|
||||
executionContext: ExecutionContextStart;
|
||||
embeddable: EmbeddableStart;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
}
|
||||
|
||||
export type AiopsPluginSetup = void;
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
"@kbn/react-kibana-mount",
|
||||
"@kbn/ml-chi2test",
|
||||
"@kbn/usage-collection-plugin",
|
||||
"@kbn/analytics",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -67,6 +67,7 @@ export const ChangePointDetectionPage: FC = () => {
|
|||
'embeddable',
|
||||
'cases',
|
||||
'i18n',
|
||||
'usageCollection',
|
||||
]),
|
||||
fieldStats: { useFieldStatsTrigger, FieldStatsFlyoutProvider },
|
||||
}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue