diff --git a/x-pack/plugins/apm/public/components/app/correlations/index.tsx b/x-pack/plugins/apm/public/components/app/correlations/index.tsx index 6e000521fe156..0614d1cbfe444 100644 --- a/x-pack/plugins/apm/public/components/app/correlations/index.tsx +++ b/x-pack/plugins/apm/public/components/app/correlations/index.tsx @@ -26,7 +26,6 @@ import { i18n } from '@kbn/i18n'; import { useHistory } from 'react-router-dom'; import { LatencyCorrelations } from './latency_correlations'; import { MlCorrelations } from './ml_correlations'; -import { MlScatter } from './ml_scatter'; import { ErrorCorrelations } from './error_correlations'; import { useUrlParams } from '../../../context/url_params_context/use_url_params'; import { createHref } from '../../shared/Links/url_helpers'; @@ -60,14 +59,7 @@ const demo1Tab = { }), component: MlCorrelations, }; -const demo2Tab = { - key: 'demo2', - label: i18n.translate('xpack.apm.correlations.tabs.demo2Label', { - defaultMessage: 'Demo 2', - }), - component: MlScatter, -}; -const tabs = [latencyTab, errorRateTab, demo1Tab, demo2Tab]; +const tabs = [latencyTab, errorRateTab, demo1Tab]; export function Correlations() { const license = useLicenseContext(); diff --git a/x-pack/plugins/apm/public/components/app/correlations/ml_scatter.tsx b/x-pack/plugins/apm/public/components/app/correlations/ml_scatter.tsx deleted file mode 100644 index 9380cc2b4de7d..0000000000000 --- a/x-pack/plugins/apm/public/components/app/correlations/ml_scatter.tsx +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 React from 'react'; - -import { useParams } from 'react-router-dom'; - -import { Scatter } from '../../../../../ml/public'; - -import { useUrlParams } from '../../../context/url_params_context/use_url_params'; - -interface Props { - onClose: () => void; -} - -export function MlScatter({ onClose }: Props) { - const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams } = useUrlParams(); - return ( - - ); -} diff --git a/x-pack/plugins/ml/public/application/components/correlations/index.ts b/x-pack/plugins/ml/public/application/components/correlations/index.ts index 42d2be2dc5412..48e59e4b9797e 100644 --- a/x-pack/plugins/ml/public/application/components/correlations/index.ts +++ b/x-pack/plugins/ml/public/application/components/correlations/index.ts @@ -6,4 +6,3 @@ */ export { Correlations } from './correlations'; -export { Scatter } from './scatter'; diff --git a/x-pack/plugins/ml/public/application/components/correlations/scatter.tsx b/x-pack/plugins/ml/public/application/components/correlations/scatter.tsx deleted file mode 100644 index 0555dac134110..0000000000000 --- a/x-pack/plugins/ml/public/application/components/correlations/scatter.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 React, { useEffect, useState, FC } from 'react'; - -import { EuiButton, EuiProgress, EuiSpacer, EuiText } from '@elastic/eui'; - -import { i18n } from '@kbn/i18n'; - -import { useMlKibana } from '../../contexts/kibana'; - -// Separate imports for lazy loadable VegaChart and related code -import { VegaChart } from '../vega_chart'; - -import { useCorrelations } from './use_correlations'; - -const isErrorMessage = (arg: unknown): arg is Error => { - return arg instanceof Error; -}; - -interface CorrelationsProps { - environment?: string; - kuery?: string; - serviceName?: string; - transactionName?: string; - transactionType?: string; - start?: string; - end?: string; -} - -export const Scatter: FC = (fetchOptions) => { - const { - services: { notifications }, - } = useMlKibana(); - - const [allScatter, setAllScatter] = useState([]); - - const { - error, - scatter, - isComplete, - isRunning, - progress, - startFetch, - cancelFetch, - } = useCorrelations({ - index: 'apm-*', - ...fetchOptions, - }); - - // cancel any running async partial request when unmounting the component - useEffect(() => cancelFetch, []); - - useEffect(() => { - const newAllScatter = allScatter - .map((d) => { - d.status = 'old'; - return d; - }) - .concat( - scatter.map((d) => { - d.status = 'new'; - return d; - }) - ); - setAllScatter(newAllScatter); - }, [JSON.stringify(scatter)]); - - useEffect(() => { - if (isComplete) { - notifications.toasts.addSuccess('Finished'); - } - }, [isComplete]); - - useEffect(() => { - if (isErrorMessage(error)) { - notifications.toasts.addDanger({ - title: i18n.translate('xpack.ml.correlations.error.title', { - defaultMessage: 'An error occurred fetching correlations', - }), - text: error.toString(), - }); - } - }, [error]); - - const vegaSpec = { - $schema: 'https://vega.github.io/schema/vega-lite/v5.json', - description: 'A scatterplot with delta updates', - width: 400, - height: 400, - data: { values: allScatter }, - mark: 'point', - encoding: { - x: { field: 'correlation', type: 'quantitative' }, - y: { field: 'docCount', type: 'quantitative', scale: { type: 'log' } }, - color: { field: 'status' }, - }, - }; - - return ( - <> - -

- {i18n.translate('xpack.ml.correlations.description', { - defaultMessage: - 'What is slowing down my service? Correlations will help discover a slower performance in a particular cohort of your data.', - })} -

-
- - - - {!isRunning && Start} - {isRunning && Cancel} - - - - - - - - - - ); -}; diff --git a/x-pack/plugins/ml/public/application/components/correlations/use_correlations.ts b/x-pack/plugins/ml/public/application/components/correlations/use_correlations.ts index bfc61bda2116d..586360b6e8616 100644 --- a/x-pack/plugins/ml/public/application/components/correlations/use_correlations.ts +++ b/x-pack/plugins/ml/public/application/components/correlations/use_correlations.ts @@ -95,7 +95,6 @@ export const useCorrelations = (params: CorrelationsOptions) => { return { error, histograms: rawResponse?.values ?? [], - scatter: rawResponse?.scatter ?? [], isComplete, isRunning, progress: loaded / total, diff --git a/x-pack/plugins/ml/server/lib/search_strategies/correlations/async_search_service.ts b/x-pack/plugins/ml/server/lib/search_strategies/correlations/async_search_service.ts index 287b286373035..8dfde1b97280b 100644 --- a/x-pack/plugins/ml/server/lib/search_strategies/correlations/async_search_service.ts +++ b/x-pack/plugins/ml/server/lib/search_strategies/correlations/async_search_service.ts @@ -68,7 +68,6 @@ export const asyncSearchServiceProvider = ( }; let values: SearchServiceValue[] = []; - let scatter: Array<{ correlation: number; docCount: number }> = []; const cancel = () => { isCancelled = true; @@ -172,8 +171,6 @@ export const asyncSearchServiceProvider = ( return p + c.doc_count; }, 0); - scatter.push({ correlation, docCount }); - yield { ...item, correlation, @@ -199,8 +196,6 @@ export const asyncSearchServiceProvider = ( fetchCorrelations(); return () => { - const scatterDelta = [...scatter]; - scatter = []; return { error, isRunning, @@ -208,7 +203,6 @@ export const asyncSearchServiceProvider = ( started: progress.started, total: 100, values, - scatter: scatterDelta, cancel, }; }; diff --git a/x-pack/plugins/ml/server/lib/search_strategies/correlations/search_strategy.ts b/x-pack/plugins/ml/server/lib/search_strategies/correlations/search_strategy.ts index 6afd236ce246d..48c12f6fcfedf 100644 --- a/x-pack/plugins/ml/server/lib/search_strategies/correlations/search_strategy.ts +++ b/x-pack/plugins/ml/server/lib/search_strategies/correlations/search_strategy.ts @@ -41,15 +41,7 @@ export const mlCorrelationsSearchStrategyProvider = (): ISearchStrategy< asyncSearchServiceMap.get(id) ?? asyncSearchServiceProvider(deps.esClient.asCurrentUser, request.params); - const { - error, - isRunning, - loaded, - started, - total, - values, - scatter, - } = getAsyncSearchServiceState(); + const { error, isRunning, loaded, started, total, values } = getAsyncSearchServiceState(); if (error instanceof Error) { asyncSearchServiceMap.delete(id); @@ -68,7 +60,7 @@ export const mlCorrelationsSearchStrategyProvider = (): ISearchStrategy< total, isRunning, isPartial: isRunning, - rawResponse: { took, values, scatter }, + rawResponse: { took, values }, }); }, cancel: async (id, options, deps) => {