From 20638a64e2a895d4e4a6597d4a37b5db7003f1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Tue, 15 Dec 2020 13:15:00 +0100 Subject: [PATCH] [APM] Correlations polish (#85116) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../app/Correlations/ErrorCorrelations.tsx | 53 +++++- .../app/Correlations/LatencyCorrelations.tsx | 160 ++++++++---------- .../Correlations/SignificantTermsTable.tsx | 84 ++++++--- .../components/app/Correlations/index.tsx | 43 +++-- .../components/app/TraceOverview/index.tsx | 2 + .../app/service_inventory/index.tsx | 2 - .../index.ts | 66 +++++--- ...g_terms.ts => get_latency_distribution.ts} | 37 +--- .../get_max_latency.ts | 2 +- .../index.ts | 21 ++- ...ms.ts => process_significant_term_aggs.ts} | 23 ++- x-pack/plugins/apm/server/ui_settings.ts | 4 +- .../tests/correlations/slow_transactions.ts | 42 ++--- 13 files changed, 307 insertions(+), 232 deletions(-) rename x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/{get_charts_for_top_sig_terms.ts => get_latency_distribution.ts} (76%) rename x-pack/plugins/apm/server/lib/correlations/{get_correlations_for_slow_transactions/format_top_significant_terms.ts => process_significant_term_aggs.ts} (63%) diff --git a/x-pack/plugins/apm/public/components/app/Correlations/ErrorCorrelations.tsx b/x-pack/plugins/apm/public/components/app/Correlations/ErrorCorrelations.tsx index 07ab89afd4108..25973b9bda388 100644 --- a/x-pack/plugins/apm/public/components/app/Correlations/ErrorCorrelations.tsx +++ b/x-pack/plugins/apm/public/components/app/Correlations/ErrorCorrelations.tsx @@ -16,7 +16,13 @@ import { } from '@elastic/charts'; import React, { useState } from 'react'; import { useParams } from 'react-router-dom'; -import { EuiTitle, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { + EuiTitle, + EuiFlexGroup, + EuiFlexItem, + EuiComboBox, + EuiAccordion, +} from '@elastic/eui'; import { useUrlParams } from '../../../context/url_params_context/use_url_params'; import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher'; import { @@ -35,12 +41,26 @@ type SignificantTerm = NonNullable< CorrelationsApiResponse['significantTerms'] >[0]; +const initialFieldNames = [ + 'transaction.name', + 'user.username', + 'user.id', + 'host.ip', + 'user_agent.name', + 'kubernetes.pod.uuid', + 'kubernetes.pod.name', + 'url.domain', + 'container.id', + 'service.node.name', +].map((label) => ({ label })); + export function ErrorCorrelations() { const [ selectedSignificantTerm, setSelectedSignificantTerm, ] = useState(null); + const [fieldNames, setFieldNames] = useState(initialFieldNames); const { serviceName } = useParams<{ serviceName?: string }>(); const { urlParams, uiFilters } = useUrlParams(); const { transactionName, transactionType, start, end } = urlParams; @@ -57,13 +77,20 @@ export function ErrorCorrelations() { start, end, uiFilters: JSON.stringify(uiFilters), - fieldNames: - 'transaction.name,user.username,user.id,host.ip,user_agent.name,kubernetes.pod.uuid,kubernetes.pod.name,url.domain,container.id,service.node.name', + fieldNames: fieldNames.map((field) => field.label).join(','), }, }, }); } - }, [serviceName, start, end, transactionName, transactionType, uiFilters]); + }, [ + serviceName, + start, + end, + transactionName, + transactionType, + uiFilters, + fieldNames, + ]); return ( <> @@ -72,14 +99,30 @@ export function ErrorCorrelations() {

Error rate over time

+ + + + + + setFieldNames((names) => [...names, { label: term }]) + } + /> + + - + [0]; +const initialFieldNames = [ + 'user.username', + 'user.id', + 'host.ip', + 'user_agent.name', + 'kubernetes.pod.uuid', + 'kubernetes.pod.name', + 'url.domain', + 'container.id', + 'service.node.name', +].map((label) => ({ label })); + export function LatencyCorrelations() { const [ selectedSignificantTerm, setSelectedSignificantTerm, ] = useState(null); + const [fieldNames, setFieldNames] = useState(initialFieldNames); + const [durationPercentile, setDurationPercentile] = useState('50'); const { serviceName } = useParams<{ serviceName?: string }>(); const { urlParams, uiFilters } = useUrlParams(); const { transactionName, transactionType, start, end } = urlParams; @@ -58,30 +77,28 @@ export function LatencyCorrelations() { start, end, uiFilters: JSON.stringify(uiFilters), - durationPercentile: '50', - fieldNames: - 'user.username,user.id,host.ip,user_agent.name,kubernetes.pod.uuid,kubernetes.pod.name,url.domain,container.id,service.node.name', + durationPercentile, + fieldNames: fieldNames.map((field) => field.label).join(','), }, }, }); } - }, [serviceName, start, end, transactionName, transactionType, uiFilters]); + }, [ + serviceName, + start, + end, + transactionName, + transactionType, + uiFilters, + durationPercentile, + fieldNames, + ]); return ( <> - - -

Average latency over time

-
- -

Latency distribution

@@ -94,8 +111,42 @@ export function LatencyCorrelations() {
+ + + + + + + setDurationPercentile(e.currentTarget.value) + } + /> + + + + + { + setFieldNames((names) => [...names, { label: term }]); + }} + /> + + + + + p.y ?? 0), - ...data.significantTerms.flatMap((term) => - term.timeseries.map((p) => p.y ?? 0) - ), - ]; - return Math.max(...yValues); -} - function getDistributionYMax(data?: CorrelationsApiResponse) { if (!data?.overall) { return 0; @@ -134,65 +171,6 @@ function getDistributionYMax(data?: CorrelationsApiResponse) { return Math.max(...yValues); } -function LatencyTimeseriesChart({ - data, - selectedSignificantTerm, - status, -}: { - data?: CorrelationsApiResponse; - selectedSignificantTerm: SignificantTerm | null; - status: FETCH_STATUS; -}) { - const dateFormatter = timeFormatter('HH:mm:ss'); - - const yMax = getTimeseriesYMax(data); - const durationFormatter = getDurationFormatter(yMax); - - return ( - - - - - - durationFormatter(d).formatted} - /> - - - - {selectedSignificantTerm !== null ? ( - - ) : null} - - - ); -} - function LatencyDistributionChart({ data, selectedSignificantTerm, diff --git a/x-pack/plugins/apm/public/components/app/Correlations/SignificantTermsTable.tsx b/x-pack/plugins/apm/public/components/app/Correlations/SignificantTermsTable.tsx index 350f64367b766..a3989d22abf68 100644 --- a/x-pack/plugins/apm/public/components/app/Correlations/SignificantTermsTable.tsx +++ b/x-pack/plugins/apm/public/components/app/Correlations/SignificantTermsTable.tsx @@ -5,13 +5,15 @@ */ import React from 'react'; -import { EuiBadge, EuiIcon, EuiToolTip, EuiLink } from '@elastic/eui'; +import { EuiIcon, EuiLink } from '@elastic/eui'; import { useHistory } from 'react-router-dom'; import { EuiBasicTable } from '@elastic/eui'; -import { asPercent, asInteger } from '../../../../common/utils/formatters'; +import { EuiBasicTableColumn } from '@elastic/eui'; +import { EuiCode } from '@elastic/eui'; +import { asInteger, asPercent } from '../../../../common/utils/formatters'; import { APIReturnType } from '../../../services/rest/createCallApmApi'; import { FETCH_STATUS } from '../../../hooks/use_fetcher'; -import { createHref } from '../../shared/Links/url_helpers'; +import { createHref, push } from '../../shared/Links/url_helpers'; type CorrelationsApiResponse = | APIReturnType<'GET /api/apm/correlations/failed_transactions'> @@ -24,39 +26,32 @@ type SignificantTerm = NonNullable< interface Props { significantTerms?: T[]; status: FETCH_STATUS; + cardinalityColumnName: string; setSelectedSignificantTerm: (term: T | null) => void; } export function SignificantTermsTable({ significantTerms, status, + cardinalityColumnName, setSelectedSignificantTerm, }: Props) { const history = useHistory(); - const columns = [ + const columns: Array> = [ { - field: 'matches', - name: 'Matches', + width: '100px', + field: 'score', + name: 'Score', render: (_: any, term: T) => { - return ( - - <> - 0.03 ? 'primary' : 'secondary' - } - > - {asPercent(term.fgCount, term.bgCount)} - - ({Math.round(term.score)}) - - - ); + return {Math.round(term.score)}; + }, + }, + { + field: 'cardinality', + name: cardinalityColumnName, + render: (_: any, term: T) => { + const matches = asPercent(term.fgCount, term.bgCount); + return `${asInteger(term.fgCount)} (${matches})`; }, }, { @@ -64,13 +59,45 @@ export function SignificantTermsTable({ name: 'Field name', }, { - field: 'filedValue', + field: 'fieldValue', name: 'Field value', render: (_: any, term: T) => String(term.fieldValue).slice(0, 50), }, { - field: 'filedValue', - name: '', + width: '100px', + actions: [ + { + name: 'Focus', + description: 'Focus on this term', + icon: 'magnifyWithPlus', + type: 'icon', + onClick: (term: T) => { + push(history, { + query: { + kuery: `${term.fieldName}:"${encodeURIComponent( + term.fieldValue + )}"`, + }, + }); + }, + }, + { + name: 'Exclude', + description: 'Exclude this term', + icon: 'magnifyWithMinus', + type: 'icon', + onClick: (term: T) => { + push(history, { + query: { + kuery: `not ${term.fieldName}:"${encodeURIComponent( + term.fieldValue + )}"`, + }, + }); + }, + }, + ], + name: 'Actions', render: (_: any, term: T) => { return ( <> @@ -85,6 +112,7 @@ export function SignificantTermsTable({ > +  /  - View correlations + View significant terms + + {isFlyoutVisible && ( setIsFlyoutVisible(false)} > -

Correlations

+

Significant terms

{urlParams.kuery ? ( - - Filtering by - {urlParams.kuery} - - Clear - - + <> + + Filtering by + {urlParams.kuery} + + Clear + + + + ) : null} + +

+ Significant terms is an experimental feature and in active + development. Bugs and surprises are to be expected but let us + know your feedback so we can improve it. +

+
+ + +
diff --git a/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx b/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx index ab10d6b4f46a0..399455e4150d4 100644 --- a/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx @@ -14,6 +14,7 @@ import { APIReturnType } from '../../../services/rest/createCallApmApi'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { SearchBar } from '../../shared/search_bar'; import { TraceList } from './TraceList'; +import { Correlations } from '../Correlations'; type TracesAPIResponse = APIReturnType<'GET /api/apm/traces'>; const DEFAULT_RESPONSE: TracesAPIResponse = { @@ -61,6 +62,7 @@ export function TraceOverview() { + diff --git a/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx b/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx index b1d725bba0ca9..fba9cecac0144 100644 --- a/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx @@ -23,7 +23,6 @@ import { useLocalStorage } from '../../../hooks/useLocalStorage'; import { useUrlParams } from '../../../context/url_params_context/use_url_params'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { SearchBar } from '../../shared/search_bar'; -import { Correlations } from '../Correlations'; import { NoServicesMessage } from './no_services_message'; import { ServiceList } from './ServiceList'; import { MLCallout } from './ServiceList/MLCallout'; @@ -138,7 +137,6 @@ export function ServiceInventory() { - diff --git a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_failed_transactions/index.ts b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_failed_transactions/index.ts index ba739310bc342..64d9ebb192eb3 100644 --- a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_failed_transactions/index.ts +++ b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_failed_transactions/index.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isEmpty } from 'lodash'; +import { isEmpty, omit } from 'lodash'; import { EventOutcome } from '../../../../common/event_outcome'; import { - formatTopSignificantTerms, + processSignificantTermAggs, TopSigTerm, -} from '../get_correlations_for_slow_transactions/format_top_significant_terms'; +} from '../process_significant_term_aggs'; import { AggregationOptionsByType } from '../../../../../../typings/elasticsearch/aggregations'; import { ESFilter } from '../../../../../../typings/elasticsearch'; import { rangeFilter } from '../../../../common/utils/range_filter'; @@ -61,38 +61,56 @@ export async function getCorrelationsForFailedTransactions({ const params = { apm: { events: [ProcessorEvent.transaction] }, + track_total_hits: true, body: { size: 0, query: { - bool: { - // foreground filters - filter: [ - ...backgroundFilters, - { term: { [EVENT_OUTCOME]: EventOutcome.failure } }, - ], + bool: { filter: backgroundFilters }, + }, + aggs: { + failed_transactions: { + filter: { term: { [EVENT_OUTCOME]: EventOutcome.failure } }, + + // significant term aggs + aggs: fieldNames.reduce((acc, fieldName) => { + return { + ...acc, + [fieldName]: { + significant_terms: { + size: 10, + field: fieldName, + background_filter: { bool: { filter: backgroundFilters } }, + }, + }, + }; + }, {} as Record), }, }, - aggs: fieldNames.reduce((acc, fieldName) => { - return { - ...acc, - [fieldName]: { - significant_terms: { - size: 10, - field: fieldName, - background_filter: { bool: { filter: backgroundFilters } }, - }, - }, - }; - }, {} as Record), }, }; const response = await apmEventClient.search(params); - const topSigTerms = formatTopSignificantTerms(response.aggregations); - return getChartsForTopSigTerms({ setup, backgroundFilters, topSigTerms }); + if (!response.aggregations) { + return {}; + } + + const failedTransactionCount = + response.aggregations?.failed_transactions.doc_count; + const totalTransactionCount = response.hits.total.value; + const avgErrorRate = (failedTransactionCount / totalTransactionCount) * 100; + const sigTermAggs = omit( + response.aggregations?.failed_transactions, + 'doc_count' + ); + + const topSigTerms = processSignificantTermAggs({ + sigTermAggs, + thresholdPercentage: avgErrorRate, + }); + return getErrorRateTimeSeries({ setup, backgroundFilters, topSigTerms }); } -export async function getChartsForTopSigTerms({ +export async function getErrorRateTimeSeries({ setup, backgroundFilters, topSigTerms, diff --git a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_charts_for_top_sig_terms.ts b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_latency_distribution.ts similarity index 76% rename from x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_charts_for_top_sig_terms.ts rename to x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_latency_distribution.ts index cbefd5e2133e5..d6d3283ca5e9a 100644 --- a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_charts_for_top_sig_terms.ts +++ b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_latency_distribution.ts @@ -10,11 +10,10 @@ import { ESFilter } from '../../../../../../typings/elasticsearch'; import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; -import { getBucketSize } from '../../helpers/get_bucket_size'; -import { TopSigTerm } from './format_top_significant_terms'; +import { TopSigTerm } from '../process_significant_term_aggs'; import { getMaxLatency } from './get_max_latency'; -export async function getChartsForTopSigTerms({ +export async function getLatencyDistribution({ setup, backgroundFilters, topSigTerms, @@ -23,8 +22,7 @@ export async function getChartsForTopSigTerms({ backgroundFilters: ESFilter[]; topSigTerms: TopSigTerm[]; }) { - const { start, end, apmEventClient } = setup; - const { intervalString } = getBucketSize({ start, end, numBuckets: 30 }); + const { apmEventClient } = setup; if (isEmpty(topSigTerms)) { return {}; @@ -62,30 +60,12 @@ export async function getChartsForTopSigTerms({ }, }; - const timeseriesAgg = { - date_histogram: { - field: '@timestamp', - fixed_interval: intervalString, - min_doc_count: 0, - extended_bounds: { min: start, max: end }, - }, - aggs: { - average: { - avg: { - // TODO: add support for metrics - field: TRANSACTION_DURATION, - }, - }, - }, - }; - const perTermAggs = topSigTerms.reduce( (acc, term, index) => { acc[`term_${index}`] = { filter: { term: { [term.fieldName]: term.fieldValue } }, aggs: { distribution: distributionAgg, - timeseries: timeseriesAgg, }, }; return acc; @@ -96,7 +76,6 @@ export async function getChartsForTopSigTerms({ filter: AggregationOptionsByType['filter']; aggs: { distribution: typeof distributionAgg; - timeseries: typeof timeseriesAgg; }; } > @@ -111,7 +90,6 @@ export async function getChartsForTopSigTerms({ aggs: { // overall aggs distribution: distributionAgg, - timeseries: timeseriesAgg, // per term aggs ...perTermAggs, @@ -126,13 +104,6 @@ export async function getChartsForTopSigTerms({ return; } - function formatTimeseries(timeseries: Agg['timeseries']) { - return timeseries.buckets.map((bucket) => ({ - x: bucket.key, - y: bucket.average.value, - })); - } - function formatDistribution(distribution: Agg['distribution']) { const total = distribution.doc_count; return distribution.dist_filtered_by_latency.buckets.map((bucket) => ({ @@ -144,7 +115,6 @@ export async function getChartsForTopSigTerms({ return { distributionInterval, overall: { - timeseries: formatTimeseries(response.aggregations.timeseries), distribution: formatDistribution(response.aggregations.distribution), }, significantTerms: topSigTerms.map((topSig, index) => { @@ -153,7 +123,6 @@ export async function getChartsForTopSigTerms({ return { ...topSig, - timeseries: formatTimeseries(agg.timeseries), distribution: formatDistribution(agg.distribution), }; }), diff --git a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_max_latency.ts b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_max_latency.ts index 3f86d2900e85b..358ed8e652eff 100644 --- a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_max_latency.ts +++ b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/get_max_latency.ts @@ -8,7 +8,7 @@ import { ESFilter } from '../../../../../../typings/elasticsearch'; import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; -import { TopSigTerm } from './format_top_significant_terms'; +import { TopSigTerm } from '../process_significant_term_aggs'; export async function getMaxLatency({ setup, diff --git a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/index.ts b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/index.ts index b8a5ab93591a4..c8642e28434e2 100644 --- a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/index.ts +++ b/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/index.ts @@ -16,8 +16,8 @@ import { import { ProcessorEvent } from '../../../../common/processor_event'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; import { getDurationForPercentile } from './get_duration_for_percentile'; -import { formatTopSignificantTerms } from './format_top_significant_terms'; -import { getChartsForTopSigTerms } from './get_charts_for_top_sig_terms'; +import { processSignificantTermAggs } from '../process_significant_term_aggs'; +import { getLatencyDistribution } from './get_latency_distribution'; export async function getCorrelationsForSlowTransactions({ serviceName, @@ -90,6 +90,19 @@ export async function getCorrelationsForSlowTransactions({ }; const response = await apmEventClient.search(params); - const topSigTerms = formatTopSignificantTerms(response.aggregations); - return getChartsForTopSigTerms({ setup, backgroundFilters, topSigTerms }); + + if (!response.aggregations) { + return {}; + } + + const topSigTerms = processSignificantTermAggs({ + sigTermAggs: response.aggregations, + thresholdPercentage: 100 - durationPercentile, + }); + + return getLatencyDistribution({ + setup, + backgroundFilters, + topSigTerms, + }); } diff --git a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/format_top_significant_terms.ts b/x-pack/plugins/apm/server/lib/correlations/process_significant_term_aggs.ts similarity index 63% rename from x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/format_top_significant_terms.ts rename to x-pack/plugins/apm/server/lib/correlations/process_significant_term_aggs.ts index f168b49fb18fd..502bb66f71db6 100644 --- a/x-pack/plugins/apm/server/lib/correlations/get_correlations_for_slow_transactions/format_top_significant_terms.ts +++ b/x-pack/plugins/apm/server/lib/correlations/process_significant_term_aggs.ts @@ -8,7 +8,7 @@ import { orderBy } from 'lodash'; import { AggregationOptionsByType, AggregationResultOf, -} from '../../../../../../typings/elasticsearch/aggregations'; +} from '../../../../../typings/elasticsearch/aggregations'; export interface TopSigTerm { bgCount: number; @@ -18,15 +18,19 @@ export interface TopSigTerm { score: number; } -type SigTermAggs = AggregationResultOf< +type SigTermAgg = AggregationResultOf< { significant_terms: AggregationOptionsByType['significant_terms'] }, {} >; -export function formatTopSignificantTerms( - aggregations?: Record -) { - const significantTerms = Object.entries(aggregations ?? []).flatMap( +export function processSignificantTermAggs({ + sigTermAggs, + thresholdPercentage, +}: { + sigTermAggs: Record; + thresholdPercentage: number; +}) { + const significantTerms = Object.entries(sigTermAggs).flatMap( ([fieldName, agg]) => { return agg.buckets.map((bucket) => ({ fieldName, @@ -39,6 +43,11 @@ export function formatTopSignificantTerms( ); // get top 10 terms ordered by score - const topSigTerms = orderBy(significantTerms, 'score', 'desc').slice(0, 10); + const topSigTerms = orderBy(significantTerms, 'score', 'desc') + .filter(({ bgCount, fgCount }) => { + // only include results that are above the threshold + return Math.floor((fgCount / bgCount) * 100) > thresholdPercentage; + }) + .slice(0, 10); return topSigTerms; } diff --git a/x-pack/plugins/apm/server/ui_settings.ts b/x-pack/plugins/apm/server/ui_settings.ts index 2a9c3d6b71ff2..80225de5195f8 100644 --- a/x-pack/plugins/apm/server/ui_settings.ts +++ b/x-pack/plugins/apm/server/ui_settings.ts @@ -19,14 +19,14 @@ export const uiSettings: Record> = { [enableCorrelations]: { category: ['observability'], name: i18n.translate('xpack.apm.enableCorrelationsExperimentName', { - defaultMessage: 'APM Correlations', + defaultMessage: 'APM Significant terms', }), value: false, description: i18n.translate( 'xpack.apm.enableCorrelationsExperimentDescription', { defaultMessage: - 'Enable the experimental correlations UI and API endpoint in APM.', + 'Enable the experimental Significant terms feature in APM', } ), schema: schema.boolean(), diff --git a/x-pack/test/apm_api_integration/basic/tests/correlations/slow_transactions.ts b/x-pack/test/apm_api_integration/basic/tests/correlations/slow_transactions.ts index 91f13ae62a7f0..5217a4be40da7 100644 --- a/x-pack/test/apm_api_integration/basic/tests/correlations/slow_transactions.ts +++ b/x-pack/test/apm_api_integration/basic/tests/correlations/slow_transactions.ts @@ -57,43 +57,37 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); it('returns significant terms', () => { - expectSnapshot(response.body?.significantTerms?.map((term) => term.fieldName).sort()) - .toMatchInline(` + const sorted = response.body?.significantTerms?.sort(); + expectSnapshot(sorted?.map((term) => term.fieldName)).toMatchInline(` Array [ - "container.id", - "container.id", - "host.ip", + "user_agent.name", + "url.domain", "host.ip", "service.node.name", - "service.node.name", - "url.domain", + "container.id", "url.domain", "user_agent.name", - "user_agent.name", ] `); }); - it('returns a timeseries per term', () => { - // @ts-ignore - expectSnapshot(response.body?.significantTerms[0].timeseries.length).toMatchInline(`31`); - }); - it('returns a distribution per term', () => { - // @ts-ignore - expectSnapshot(response.body?.significantTerms[0].distribution.length).toMatchInline( - `42` - ); - }); - - it('returns overall timeseries', () => { - // @ts-ignore - expectSnapshot(response.body?.overall.timeseries.length).toMatchInline(`31`); + expectSnapshot(response.body?.significantTerms?.map((term) => term.distribution.length)) + .toMatchInline(` + Array [ + 11, + 11, + 11, + 11, + 11, + 11, + 11, + ] + `); }); it('returns overall distribution', () => { - // @ts-ignore - expectSnapshot(response.body?.overall.distribution.length).toMatchInline(`42`); + expectSnapshot(response.body?.overall?.distribution.length).toMatchInline(`11`); }); }); });