diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx index 4cd2db43621a8..4b8d8ddc6f746 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx @@ -67,9 +67,8 @@ type ErrorGroupDetailsProps = RouteComponentProps<{ export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) { const { serviceName, groupId } = match.params; - const { urlParams, uiFilters } = useUrlParams(); - const { environment, start, end } = urlParams; - + const { urlParams } = useUrlParams(); + const { environment, kuery, start, end } = urlParams; const { data: errorGroupData } = useFetcher( (callApmApi) => { if (start && end) { @@ -82,15 +81,15 @@ export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) { }, query: { environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, serviceName, start, end, groupId, uiFilters] + [environment, kuery, serviceName, start, end, groupId] ); const { errorDistributionData } = useErrorGroupDistributionFetcher({ diff --git a/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx b/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx index 69f03f56b4c72..6a5582ca24fc7 100644 --- a/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx +++ b/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx @@ -49,9 +49,10 @@ export function ErrorCorrelations({ onClose }: Props) { ] = useState(null); const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams, uiFilters } = useUrlParams(); + const { urlParams } = useUrlParams(); const { environment, + kuery, transactionName, transactionType, start, @@ -71,12 +72,12 @@ export function ErrorCorrelations({ onClose }: Props) { params: { query: { environment, + kuery, serviceName, transactionName, transactionType, start, end, - uiFilters: JSON.stringify(uiFilters), fieldNames: fieldNames.join(','), }, }, @@ -85,12 +86,12 @@ export function ErrorCorrelations({ onClose }: Props) { }, [ environment, + kuery, serviceName, start, end, transactionName, transactionType, - uiFilters, fieldNames, ] ); diff --git a/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx b/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx index ce88da64dabc4..22dd89918e25d 100644 --- a/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx +++ b/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx @@ -47,9 +47,10 @@ export function LatencyCorrelations({ onClose }: Props) { ] = useState(null); const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams, uiFilters } = useUrlParams(); + const { urlParams } = useUrlParams(); const { environment, + kuery, transactionName, transactionType, start, @@ -76,12 +77,12 @@ export function LatencyCorrelations({ onClose }: Props) { params: { query: { environment, + kuery, serviceName, transactionName, transactionType, start, end, - uiFilters: JSON.stringify(uiFilters), durationPercentile: durationPercentile.toString(10), fieldNames: fieldNames.join(','), }, @@ -91,12 +92,12 @@ export function LatencyCorrelations({ onClose }: Props) { }, [ environment, + kuery, serviceName, start, end, transactionName, transactionType, - uiFilters, durationPercentile, fieldNames, ] diff --git a/x-pack/plugins/apm/public/components/app/error_group_overview/index.tsx b/x-pack/plugins/apm/public/components/app/error_group_overview/index.tsx index bde23eddaa44f..49e1cc44f9255 100644 --- a/x-pack/plugins/apm/public/components/app/error_group_overview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/error_group_overview/index.tsx @@ -27,8 +27,9 @@ interface ErrorGroupOverviewProps { } export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) { - const { urlParams, uiFilters } = useUrlParams(); - const { environment, start, end, sortField, sortDirection } = urlParams; + const { + urlParams: { environment, kuery, start, end, sortField, sortDirection }, + } = useUrlParams(); const { errorDistributionData } = useErrorGroupDistributionFetcher({ serviceName, groupId: undefined, @@ -47,17 +48,17 @@ export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) { }, query: { environment, + kuery, start, end, sortField, sortDirection: normalizedSortDirection, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, serviceName, start, end, sortField, sortDirection, uiFilters] + [environment, kuery, serviceName, start, end, sortField, sortDirection] ); useTrackPageview({ 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 cd17ca0ce023d..1d67ff03b675d 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 @@ -36,10 +36,12 @@ const initialData = { let hasDisplayedToast = false; function useServicesFetcher() { - const { urlParams, uiFilters } = useUrlParams(); + const { + urlParams: { environment, kuery, start, end }, + } = useUrlParams(); const { core } = useApmPluginContext(); const upgradeAssistantHref = useUpgradeAssistantHref(); - const { environment, start, end } = urlParams; + const { data = initialData, status } = useFetcher( (callApmApi) => { if (start && end) { @@ -48,15 +50,15 @@ function useServicesFetcher() { params: { query: { environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, start, end, uiFilters] + [environment, kuery, start, end] ); useEffect(() => { diff --git a/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx b/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx index 21871a17f4b04..186c148fa6918 100644 --- a/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_node_metrics/index.tsx @@ -57,11 +57,12 @@ type ServiceNodeMetricsProps = RouteComponentProps<{ }>; export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) { - const { urlParams, uiFilters } = useUrlParams(); + const { + urlParams: { kuery, start, end }, + } = useUrlParams(); const { serviceName, serviceNodeName } = match.params; const { agentName } = useApmServiceContext(); const { data } = useServiceMetricChartsFetcher({ serviceNodeName }); - const { start, end } = urlParams; const { data: { host, containerId } = INITIAL_DATA, status } = useFetcher( (callApmApi) => { @@ -72,15 +73,15 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) { params: { path: { serviceName, serviceNodeName }, query: { + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [serviceName, serviceNodeName, start, end, uiFilters] + [kuery, serviceName, serviceNodeName, start, end] ); const isLoading = status === FETCH_STATUS.LOADING; diff --git a/x-pack/plugins/apm/public/components/app/service_node_overview/index.tsx b/x-pack/plugins/apm/public/components/app/service_node_overview/index.tsx index c64bbcb569dde..f4870439fe478 100644 --- a/x-pack/plugins/apm/public/components/app/service_node_overview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_node_overview/index.tsx @@ -35,8 +35,9 @@ interface ServiceNodeOverviewProps { } function ServiceNodeOverview({ serviceName }: ServiceNodeOverviewProps) { - const { uiFilters, urlParams } = useUrlParams(); - const { start, end } = urlParams; + const { + urlParams: { kuery, start, end }, + } = useUrlParams(); const { data: items = [] } = useFetcher( (callApmApi) => { @@ -50,14 +51,14 @@ function ServiceNodeOverview({ serviceName }: ServiceNodeOverviewProps) { serviceName, }, query: { + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), }, }, }); }, - [serviceName, start, end, uiFilters] + [kuery, serviceName, start, end] ); const columns: Array> = [ diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_errors_table/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_errors_table/index.tsx index 109bf0483f2b0..bbd36a4c8df93 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_errors_table/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_errors_table/index.tsx @@ -43,8 +43,7 @@ const INITIAL_STATE = { export function ServiceOverviewErrorsTable({ serviceName }: Props) { const { - urlParams: { environment, start, end }, - uiFilters, + urlParams: { environment, kuery, start, end }, } = useUrlParams(); const { transactionType } = useApmServiceContext(); const [tableOptions, setTableOptions] = useState<{ @@ -72,9 +71,9 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) { path: { serviceName }, query: { environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), transactionType, }, }, @@ -85,7 +84,7 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) { }; }); }, - [environment, start, end, serviceName, uiFilters, transactionType] + [environment, kuery, start, end, serviceName, transactionType] ); const { requestId, items } = data; @@ -116,9 +115,10 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) { params: { path: { serviceName }, query: { + environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), numBuckets: 20, transactionType, groupIds, diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx index 2f2aaf3156b93..b01529a86e88f 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_instances_chart_and_table.tsx @@ -25,8 +25,7 @@ export function ServiceOverviewInstancesChartAndTable({ const { transactionType } = useApmServiceContext(); const { - urlParams: { environment, latencyAggregationType, start, end }, - uiFilters, + urlParams: { environment, kuery, latencyAggregationType, start, end }, } = useUrlParams(); const { data = [], status } = useFetcher( @@ -44,11 +43,11 @@ export function ServiceOverviewInstancesChartAndTable({ }, query: { environment, + kuery, latencyAggregationType, start, end, transactionType, - uiFilters: JSON.stringify(uiFilters), numBuckets: 20, }, }, @@ -56,12 +55,12 @@ export function ServiceOverviewInstancesChartAndTable({ }, [ environment, + kuery, latencyAggregationType, start, end, serviceName, transactionType, - uiFilters, ] ); diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_throughput_chart.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_throughput_chart.tsx index 2d38ce2c23ca7..ecb57ae5d5715 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_throughput_chart.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_throughput_chart.tsx @@ -28,9 +28,10 @@ export function ServiceOverviewThroughputChart({ }) { const theme = useTheme(); const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams, uiFilters } = useUrlParams(); + const { + urlParams: { environment, kuery, start, end }, + } = useUrlParams(); const { transactionType } = useApmServiceContext(); - const { environment, start, end } = urlParams; const { data = INITIAL_STATE, status } = useFetcher( (callApmApi) => { @@ -43,16 +44,16 @@ export function ServiceOverviewThroughputChart({ }, query: { environment, + kuery, start, end, transactionType, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, serviceName, start, end, uiFilters, transactionType] + [environment, kuery, serviceName, start, end, transactionType] ); return ( diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx index 5529f9028b9dd..e4c42b4de90fe 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx @@ -57,8 +57,7 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) { const { transactionType } = useApmServiceContext(); const { - uiFilters, - urlParams: { environment, start, end, latencyAggregationType }, + urlParams: { environment, kuery, start, end, latencyAggregationType }, } = useUrlParams(); const { data = INITIAL_STATE, status } = useFetcher( @@ -73,9 +72,9 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) { path: { serviceName }, query: { environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), transactionType, latencyAggregationType, }, @@ -89,10 +88,10 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) { }, [ environment, + kuery, serviceName, start, end, - uiFilters, transactionType, latencyAggregationType, ] @@ -128,9 +127,9 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) { path: { serviceName }, query: { environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), numBuckets: 20, transactionType, latencyAggregationType, diff --git a/x-pack/plugins/apm/public/components/app/service_profiling/index.tsx b/x-pack/plugins/apm/public/components/app/service_profiling/index.tsx index 09a42f9b2df90..23adbb23b2322 100644 --- a/x-pack/plugins/apm/public/components/app/service_profiling/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_profiling/index.tsx @@ -33,8 +33,7 @@ export function ServiceProfiling({ environment, }: ServiceProfilingProps) { const { - urlParams: { start, end }, - uiFilters, + urlParams: { kuery, start, end }, } = useUrlParams(); const { data = [] } = useFetcher( @@ -48,15 +47,15 @@ export function ServiceProfiling({ params: { path: { serviceName }, query: { + kuery, start, end, environment, - uiFilters: JSON.stringify(uiFilters), }, }, }); }, - [start, end, serviceName, environment, uiFilters] + [kuery, start, end, serviceName, environment] ); const [valueType, setValueType] = useState(); @@ -125,7 +124,7 @@ export function ServiceProfiling({ valueType={valueType} start={start} end={end} - uiFilters={uiFilters} + kuery={kuery} /> diff --git a/x-pack/plugins/apm/public/components/app/service_profiling/service_profiling_flamegraph.tsx b/x-pack/plugins/apm/public/components/app/service_profiling/service_profiling_flamegraph.tsx index 03248d2836674..fa1da99dbf072 100644 --- a/x-pack/plugins/apm/public/components/app/service_profiling/service_profiling_flamegraph.tsx +++ b/x-pack/plugins/apm/public/components/app/service_profiling/service_profiling_flamegraph.tsx @@ -42,7 +42,6 @@ import { asDynamicBytes, asInteger, } from '../../../../common/utils/formatters'; -import { UIFilters } from '../../../../typings/ui_filters'; import { useFetcher } from '../../../hooks/use_fetcher'; import { useTheme } from '../../../hooks/use_theme'; import { px, unit } from '../../../style/variables'; @@ -124,17 +123,17 @@ function CustomTooltip({ export function ServiceProfilingFlamegraph({ serviceName, environment, + kuery, valueType, start, end, - uiFilters, }: { serviceName: string; environment?: string; + kuery?: string; valueType?: ProfilingValueType; start?: string; end?: string; - uiFilters: UIFilters; }) { const theme = useTheme(); @@ -154,16 +153,16 @@ export function ServiceProfilingFlamegraph({ serviceName, }, query: { + kuery, start, end, environment, valueType, - uiFilters: JSON.stringify(uiFilters), }, }, }); }, - [start, end, environment, serviceName, valueType, uiFilters] + [kuery, start, end, environment, serviceName, valueType] ); const points = useMemo(() => { diff --git a/x-pack/plugins/apm/public/components/app/trace_overview/index.tsx b/x-pack/plugins/apm/public/components/app/trace_overview/index.tsx index 8fc9ac12824ba..6d7edcd0a1e35 100644 --- a/x-pack/plugins/apm/public/components/app/trace_overview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/trace_overview/index.tsx @@ -22,8 +22,9 @@ const DEFAULT_RESPONSE: TracesAPIResponse = { }; export function TraceOverview() { - const { urlParams, uiFilters } = useUrlParams(); - const { environment, start, end } = urlParams; + const { + urlParams: { environment, kuery, start, end }, + } = useUrlParams(); const { status, data = DEFAULT_RESPONSE } = useFetcher( (callApmApi) => { if (start && end) { @@ -32,15 +33,15 @@ export function TraceOverview() { params: { query: { environment, + kuery, start, end, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, start, end, uiFilters] + [environment, kuery, start, end] ); useTrackPageview({ app: 'apm', path: 'traces_overview' }); diff --git a/x-pack/plugins/apm/public/components/app/transaction_overview/use_transaction_list.ts b/x-pack/plugins/apm/public/components/app/transaction_overview/use_transaction_list.ts index a63788457b8b5..062fd5470e60c 100644 --- a/x-pack/plugins/apm/public/components/app/transaction_overview/use_transaction_list.ts +++ b/x-pack/plugins/apm/public/components/app/transaction_overview/use_transaction_list.ts @@ -19,9 +19,10 @@ const DEFAULT_RESPONSE: Partial = { }; export function useTransactionListFetcher() { - const { urlParams, uiFilters } = useUrlParams(); + const { + urlParams: { environment, kuery, transactionType, start, end }, + } = useUrlParams(); const { serviceName } = useParams<{ serviceName?: string }>(); - const { environment, transactionType, start, end } = urlParams; const { data = DEFAULT_RESPONSE, error, status } = useFetcher( (callApmApi) => { if (serviceName && start && end && transactionType) { @@ -31,16 +32,16 @@ export function useTransactionListFetcher() { path: { serviceName }, query: { environment, + kuery, start, end, transactionType, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, serviceName, start, end, transactionType, uiFilters] + [environment, kuery, serviceName, start, end, transactionType] ); return { diff --git a/x-pack/plugins/apm/public/components/shared/DatePicker/date_picker.test.tsx b/x-pack/plugins/apm/public/components/shared/DatePicker/date_picker.test.tsx index f21e87da23979..28a45e492169b 100644 --- a/x-pack/plugins/apm/public/components/shared/DatePicker/date_picker.test.tsx +++ b/x-pack/plugins/apm/public/components/shared/DatePicker/date_picker.test.tsx @@ -12,10 +12,7 @@ import { createMemoryHistory } from 'history'; import React, { ReactNode } from 'react'; import { Router } from 'react-router-dom'; import { MockApmPluginContextWrapper } from '../../../context/apm_plugin/mock_apm_plugin_context'; -import { - UrlParamsContext, - useUiFilters, -} from '../../../context/url_params_context/url_params_context'; +import { UrlParamsContext } from '../../../context/url_params_context/url_params_context'; import { IUrlParams } from '../../../context/url_params_context/types'; import { DatePicker } from './'; @@ -35,7 +32,7 @@ function MockUrlParamsProvider({ rangeId: 0, refreshTimeRange: mockRefreshTimeRange, urlParams, - uiFilters: useUiFilters(urlParams), + uiFilters: {}, }} children={children} /> diff --git a/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/use_transaction_breakdown.ts b/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/use_transaction_breakdown.ts index 293a1929ca606..a80c859459557 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/use_transaction_breakdown.ts +++ b/x-pack/plugins/apm/public/components/shared/charts/transaction_breakdown_chart/use_transaction_breakdown.ts @@ -12,8 +12,9 @@ import { useApmServiceContext } from '../../../../context/apm_service/use_apm_se export function useTransactionBreakdown() { const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams, uiFilters } = useUrlParams(); - const { environment, start, end, transactionName } = urlParams; + const { + urlParams: { environment, kuery, start, end, transactionName }, + } = useUrlParams(); const { transactionType } = useApmServiceContext(); const { data = { timeseries: undefined }, error, status } = useFetcher( @@ -26,11 +27,11 @@ export function useTransactionBreakdown() { path: { serviceName }, query: { environment, + kuery, start, end, transactionName, transactionType, - uiFilters: JSON.stringify(uiFilters), }, }, }); @@ -38,12 +39,12 @@ export function useTransactionBreakdown() { }, [ environment, + kuery, serviceName, start, end, transactionType, transactionName, - uiFilters, ] ); diff --git a/x-pack/plugins/apm/public/components/shared/charts/transaction_error_rate_chart/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/transaction_error_rate_chart/index.tsx index a3da8812966f1..b3c38651ea178 100644 --- a/x-pack/plugins/apm/public/components/shared/charts/transaction_error_rate_chart/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/charts/transaction_error_rate_chart/index.tsx @@ -31,9 +31,10 @@ export function TransactionErrorRateChart({ }: Props) { const theme = useTheme(); const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams, uiFilters } = useUrlParams(); + const { + urlParams: { environment, kuery, start, end, transactionName }, + } = useUrlParams(); const { transactionType } = useApmServiceContext(); - const { environment, start, end, transactionName } = urlParams; const { data, status } = useFetcher( (callApmApi) => { @@ -47,11 +48,11 @@ export function TransactionErrorRateChart({ }, query: { environment, + kuery, start, end, transactionType, transactionName, - uiFilters: JSON.stringify(uiFilters), }, }, }); @@ -59,10 +60,10 @@ export function TransactionErrorRateChart({ }, [ environment, + kuery, serviceName, start, end, - uiFilters, transactionType, transactionName, ] diff --git a/x-pack/plugins/apm/public/context/annotations/annotations_context.tsx b/x-pack/plugins/apm/public/context/annotations/annotations_context.tsx index 54a1d3a59eb20..ea2feb3d2a4ad 100644 --- a/x-pack/plugins/apm/public/context/annotations/annotations_context.tsx +++ b/x-pack/plugins/apm/public/context/annotations/annotations_context.tsx @@ -23,8 +23,9 @@ export function AnnotationsContextProvider({ children: React.ReactNode; }) { const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams } = useUrlParams(); - const { environment, start, end } = urlParams; + const { + urlParams: { environment, start, end }, + } = useUrlParams(); const { data = INITIAL_STATE } = useFetcher( (callApmApi) => { @@ -36,15 +37,15 @@ export function AnnotationsContextProvider({ serviceName, }, query: { + environment, start, end, - environment, }, }, }); } }, - [start, end, environment, serviceName] + [environment, start, end, serviceName] ); return ; diff --git a/x-pack/plugins/apm/public/context/url_params_context/mock_url_params_context_provider.tsx b/x-pack/plugins/apm/public/context/url_params_context/mock_url_params_context_provider.tsx index 7a561072d4bb2..6f34e9dec59e5 100644 --- a/x-pack/plugins/apm/public/context/url_params_context/mock_url_params_context_provider.tsx +++ b/x-pack/plugins/apm/public/context/url_params_context/mock_url_params_context_provider.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { IUrlParams } from './types'; -import { UrlParamsContext, useUiFilters } from './url_params_context'; +import { UrlParamsContext } from './url_params_context'; const defaultUrlParams = { page: 0, @@ -35,7 +35,7 @@ export function MockUrlParamsContextProvider({ rangeId: 0, refreshTimeRange, urlParams, - uiFilters: useUiFilters(urlParams), + uiFilters: {}, }} children={children} /> diff --git a/x-pack/plugins/apm/public/context/url_params_context/url_params_context.tsx b/x-pack/plugins/apm/public/context/url_params_context/url_params_context.tsx index 90245b9843b01..bb29d1c40b5e2 100644 --- a/x-pack/plugins/apm/public/context/url_params_context/url_params_context.tsx +++ b/x-pack/plugins/apm/public/context/url_params_context/url_params_context.tsx @@ -30,16 +30,12 @@ export interface TimeRange { } function useUiFilters(params: IUrlParams): UIFilters { - const { kuery, environment, ...urlParams } = params; const localUiFilters = mapValues( - pickKeys(urlParams, ...localUIFilterNames), + pickKeys(params, ...localUIFilterNames), (val) => (val ? val.split(',') : []) ) as Partial>; - return useDeepObjectIdentity({ - kuery, - ...localUiFilters, - }); + return useDeepObjectIdentity(localUiFilters); } const defaultRefresh = (_time: TimeRange) => {}; diff --git a/x-pack/plugins/apm/public/hooks/use_error_group_distribution_fetcher.tsx b/x-pack/plugins/apm/public/hooks/use_error_group_distribution_fetcher.tsx index 9ff179e6af6a0..3ef685abe0847 100644 --- a/x-pack/plugins/apm/public/hooks/use_error_group_distribution_fetcher.tsx +++ b/x-pack/plugins/apm/public/hooks/use_error_group_distribution_fetcher.tsx @@ -15,8 +15,9 @@ export function useErrorGroupDistributionFetcher({ serviceName: string; groupId: string | undefined; }) { - const { urlParams, uiFilters } = useUrlParams(); - const { environment, start, end } = urlParams; + const { + urlParams: { environment, kuery, start, end }, + } = useUrlParams(); const { data } = useFetcher( (callApmApi) => { if (start && end) { @@ -26,16 +27,16 @@ export function useErrorGroupDistributionFetcher({ path: { serviceName }, query: { environment, + kuery, start, end, groupId, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [environment, serviceName, start, end, groupId, uiFilters] + [environment, kuery, serviceName, start, end, groupId] ); return { errorDistributionData: data }; diff --git a/x-pack/plugins/apm/public/hooks/use_service_metric_charts_fetcher.ts b/x-pack/plugins/apm/public/hooks/use_service_metric_charts_fetcher.ts index 87e10f1e8937b..baf3eb51ae033 100644 --- a/x-pack/plugins/apm/public/hooks/use_service_metric_charts_fetcher.ts +++ b/x-pack/plugins/apm/public/hooks/use_service_metric_charts_fetcher.ts @@ -21,10 +21,12 @@ export function useServiceMetricChartsFetcher({ }: { serviceNodeName: string | undefined; }) { - const { urlParams, uiFilters } = useUrlParams(); + const { + urlParams: { environment, kuery, start, end }, + } = useUrlParams(); const { agentName } = useApmServiceContext(); const { serviceName } = useParams<{ serviceName?: string }>(); - const { environment, start, end } = urlParams; + const { data = INITIAL_DATA, error, status } = useFetcher( (callApmApi) => { if (serviceName && start && end && agentName) { @@ -34,25 +36,17 @@ export function useServiceMetricChartsFetcher({ path: { serviceName }, query: { environment, + kuery, serviceNodeName, start, end, agentName, - uiFilters: JSON.stringify(uiFilters), }, }, }); } }, - [ - environment, - serviceName, - start, - end, - agentName, - serviceNodeName, - uiFilters, - ] + [environment, kuery, serviceName, start, end, agentName, serviceNodeName] ); return { diff --git a/x-pack/plugins/apm/public/hooks/use_transaction_distribution_fetcher.ts b/x-pack/plugins/apm/public/hooks/use_transaction_distribution_fetcher.ts index c493a30716aa5..25632d4b19cf4 100644 --- a/x-pack/plugins/apm/public/hooks/use_transaction_distribution_fetcher.ts +++ b/x-pack/plugins/apm/public/hooks/use_transaction_distribution_fetcher.ts @@ -23,16 +23,18 @@ const INITIAL_DATA = { export function useTransactionDistributionFetcher() { const { serviceName } = useParams<{ serviceName?: string }>(); - const { urlParams, uiFilters } = useUrlParams(); const { - environment, - start, - end, - transactionType, - transactionId, - traceId, - transactionName, - } = urlParams; + urlParams: { + environment, + kuery, + start, + end, + transactionType, + transactionId, + traceId, + transactionName, + }, + } = useUrlParams(); const history = useHistory(); const { data = INITIAL_DATA, status, error } = useFetcher( @@ -47,13 +49,13 @@ export function useTransactionDistributionFetcher() { }, query: { environment, + kuery, start, end, transactionType, transactionName, transactionId, traceId, - uiFilters: JSON.stringify(uiFilters), }, }, }); @@ -96,12 +98,12 @@ export function useTransactionDistributionFetcher() { // eslint-disable-next-line react-hooks/exhaustive-deps [ environment, + kuery, serviceName, start, end, transactionType, transactionName, - uiFilters, ] ); diff --git a/x-pack/plugins/apm/public/hooks/use_transaction_latency_chart_fetcher.ts b/x-pack/plugins/apm/public/hooks/use_transaction_latency_chart_fetcher.ts index cca2e99d84dfd..b92b812bdd430 100644 --- a/x-pack/plugins/apm/public/hooks/use_transaction_latency_chart_fetcher.ts +++ b/x-pack/plugins/apm/public/hooks/use_transaction_latency_chart_fetcher.ts @@ -20,12 +20,12 @@ export function useTransactionLatencyChartsFetcher() { const { urlParams: { environment, + kuery, start, end, transactionName, latencyAggregationType, }, - uiFilters, } = useUrlParams(); const { data, error, status } = useFetcher( @@ -44,11 +44,11 @@ export function useTransactionLatencyChartsFetcher() { path: { serviceName }, query: { environment, + kuery, start, end, transactionType, transactionName, - uiFilters: JSON.stringify(uiFilters), latencyAggregationType, }, }, @@ -57,12 +57,12 @@ export function useTransactionLatencyChartsFetcher() { }, [ environment, + kuery, serviceName, start, end, transactionName, transactionType, - uiFilters, latencyAggregationType, ] ); diff --git a/x-pack/plugins/apm/public/hooks/use_transaction_throughput_chart_fetcher.ts b/x-pack/plugins/apm/public/hooks/use_transaction_throughput_chart_fetcher.ts index 55765cd40c04e..c8ae4fa5823a4 100644 --- a/x-pack/plugins/apm/public/hooks/use_transaction_throughput_chart_fetcher.ts +++ b/x-pack/plugins/apm/public/hooks/use_transaction_throughput_chart_fetcher.ts @@ -18,8 +18,7 @@ export function useTransactionThroughputChartsFetcher() { const { transactionType } = useApmServiceContext(); const theme = useTheme(); const { - urlParams: { environment, start, end, transactionName }, - uiFilters, + urlParams: { environment, kuery, start, end, transactionName }, } = useUrlParams(); const { data, error, status } = useFetcher( @@ -32,11 +31,11 @@ export function useTransactionThroughputChartsFetcher() { path: { serviceName }, query: { environment, + kuery, start, end, transactionType, transactionName, - uiFilters: JSON.stringify(uiFilters), }, }, }); @@ -44,12 +43,12 @@ export function useTransactionThroughputChartsFetcher() { }, [ environment, + kuery, serviceName, start, end, transactionName, transactionType, - uiFilters, ] ); diff --git a/x-pack/plugins/apm/public/utils/testHelpers.tsx b/x-pack/plugins/apm/public/utils/testHelpers.tsx index f7f6f7486091b..80df113e18190 100644 --- a/x-pack/plugins/apm/public/utils/testHelpers.tsx +++ b/x-pack/plugins/apm/public/utils/testHelpers.tsx @@ -17,7 +17,6 @@ import React from 'react'; import { MemoryRouter } from 'react-router-dom'; import { EuiThemeProvider } from '../../../../../src/plugins/kibana_react/common'; import { - ESFilter, ESSearchRequest, ESSearchResponse, } from '../../../../typings/elasticsearch'; @@ -121,7 +120,6 @@ interface MockSetup { internalClient: any; config: APMConfig; uiFilters: UIFilters; - esFilter: ESFilter[]; indices: { /* eslint-disable @typescript-eslint/naming-convention */ 'apm_oss.sourcemapIndices': string; @@ -183,7 +181,6 @@ export async function inspectSearchParams( } ) as APMConfig, uiFilters: {}, - esFilter: [], indices: { /* eslint-disable @typescript-eslint/naming-convention */ 'apm_oss.sourcemapIndices': 'myIndex', diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts index 3457207eeee3c..86456114698cb 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts +++ b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts @@ -13,7 +13,7 @@ import { TRANSACTION_TYPE, } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { AlertParams } from '../../../routes/alerts/chart_preview'; import { withApmSpan } from '../../../utils/with_apm_span'; import { getBucketSize } from '../../helpers/get_bucket_size'; diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts index aa85c44284d9d..2cf1317dc44b0 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts +++ b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_count.ts @@ -8,7 +8,7 @@ import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; import { AlertParams } from '../../../routes/alerts/chart_preview'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts index 88e249a71a81f..f0c8d23e0e8fa 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts +++ b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_error_rate.ts @@ -12,7 +12,7 @@ import { } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; import { AlertParams } from '../../../routes/alerts/chart_preview'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; import { diff --git a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts index c7861eaa819ae..cf31ff69bad27 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_error_count_alert_type.ts @@ -27,7 +27,7 @@ import { SERVICE_NAME, } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; -import { environmentQuery } from '../../../common/utils/queries'; +import { environmentQuery } from '../../../server/utils/queries'; import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts index 704aee932a604..6de9ca6db8c12 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts @@ -20,7 +20,7 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; import { getDurationFormatter } from '../../../common/utils/formatters'; -import { environmentQuery } from '../../../common/utils/queries'; +import { environmentQuery } from '../../../server/utils/queries'; import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts index 6f58b7714d832..b9923cc339ac2 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_error_rate_alert_type.ts @@ -22,7 +22,7 @@ import { import { EventOutcome } from '../../../common/event_outcome'; import { ProcessorEvent } from '../../../common/processor_event'; import { asDecimalOrInteger } from '../../../common/utils/formatters'; -import { environmentQuery } from '../../../common/utils/queries'; +import { environmentQuery } from '../../../server/utils/queries'; import { getApmIndices } from '../settings/apm_indices/get_apm_indices'; import { apmActionVariables } from './action_variables'; import { alertingEsClient } from './alerting_es_client'; diff --git a/x-pack/plugins/apm/server/lib/anomaly_detection/create_anomaly_detection_jobs.ts b/x-pack/plugins/apm/server/lib/anomaly_detection/create_anomaly_detection_jobs.ts index d70e19bf4a5f5..dd36e7cbeb24e 100644 --- a/x-pack/plugins/apm/server/lib/anomaly_detection/create_anomaly_detection_jobs.ts +++ b/x-pack/plugins/apm/server/lib/anomaly_detection/create_anomaly_detection_jobs.ts @@ -11,7 +11,7 @@ import { snakeCase } from 'lodash'; import Boom from '@hapi/boom'; import { ML_ERRORS } from '../../../common/anomaly_detection'; import { ProcessorEvent } from '../../../common/processor_event'; -import { environmentQuery } from '../../../common/utils/queries'; +import { environmentQuery } from '../../../server/utils/queries'; import { Setup } from '../helpers/setup_request'; import { TRANSACTION_DURATION, 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 ecefdfc2b3d9b..e2411d1d17adc 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 @@ -13,7 +13,11 @@ import { } from '../process_significant_term_aggs'; import { AggregationOptionsByType } from '../../../../../../typings/elasticsearch/aggregations'; import { ESFilter } from '../../../../../../typings/elasticsearch'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { EVENT_OUTCOME, SERVICE_NAME, @@ -32,6 +36,7 @@ import { withApmSpan } from '../../../utils/with_apm_span'; export async function getCorrelationsForFailedTransactions({ environment, + kuery, serviceName, transactionType, transactionName, @@ -39,6 +44,7 @@ export async function getCorrelationsForFailedTransactions({ setup, }: { environment?: string; + kuery?: string; serviceName: string | undefined; transactionType: string | undefined; transactionName: string | undefined; @@ -46,13 +52,13 @@ export async function getCorrelationsForFailedTransactions({ setup: Setup & SetupTimeRange; }) { return withApmSpan('get_correlations_for_failed_transactions', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const backgroundFilters: ESFilter[] = [ { term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; if (serviceName) { 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 832b89a18d102..824b290a6ba60 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 @@ -7,7 +7,11 @@ import { AggregationOptionsByType } from '../../../../../../typings/elasticsearch/aggregations'; import { ESFilter } from '../../../../../../typings/elasticsearch'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { SERVICE_NAME, TRANSACTION_DURATION, @@ -24,6 +28,7 @@ import { withApmSpan } from '../../../utils/with_apm_span'; export async function getCorrelationsForSlowTransactions({ environment, + kuery, serviceName, transactionType, transactionName, @@ -32,6 +37,7 @@ export async function getCorrelationsForSlowTransactions({ setup, }: { environment?: string; + kuery?: string; serviceName: string | undefined; transactionType: string | undefined; transactionName: string | undefined; @@ -40,13 +46,13 @@ export async function getCorrelationsForSlowTransactions({ setup: Setup & SetupTimeRange; }) { return withApmSpan('get_correlations_for_slow_transactions', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const backgroundFilters: ESFilter[] = [ { term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; if (serviceName) { diff --git a/x-pack/plugins/apm/server/lib/environments/get_environments.ts b/x-pack/plugins/apm/server/lib/environments/get_environments.ts index af88493c148ce..509e4cdcd67ac 100644 --- a/x-pack/plugins/apm/server/lib/environments/get_environments.ts +++ b/x-pack/plugins/apm/server/lib/environments/get_environments.ts @@ -11,7 +11,7 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values'; import { ProcessorEvent } from '../../../common/processor_event'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/errors/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/errors/__snapshots__/queries.test.ts.snap index 632232ffb075d..c0d928ebd70f6 100644 --- a/x-pack/plugins/apm/server/lib/errors/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/errors/__snapshots__/queries.test.ts.snap @@ -30,11 +30,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], "should": Array [ Object { @@ -117,11 +112,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -192,11 +182,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/queries.test.ts.snap index b329499c8b045..121cbe226d387 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/queries.test.ts.snap @@ -38,11 +38,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -89,11 +84,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "error.grouping_key": "foo", diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts index 1712699162b73..b1260d653f3de 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts @@ -44,7 +44,6 @@ describe('get buckets', () => { } ) as APMConfig, uiFilters: {}, - esFilter: [], indices: { /* eslint-disable @typescript-eslint/naming-convention */ 'apm_oss.sourcemapIndices': 'apm-*', diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts index fbe406d8d1a9d..1e161b0383f0b 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts @@ -11,30 +11,36 @@ import { SERVICE_NAME, } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; export async function getBuckets({ environment, + kuery, serviceName, groupId, bucketSize, setup, }: { environment?: string; + kuery?: string; serviceName: string; groupId?: string; bucketSize: number; setup: Setup & SetupTimeRange; }) { return withApmSpan('get_error_distribution_buckets', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const filter: ESFilter[] = [ { term: { [SERVICE_NAME]: serviceName } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; if (groupId) { diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts index 1fb0cbad4a5f0..6bb43a395f235 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts @@ -15,11 +15,13 @@ function getBucketSize({ start, end }: SetupTimeRange) { export async function getErrorDistribution({ environment, + kuery, serviceName, groupId, setup, }: { environment?: string; + kuery?: string; serviceName: string; groupId?: string; setup: Setup & SetupTimeRange; @@ -27,6 +29,7 @@ export async function getErrorDistribution({ const bucketSize = getBucketSize({ start: setup.start, end: setup.end }); const { buckets, noHits } = await getBuckets({ environment, + kuery, serviceName, groupId, bucketSize, diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts b/x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts index 0ab26f3c6e969..d4ad2c8a9b2cb 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts +++ b/x-pack/plugins/apm/server/lib/errors/get_error_group_sample.ts @@ -11,24 +11,30 @@ import { TRANSACTION_SAMPLED, } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { getTransaction } from '../transactions/get_transaction'; export function getErrorGroupSample({ environment, + kuery, serviceName, groupId, setup, }: { environment?: string; + kuery?: string; serviceName: string; groupId: string; setup: Setup & SetupTimeRange; }) { return withApmSpan('get_error_group_sample', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const params = { apm: { @@ -43,7 +49,7 @@ export function getErrorGroupSample({ { term: { [ERROR_GROUP_ID]: groupId } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], should: [{ term: { [TRANSACTION_SAMPLED]: true } }], }, diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts b/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts index 28d89eb057470..5371d69caaa99 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts +++ b/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts @@ -22,12 +22,14 @@ import { Setup, SetupTimeRange } from '../helpers/setup_request'; export function getErrorGroups({ environment, + kuery, serviceName, sortField, sortDirection = 'desc', setup, }: { environment?: string; + kuery?: string; serviceName: string; sortField?: string; sortDirection?: 'asc' | 'desc'; @@ -41,6 +43,7 @@ export function getErrorGroups({ const projection = getErrorGroupsProjection({ environment, + kuery, setup, serviceName, }); diff --git a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts index 71744c3e59092..394cf6b988f12 100644 --- a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts @@ -6,7 +6,7 @@ */ import { SearchAggregatedTransactionSetting } from '../../../../common/aggregated_transactions'; -import { rangeQuery } from '../../../../common/utils/queries'; +import { rangeQuery } from '../../../../server/utils/queries'; import { ProcessorEvent } from '../../../../common/processor_event'; import { TRANSACTION_DURATION, diff --git a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts index b12a396befe8c..60fb9a8bfa85a 100644 --- a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts +++ b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts @@ -10,14 +10,12 @@ import { isActivePlatinumLicense } from '../../../common/license_check'; import { APMConfig } from '../..'; import { KibanaRequest } from '../../../../../../src/core/server'; import { UI_SETTINGS } from '../../../../../../src/plugins/data/common'; -import { ESFilter } from '../../../../../typings/elasticsearch'; import { UIFilters } from '../../../typings/ui_filters'; import { APMRequestHandlerContext } from '../../routes/typings'; import { ApmIndicesConfig, getApmIndices, } from '../settings/apm_indices/get_apm_indices'; -import { getEsFilter } from './convert_ui_filters/get_es_filter'; import { APMEventClient, createApmEventClient, @@ -38,7 +36,6 @@ export interface Setup { config: APMConfig; indices: ApmIndicesConfig; uiFilters: UIFilters; - esFilter: ESFilter[]; } export interface SetupTimeRange { @@ -110,7 +107,6 @@ export async function setupRequest( : undefined, config, uiFilters, - esFilter: getEsFilter(uiFilters), }; return { diff --git a/x-pack/plugins/apm/server/lib/metrics/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/metrics/__snapshots__/queries.test.ts.snap index 4eed09f3e5c28..ad91356ac6448 100644 --- a/x-pack/plugins/apm/server/lib/metrics/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/metrics/__snapshots__/queries.test.ts.snap @@ -85,11 +85,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -173,11 +168,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -336,11 +326,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "exists": Object { "field": "system.process.cgroup.memory.mem.usage.bytes", @@ -429,11 +414,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -512,11 +492,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -621,11 +596,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -715,11 +685,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -884,11 +849,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "exists": Object { "field": "system.process.cgroup.memory.mem.usage.bytes", @@ -983,11 +943,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -1072,11 +1027,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -1170,11 +1120,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -1253,11 +1198,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -1411,11 +1351,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "exists": Object { "field": "system.process.cgroup.memory.mem.usage.bytes", @@ -1499,11 +1434,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", @@ -1577,11 +1507,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "term": Object { "agent.name": "java", diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts index c5e80600b69d4..e4d6d2e77f73c 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/default.ts @@ -11,16 +11,18 @@ import { getMemoryChartData } from './shared/memory'; export async function getDefaultMetricsCharts({ environment, + kuery, serviceName, setup, }: { environment?: string; + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; }) { const charts = await Promise.all([ - getCPUChartData({ environment, setup, serviceName }), - getMemoryChartData({ environment, setup, serviceName }), + getCPUChartData({ environment, kuery, setup, serviceName }), + getMemoryChartData({ environment, kuery, setup, serviceName }), ]); return { charts }; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts index d7c9294c8ec7a..9f83af989fc57 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts @@ -23,6 +23,7 @@ import { getVizColorForIndex } from '../../../../../../common/viz_colors'; export async function fetchAndTransformGcMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, @@ -30,6 +31,7 @@ export async function fetchAndTransformGcMetrics({ fieldName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -42,6 +44,7 @@ export async function fetchAndTransformGcMetrics({ const projection = getMetricsProjection({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts index 8c5b9fb3db922..388331f3bbf17 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_rate_chart.ts @@ -34,11 +34,13 @@ const chartBase: ChartBase = { function getGcRateChart({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -46,6 +48,7 @@ function getGcRateChart({ return withApmSpan('get_gc_rate_charts', () => fetchAndTransformGcMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts index 98f31f06c1b64..e6f80190d1daa 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/get_gc_time_chart.ts @@ -34,11 +34,13 @@ const chartBase: ChartBase = { function getGcTimeChart({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -46,6 +48,7 @@ function getGcTimeChart({ return withApmSpan('get_gc_time_charts', () => fetchAndTransformGcMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts index d6cbc4a07e8f9..7630827a3cb38 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/heap_memory/index.ts @@ -54,11 +54,13 @@ const chartBase: ChartBase = { export function getHeapMemoryChart({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -66,6 +68,7 @@ export function getHeapMemoryChart({ return withApmSpan('get_heap_memory_charts', () => fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts index 970b4d3499b79..5a266b57bd598 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/index.ts @@ -17,29 +17,34 @@ import { getGcTimeChart } from './gc/get_gc_time_chart'; export function getJavaMetricsCharts({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; }) { return withApmSpan('get_java_system_metric_charts', async () => { + const options = { + environment, + kuery, + setup, + serviceName, + serviceNodeName, + }; + const charts = await Promise.all([ - getCPUChartData({ environment, setup, serviceName, serviceNodeName }), - getMemoryChartData({ environment, setup, serviceName, serviceNodeName }), - getHeapMemoryChart({ environment, setup, serviceName, serviceNodeName }), - getNonHeapMemoryChart({ - environment, - setup, - serviceName, - serviceNodeName, - }), - getThreadCountChart({ environment, setup, serviceName, serviceNodeName }), - getGcRateChart({ environment, setup, serviceName, serviceNodeName }), - getGcTimeChart({ environment, setup, serviceName, serviceNodeName }), + getCPUChartData(options), + getMemoryChartData(options), + getHeapMemoryChart(options), + getNonHeapMemoryChart(options), + getThreadCountChart(options), + getGcRateChart(options), + getGcTimeChart(options), ]); return { charts }; diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts index 25abd2c34c83a..cd11e5e5383b6 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/non_heap_memory/index.ts @@ -51,11 +51,13 @@ const chartBase: ChartBase = { export async function getNonHeapMemoryChart({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -63,6 +65,7 @@ export async function getNonHeapMemoryChart({ return withApmSpan('get_non_heap_memory_charts', () => fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts index c8a209fee701a..8d4c079197d19 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/thread_count/index.ts @@ -43,11 +43,13 @@ const chartBase: ChartBase = { export async function getThreadCountChart({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -55,6 +57,7 @@ export async function getThreadCountChart({ return withApmSpan('get_thread_count_charts', () => fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts index ebfe504e5269b..37bef191ae876 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/cpu/index.ts @@ -55,11 +55,13 @@ const chartBase: ChartBase = { export function getCPUChartData({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -67,6 +69,7 @@ export function getCPUChartData({ return withApmSpan('get_cpu_metric_charts', () => fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts index 55b3328bcd2a9..c58fb170bd2b0 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/shared/memory/index.ts @@ -72,11 +72,13 @@ export const percentCgroupMemoryUsedScript = { export async function getMemoryChartData({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -87,6 +89,7 @@ export async function getMemoryChartData({ () => fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, @@ -105,6 +108,7 @@ export async function getMemoryChartData({ return await withApmSpan('get_system_memory_metrics_charts', () => fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts b/x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts index 17e9aef29ba82..ef24b531d8046 100644 --- a/x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts +++ b/x-pack/plugins/apm/server/lib/metrics/fetch_and_transform_metrics.ts @@ -49,6 +49,7 @@ interface Filter { export async function fetchAndTransformMetrics({ environment, + kuery, setup, serviceName, serviceNodeName, @@ -57,6 +58,7 @@ export async function fetchAndTransformMetrics({ additionalFilters = [], }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -68,6 +70,7 @@ export async function fetchAndTransformMetrics({ const projection = getMetricsProjection({ environment, + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts b/x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts index eda71ef380ee9..8e7008ef913fa 100644 --- a/x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts +++ b/x-pack/plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent.ts @@ -16,12 +16,14 @@ export interface MetricsChartsByAgentAPIResponse { export async function getMetricsChartDataByAgent({ environment, + kuery, setup, serviceName, serviceNodeName, agentName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; @@ -31,6 +33,7 @@ export async function getMetricsChartDataByAgent({ case 'java': { return getJavaMetricsCharts({ environment, + kuery, setup, serviceName, serviceNodeName, @@ -38,7 +41,12 @@ export async function getMetricsChartDataByAgent({ } default: { - return getDefaultMetricsCharts({ environment, setup, serviceName }); + return getDefaultMetricsCharts({ + environment, + kuery, + setup, + serviceName, + }); } } } diff --git a/x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts b/x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts index c7ac678899b58..2ccbe318862f1 100644 --- a/x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts +++ b/x-pack/plugins/apm/server/lib/observability_overview/get_service_count.ts @@ -6,7 +6,7 @@ */ import { ProcessorEvent } from '../../../common/processor_event'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; diff --git a/x-pack/plugins/apm/server/lib/observability_overview/get_transaction_coordinates.ts b/x-pack/plugins/apm/server/lib/observability_overview/get_transaction_coordinates.ts index 2da4b0f8de363..aac18e2bdfe4c 100644 --- a/x-pack/plugins/apm/server/lib/observability_overview/get_transaction_coordinates.ts +++ b/x-pack/plugins/apm/server/lib/observability_overview/get_transaction_coordinates.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { Coordinates } from '../../../../observability/typings/common'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; diff --git a/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap index 6b4bc844f21c3..79eb0fbce5498 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap @@ -58,11 +58,6 @@ Object { "transaction.type": "page-load", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -158,11 +153,6 @@ Object { "service.language.name": "javascript", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -237,11 +227,6 @@ Object { "field": "transaction.marks.navigationTiming.fetchStart", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -507,11 +492,6 @@ Object { "field": "transaction.marks.navigationTiming.fetchStart", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -554,11 +534,6 @@ Object { "transaction.type": "page-load", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -676,11 +651,6 @@ Object { "field": "transaction.marks.navigationTiming.fetchStart", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -727,11 +697,6 @@ Object { "field": "transaction.marks.navigationTiming.fetchStart", }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts b/x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts index 9626019347e5b..ec96b5225d617 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts @@ -11,7 +11,7 @@ import { TRANSACTION_TYPE, } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { TRANSACTION_PAGE_LOAD } from '../../../common/transaction_types'; export async function hasRumData({ setup }: { setup: Setup & SetupTimeRange }) { diff --git a/x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/get_es_filter.ts b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts similarity index 58% rename from x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/get_es_filter.ts rename to x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts index e91c9b52deecf..aed361f13bd7d 100644 --- a/x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/get_es_filter.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts @@ -7,14 +7,10 @@ import { ESFilter } from '../../../../../../typings/elasticsearch'; import { UIFilters } from '../../../../typings/ui_filters'; -import { - localUIFilters, - localUIFilterNames, -} from '../../rum_client/ui_filters/local_ui_filters/config'; -import { esKuery } from '../../../../../../../src/plugins/data/server'; +import { localUIFilters, localUIFilterNames } from './local_ui_filters/config'; export function getEsFilter(uiFilters: UIFilters) { - const { kuery, environment, ...localFilterValues } = uiFilters; + const localFilterValues = uiFilters; const mappedFilters = localUIFilterNames .filter((name) => name in localFilterValues) .map((filterName) => { @@ -27,16 +23,5 @@ export function getEsFilter(uiFilters: UIFilters) { }; }) as ESFilter[]; - const esFilters = [...getKueryUiFilterES(uiFilters.kuery), ...mappedFilters]; - - return esFilters; -} - -function getKueryUiFilterES(kuery?: string) { - if (!kuery) { - return []; - } - - const ast = esKuery.fromKueryExpression(kuery); - return [esKuery.toElasticsearchQuery(ast) as ESFilter]; + return mappedFilters; } diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/__snapshots__/index.test.ts.snap b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/__snapshots__/index.test.ts.snap index 40504cec36a63..9742d89587841 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/__snapshots__/index.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/__snapshots__/index.test.ts.snap @@ -44,11 +44,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/get_local_filter_query.ts b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/get_local_filter_query.ts index 8ea635467d0a1..a904bfe337a6b 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/get_local_filter_query.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/get_local_filter_query.ts @@ -9,7 +9,7 @@ import { omit } from 'lodash'; import { mergeProjection } from '../../../../projections/util/merge_projection'; import { Projection } from '../../../../projections/typings'; import { UIFilters } from '../../../../../typings/ui_filters'; -import { getEsFilter } from '../../../helpers/convert_ui_filters/get_es_filter'; +import { getEsFilter } from '../get_es_filter'; import { localUIFilters } from './config'; import { LocalUIFilterName } from '../../../../../common/ui_filter'; diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/index.test.ts b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/index.test.ts index 7254bb25cc5fe..e2ccc43374db7 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/index.test.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/local_ui_filters/index.test.ts @@ -16,7 +16,7 @@ describe('getLocalUIFilters', () => { let mock: SearchParamsMock; beforeEach(() => { - jest.mock('../../../helpers/convert_ui_filters/get_es_filter', () => { + jest.mock('../get_es_filter', () => { return []; }); }); diff --git a/x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts b/x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts index 259a0e6daea6f..64de74fb9023b 100644 --- a/x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts +++ b/x-pack/plugins/apm/server/lib/service_map/fetch_service_paths_from_trace_ids.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { ProcessorEvent } from '../../../common/processor_event'; import { TRACE_ID } from '../../../common/elasticsearch_fieldnames'; import { diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts b/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts index ab221e30ea489..f08cc27b2e59c 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts @@ -17,7 +17,7 @@ import { TRANSACTION_PAGE_LOAD, TRANSACTION_REQUEST, } from '../../../common/transaction_types'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { getMlJobsWithAPMGroup } from '../anomaly_detection/get_ml_jobs_with_apm_group'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map.ts b/x-pack/plugins/apm/server/lib/service_map/get_service_map.ts index 1aee1bb5b242a..e5b0b72b8784a 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_service_map.ts @@ -15,7 +15,7 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { getServicesProjection } from '../../projections/services'; import { mergeProjection } from '../../projections/util/merge_projection'; -import { environmentQuery } from '../../../common/utils/queries'; +import { environmentQuery } from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { @@ -91,7 +91,7 @@ async function getServicesData(options: IEnvOptions) { const { environment, setup, searchAggregatedTransactions } = options; const projection = getServicesProjection({ - setup: { ...setup, esFilter: [] }, + setup, searchAggregatedTransactions, }); diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts b/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts index b161345e729d3..d812275d7103b 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.test.ts @@ -19,7 +19,6 @@ describe('getServiceMapServiceNodeInfo', () => { hits: { total: { value: 0 } }, }), }, - esFilter: [], indices: {}, uiFilters: {}, } as unknown) as Setup & SetupTimeRange; diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts b/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts index 367fbc6810a7f..a6e7832bf697d 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_service_map_service_node_info.ts @@ -19,7 +19,7 @@ import { TRANSACTION_PAGE_LOAD, TRANSACTION_REQUEST, } from '../../../common/transaction_types'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { getDocumentTypeFilterForAggregatedTransactions, diff --git a/x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts b/x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts index e8dcb28baa9a3..2b949863bcb30 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_trace_sample_ids.ts @@ -16,7 +16,7 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../common/processor_event'; import { SERVICE_MAP_TIMEOUT_ERROR } from '../../../common/service_map'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/service_nodes/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/service_nodes/__snapshots__/queries.test.ts.snap index e6d702cc03c0b..8e47b7298cc33 100644 --- a/x-pack/plugins/apm/server/lib/service_nodes/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/service_nodes/__snapshots__/queries.test.ts.snap @@ -49,11 +49,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -117,11 +112,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -186,11 +176,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/service_nodes/index.ts b/x-pack/plugins/apm/server/lib/service_nodes/index.ts index a22c732a5e8ce..07b7e532d8055 100644 --- a/x-pack/plugins/apm/server/lib/service_nodes/index.ts +++ b/x-pack/plugins/apm/server/lib/service_nodes/index.ts @@ -18,16 +18,18 @@ import { withApmSpan } from '../../utils/with_apm_span'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; const getServiceNodes = ({ + kuery, setup, serviceName, }: { + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; }) => { return withApmSpan('get_service_nodes', async () => { const { apmEventClient } = setup; - const projection = getServiceNodesProjection({ setup, serviceName }); + const projection = getServiceNodesProjection({ kuery, setup, serviceName }); const params = mergeProjection(projection, { body: { diff --git a/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap index 0521ff7d9554d..dec5be8da32f4 100644 --- a/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap @@ -191,11 +191,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts b/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts index 25c42f403da2e..efe9608edb95d 100644 --- a/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts +++ b/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts @@ -12,7 +12,7 @@ import { SERVICE_NAME, SERVICE_VERSION, } from '../../../../common/elasticsearch_fieldnames'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; import { getDocumentTypeFilterForAggregatedTransactions, diff --git a/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts b/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts index 6c7cbc26ea653..87ee0e9830fce 100644 --- a/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts +++ b/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts @@ -7,7 +7,7 @@ import { ResponseError } from '@elastic/elasticsearch/lib/errors'; import { ElasticsearchClient, Logger } from 'kibana/server'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { unwrapEsResponse, WrappedElasticsearchClientError, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_agent_name.ts b/x-pack/plugins/apm/server/lib/services/get_service_agent_name.ts index 3683a069342a9..a81c0b2fc2c44 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_agent_name.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_agent_name.ts @@ -10,7 +10,7 @@ import { AGENT_NAME, SERVICE_NAME, } from '../../../common/elasticsearch_fieldnames'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; import { withApmSpan } from '../../utils/with_apm_span'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_destination_map.ts b/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_destination_map.ts index 558d6ae22f00f..cb9d37d56b867 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_destination_map.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_destination_map.ts @@ -20,7 +20,7 @@ import { SPAN_TYPE, } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { joinByKey } from '../../../../common/utils/join_by_key'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; import { withApmSpan } from '../../../utils/with_apm_span'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_metrics.ts b/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_metrics.ts index dfbdfb3f504e8..c8642c6272b5f 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_metrics.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_metrics.ts @@ -14,7 +14,7 @@ import { SPAN_DESTINATION_SERVICE_RESPONSE_TIME_SUM, } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { environmentQuery, rangeQuery } from '../../../../server/utils/queries'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { EventOutcome } from '../../../../common/event_outcome'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_comparison_statistics.ts b/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_comparison_statistics.ts index 3655fa513dfb4..e33044bff8ffa 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_comparison_statistics.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_comparison_statistics.ts @@ -11,12 +11,17 @@ import { TRANSACTION_TYPE, } from '../../../../common/elasticsearch_fieldnames'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; export async function getServiceErrorGroupComparisonStatistics({ + kuery, serviceName, setup, numBuckets, @@ -24,6 +29,7 @@ export async function getServiceErrorGroupComparisonStatistics({ groupIds, environment, }: { + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; numBuckets: number; @@ -34,7 +40,7 @@ export async function getServiceErrorGroupComparisonStatistics({ return withApmSpan( 'get_service_error_group_comparison_statistics', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const { intervalString } = getBucketSize({ start, end, numBuckets }); @@ -52,7 +58,7 @@ export async function getServiceErrorGroupComparisonStatistics({ { term: { [TRANSACTION_TYPE]: transactionType } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_primary_statistics.ts b/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_primary_statistics.ts index e6c1c5db8f2ca..13a6069876369 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_primary_statistics.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_error_groups/get_service_error_group_primary_statistics.ts @@ -14,24 +14,30 @@ import { } from '../../../../common/elasticsearch_fieldnames'; import { NOT_AVAILABLE_LABEL } from '../../../../common/i18n'; import { ProcessorEvent } from '../../../../common/processor_event'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; import { getErrorName } from '../../helpers/get_error_name'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; export function getServiceErrorGroupPrimaryStatistics({ + kuery, serviceName, setup, transactionType, environment, }: { + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; transactionType: string; environment?: string; }) { return withApmSpan('get_service_error_group_primary_statistics', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const response = await apmEventClient.search({ apm: { @@ -46,7 +52,7 @@ export function getServiceErrorGroupPrimaryStatistics({ { term: { [TRANSACTION_TYPE]: transactionType } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts b/x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts index a17fb6da2007f..676ba1625cc61 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_error_groups/index.ts @@ -9,7 +9,11 @@ import { ValuesType } from 'utility-types'; import { orderBy } from 'lodash'; import { NOT_AVAILABLE_LABEL } from '../../../../common/i18n'; import { PromiseReturnType } from '../../../../../observability/typings/common'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { ProcessorEvent } from '../../../../common/processor_event'; import { ERROR_EXC_MESSAGE, @@ -29,6 +33,7 @@ export type ServiceErrorGroupItem = ValuesType< export async function getServiceErrorGroups({ environment, + kuery, serviceName, setup, size, @@ -39,6 +44,7 @@ export async function getServiceErrorGroups({ transactionType, }: { environment?: string; + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; size: number; @@ -49,7 +55,7 @@ export async function getServiceErrorGroups({ transactionType: string; }) { return withApmSpan('get_service_error_groups', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const { intervalString } = getBucketSize({ start, end, numBuckets }); @@ -67,7 +73,7 @@ export async function getServiceErrorGroups({ { term: { [TRANSACTION_TYPE]: transactionType } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, @@ -150,7 +156,7 @@ export async function getServiceErrorGroups({ { term: { [TRANSACTION_TYPE]: transactionType } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_system_metric_stats.ts b/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_system_metric_stats.ts index ef90e5197229b..3e788ca8ddf83 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_system_metric_stats.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_system_metric_stats.ts @@ -6,7 +6,11 @@ */ import { AggregationOptionsByType } from '../../../../../../typings/elasticsearch'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes'; import { METRIC_CGROUP_MEMORY_USAGE_BYTES, @@ -27,13 +31,14 @@ import { withApmSpan } from '../../../utils/with_apm_span'; export async function getServiceInstanceSystemMetricStats({ environment, + kuery, setup, serviceName, size, numBuckets, }: ServiceInstanceParams) { return withApmSpan('get_service_instance_system_metric_stats', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const { intervalString } = getBucketSize({ start, end, numBuckets }); @@ -99,7 +104,7 @@ export async function getServiceInstanceSystemMetricStats({ { term: { [SERVICE_NAME]: serviceName } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], should: [cgroupMemoryFilter, systemMemoryFilter, cpuUsageFilter], minimum_should_match: 1, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_transaction_stats.ts b/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_transaction_stats.ts index 620fd9828bd37..94a5e54e9ace5 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_transaction_stats.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_instances/get_service_instance_transaction_stats.ts @@ -6,7 +6,11 @@ */ import { EventOutcome } from '../../../../common/event_outcome'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes'; import { EVENT_OUTCOME, @@ -29,6 +33,7 @@ import { export async function getServiceInstanceTransactionStats({ environment, + kuery, latencyAggregationType, setup, transactionType, @@ -38,7 +43,7 @@ export async function getServiceInstanceTransactionStats({ numBuckets, }: ServiceInstanceParams) { return withApmSpan('get_service_instance_transaction_stats', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const { intervalString, bucketSize } = getBucketSize({ start, @@ -78,7 +83,7 @@ export async function getServiceInstanceTransactionStats({ { term: { [TRANSACTION_TYPE]: transactionType } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_instances/index.ts b/x-pack/plugins/apm/server/lib/services/get_service_instances/index.ts index 7c0124f4ce004..838753890a8cd 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_instances/index.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_instances/index.ts @@ -14,6 +14,7 @@ import { getServiceInstanceTransactionStats } from './get_service_instance_trans export interface ServiceInstanceParams { environment?: string; + kuery?: string; latencyAggregationType: LatencyAggregationType; setup: Setup & SetupTimeRange; serviceName: string; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts b/x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts index 5c43191cf588c..a064d5b3008c2 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_metadata_details.ts @@ -21,7 +21,7 @@ import { SERVICE_VERSION, } from '../../../common/elasticsearch_fieldnames'; import { ContainerType } from '../../../common/service_metadata'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { TransactionRaw } from '../../../typings/es_schemas/raw/transaction_raw'; import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts b/x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts index b342ffea02464..94da6545c5e90 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_metadata_icons.ts @@ -16,7 +16,7 @@ import { HOST_OS_PLATFORM, } from '../../../common/elasticsearch_fieldnames'; import { ContainerType } from '../../../common/service_metadata'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { TransactionRaw } from '../../../typings/es_schemas/raw/transaction_raw'; import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts b/x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts index 16753db416edd..8eaf9e96c7fd9 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_node_metadata.ts @@ -16,10 +16,12 @@ import { getServiceNodesProjection } from '../../projections/service_nodes'; import { withApmSpan } from '../../utils/with_apm_span'; export function getServiceNodeMetadata({ + kuery, serviceName, serviceNodeName, setup, }: { + kuery?: string; serviceName: string; serviceNodeName: string; setup: Setup & SetupTimeRange; @@ -29,6 +31,7 @@ export function getServiceNodeMetadata({ const query = mergeProjection( getServiceNodesProjection({ + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_transaction_group_comparison_statistics.ts b/x-pack/plugins/apm/server/lib/services/get_service_transaction_group_comparison_statistics.ts index ce36db3e82bab..6875a41ad7d9f 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_transaction_group_comparison_statistics.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_transaction_group_comparison_statistics.ts @@ -14,7 +14,11 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { EventOutcome } from '../../../common/event_outcome'; import { LatencyAggregationType } from '../../../common/latency_aggregation_types'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../server/utils/queries'; import { Coordinate } from '../../../typings/timeseries'; import { withApmSpan } from '../../utils/with_apm_span'; import { @@ -32,6 +36,7 @@ import { calculateTransactionErrorPercentage } from '../helpers/transaction_erro export async function getServiceTransactionGroupComparisonStatistics({ environment, + kuery, serviceName, transactionNames, setup, @@ -41,6 +46,7 @@ export async function getServiceTransactionGroupComparisonStatistics({ latencyAggregationType, }: { environment?: string; + kuery?: string; serviceName: string; transactionNames: string[]; setup: Setup & SetupTimeRange; @@ -62,7 +68,7 @@ export async function getServiceTransactionGroupComparisonStatistics({ return withApmSpan( 'get_service_transaction_group_comparison_statistics', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const { intervalString } = getBucketSize({ start, end, numBuckets }); const field = getTransactionDurationFieldForAggregatedTransactions( @@ -89,7 +95,7 @@ export async function getServiceTransactionGroupComparisonStatistics({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts b/x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts index ddbfd617faf65..28574bab4df21 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_transaction_groups.ts @@ -13,7 +13,11 @@ import { } from '../../../common/elasticsearch_fieldnames'; import { EventOutcome } from '../../../common/event_outcome'; import { LatencyAggregationType } from '../../../common/latency_aggregation_types'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../server/utils/queries'; import { withApmSpan } from '../../utils/with_apm_span'; import { getDocumentTypeFilterForAggregatedTransactions, @@ -37,6 +41,7 @@ export type ServiceOverviewTransactionGroupSortField = export async function getServiceTransactionGroups({ environment, + kuery, serviceName, setup, searchAggregatedTransactions, @@ -44,6 +49,7 @@ export async function getServiceTransactionGroups({ latencyAggregationType, }: { environment?: string; + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; searchAggregatedTransactions: boolean; @@ -51,7 +57,7 @@ export async function getServiceTransactionGroups({ latencyAggregationType: LatencyAggregationType; }) { return withApmSpan('get_service_transaction_groups', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const field = getTransactionDurationFieldForAggregatedTransactions( searchAggregatedTransactions @@ -77,7 +83,7 @@ export async function getServiceTransactionGroups({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts b/x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts index 3d77bf5bd6baf..e280ab6db1665 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_transaction_types.ts @@ -9,7 +9,7 @@ import { SERVICE_NAME, TRANSACTION_TYPE, } from '../../../common/elasticsearch_fieldnames'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { getDocumentTypeFilterForAggregatedTransactions, diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts b/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts index a3adca0d306aa..b42fd340bfb42 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { rangeQuery } from '../../../../common/utils/queries'; +import { rangeQuery } from '../../../../server/utils/queries'; import { ProcessorEvent } from '../../../../common/processor_event'; import { OBSERVER_VERSION_MAJOR } from '../../../../common/elasticsearch_fieldnames'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts b/x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts index e1f8bca83829c..5f0302035462c 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services/get_service_transaction_stats.ts @@ -15,7 +15,11 @@ import { TRANSACTION_PAGE_LOAD, TRANSACTION_REQUEST, } from '../../../../common/transaction_types'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent'; import { getDocumentTypeFilterForAggregatedTransactions, @@ -33,6 +37,7 @@ import { withApmSpan } from '../../../utils/with_apm_span'; interface AggregationParams { environment?: string; + kuery?: string; setup: ServicesItemsSetup; searchAggregatedTransactions: boolean; } @@ -41,11 +46,12 @@ const MAX_NUMBER_OF_SERVICES = 500; export async function getServiceTransactionStats({ environment, + kuery, setup, searchAggregatedTransactions, }: AggregationParams) { return withApmSpan('get_service_transaction_stats', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const outcomes = getOutcomeAggregation(); @@ -78,7 +84,7 @@ export async function getServiceTransactionStats({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts b/x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts index c2677af038486..1ddc7a6583c81 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts @@ -17,11 +17,13 @@ export type ServicesItemsSetup = Setup & SetupTimeRange; export async function getServicesItems({ environment, + kuery, setup, searchAggregatedTransactions, logger, }: { environment?: string; + kuery?: string; setup: ServicesItemsSetup; searchAggregatedTransactions: boolean; logger: Logger; @@ -29,7 +31,9 @@ export async function getServicesItems({ return withApmSpan('get_services_items', async () => { const params = { environment, + kuery, projection: getServicesProjection({ + kuery, setup, searchAggregatedTransactions, }), diff --git a/x-pack/plugins/apm/server/lib/services/get_services/index.ts b/x-pack/plugins/apm/server/lib/services/get_services/index.ts index 1a0ddeda11651..e76eb3c28fddb 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/index.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services/index.ts @@ -15,11 +15,13 @@ import { hasHistoricalAgentData } from './has_historical_agent_data'; export async function getServices({ environment, + kuery, setup, searchAggregatedTransactions, logger, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; searchAggregatedTransactions: boolean; logger: Logger; @@ -28,6 +30,7 @@ export async function getServices({ const [items, hasLegacyData] = await Promise.all([ getServicesItems({ environment, + kuery, setup, searchAggregatedTransactions, logger, diff --git a/x-pack/plugins/apm/server/lib/services/get_throughput.ts b/x-pack/plugins/apm/server/lib/services/get_throughput.ts index f7cd23b0e37a7..490eec337840e 100644 --- a/x-pack/plugins/apm/server/lib/services/get_throughput.ts +++ b/x-pack/plugins/apm/server/lib/services/get_throughput.ts @@ -10,7 +10,11 @@ import { SERVICE_NAME, TRANSACTION_TYPE, } from '../../../common/elasticsearch_fieldnames'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../server/utils/queries'; import { getDocumentTypeFilterForAggregatedTransactions, getProcessorEventForAggregatedTransactions, @@ -21,6 +25,7 @@ import { withApmSpan } from '../../utils/with_apm_span'; interface Options { environment?: string; + kuery?: string; searchAggregatedTransactions: boolean; serviceName: string; setup: Setup; @@ -31,6 +36,7 @@ interface Options { function fetcher({ environment, + kuery, searchAggregatedTransactions, serviceName, setup, @@ -38,7 +44,7 @@ function fetcher({ start, end, }: Options) { - const { esFilter, apmEventClient } = setup; + const { apmEventClient } = setup; const { intervalString } = getBucketSize({ start, end }); const filter: ESFilter[] = [ { term: { [SERVICE_NAME]: serviceName } }, @@ -48,7 +54,7 @@ function fetcher({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; const params = { diff --git a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts b/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts index 0c9bbb35be631..8b60d39a8de5d 100644 --- a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts +++ b/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_statistics.ts @@ -21,7 +21,11 @@ import { PROFILE_TOP_ID, SERVICE_NAME, } from '../../../../common/elasticsearch_fieldnames'; -import { rangeQuery, environmentQuery } from '../../../../common/utils/queries'; +import { + rangeQuery, + environmentQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { APMEventClient } from '../../helpers/create_es_client/create_apm_event_client'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; import { withApmSpan } from '../../../utils/with_apm_span'; @@ -184,12 +188,14 @@ function getProfilesWithStacks({ } export async function getServiceProfilingStatistics({ + kuery, serviceName, setup, environment, valueType, logger, }: { + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; environment?: string; @@ -202,11 +208,11 @@ export async function getServiceProfilingStatistics({ const valueTypeField = getValueTypeConfig(valueType).field; const filter: ESFilter[] = [ - ...rangeQuery(start, end), { term: { [SERVICE_NAME]: serviceName } }, - ...environmentQuery(environment), { exists: { field: valueTypeField } }, - ...setup.esFilter, + ...rangeQuery(start, end), + ...environmentQuery(environment), + ...kqlQuery(kuery), ]; const [profileStats, profileStacks] = await Promise.all([ diff --git a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts b/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts index dc29d6a43d82d..93fa029da8c72 100644 --- a/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts +++ b/x-pack/plugins/apm/server/lib/services/profiling/get_service_profiling_timeline.ts @@ -5,7 +5,7 @@ * 2.0. */ import { mapKeys, mapValues } from 'lodash'; -import { rangeQuery, environmentQuery } from '../../../../common/utils/queries'; +import { rangeQuery, environmentQuery } from '../../../../server/utils/queries'; import { ProcessorEvent } from '../../../../common/processor_event'; import { PROFILE_ID, @@ -18,6 +18,7 @@ import { import { Setup, SetupTimeRange } from '../../helpers/setup_request'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { withApmSpan } from '../../../utils/with_apm_span'; +import { kqlQuery } from '../../../utils/queries'; const configMap = mapValues( mapKeys(ProfilingValueType, (val, key) => val), @@ -27,16 +28,18 @@ const configMap = mapValues( const allFields = Object.values(configMap).map((config) => config.field); export async function getServiceProfilingTimeline({ + kuery, serviceName, environment, setup, }: { + kuery?: string; serviceName: string; setup: Setup & SetupTimeRange; environment?: string; }) { return withApmSpan('get_service_profiling_timeline', async () => { - const { apmEventClient, start, end, esFilter } = setup; + const { apmEventClient, start, end } = setup; const response = await apmEventClient.search({ apm: { @@ -50,7 +53,7 @@ export async function getServiceProfilingTimeline({ { term: { [SERVICE_NAME]: serviceName } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts b/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts index f631657f87276..0b158d9e57285 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts +++ b/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts @@ -15,7 +15,7 @@ import { ERROR_LOG_LEVEL, } from '../../../common/elasticsearch_fieldnames'; import { APMError } from '../../../typings/es_schemas/ui/apm_error'; -import { rangeQuery } from '../../../common/utils/queries'; +import { rangeQuery } from '../../../server/utils/queries'; import { Setup, SetupTimeRange } from '../helpers/setup_request'; import { PromiseValueType } from '../../../typings/common'; import { withApmSpan } from '../../utils/with_apm_span'; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/queries.test.ts.snap index 7fb2bb2fcbeeb..34c2f39ca04c0 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/transaction_groups/__snapshots__/queries.test.ts.snap @@ -56,11 +56,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], "must_not": Array [ Object { @@ -123,11 +118,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], "must_not": Array [ Object { @@ -190,11 +180,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], "must_not": Array [ Object { @@ -262,11 +247,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -317,11 +297,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -372,11 +347,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, @@ -433,11 +403,6 @@ Array [ }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts index 09e5e358a1b7c..ce0b6cf2a64fe 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -28,6 +28,7 @@ import { interface TopTransactionOptions { environment?: string; + kuery?: string; type: 'top_transactions'; serviceName: string; transactionType: string; @@ -37,6 +38,7 @@ interface TopTransactionOptions { interface TopTraceOptions { environment?: string; + kuery?: string; type: 'top_traces'; transactionName?: string; searchAggregatedTransactions: boolean; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/get_error_rate.ts b/x-pack/plugins/apm/server/lib/transaction_groups/get_error_rate.ts index d1a056002db07..627086df9d681 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/get_error_rate.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/get_error_rate.ts @@ -14,7 +14,11 @@ import { TRANSACTION_TYPE, } from '../../../common/elasticsearch_fieldnames'; import { EventOutcome } from '../../../common/event_outcome'; -import { environmentQuery, rangeQuery } from '../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../server/utils/queries'; import { getDocumentTypeFilterForAggregatedTransactions, getProcessorEventForAggregatedTransactions, @@ -30,6 +34,7 @@ import { withApmSpan } from '../../utils/with_apm_span'; export async function getErrorRate({ environment, + kuery, serviceName, transactionType, transactionName, @@ -37,6 +42,7 @@ export async function getErrorRate({ searchAggregatedTransactions, }: { environment?: string; + kuery?: string; serviceName: string; transactionType?: string; transactionName?: string; @@ -48,7 +54,7 @@ export async function getErrorRate({ average: number | null; }> { return withApmSpan('get_transaction_group_error_rate', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const transactionNamefilter = transactionName ? [{ term: { [TRANSACTION_NAME]: transactionName } }] @@ -71,7 +77,7 @@ export async function getErrorRate({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; const outcomes = getOutcomeAggregation(); diff --git a/x-pack/plugins/apm/server/lib/transactions/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/transactions/__snapshots__/queries.test.ts.snap index 62050563497e9..baa9b3ae230fe 100644 --- a/x-pack/plugins/apm/server/lib/transactions/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/transactions/__snapshots__/queries.test.ts.snap @@ -159,11 +159,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "bool": Object { "minimum_should_match": 1, @@ -310,11 +305,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, Object { "bool": Object { "minimum_should_match": 1, @@ -387,11 +377,6 @@ Object { }, }, }, - Object { - "term": Object { - "service.environment": "test", - }, - }, ], }, }, diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts b/x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts index 130029495af32..d8867c0dcc1e2 100644 --- a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts +++ b/x-pack/plugins/apm/server/lib/transactions/breakdown/index.test.ts @@ -38,7 +38,6 @@ function getMockSetup(esResponse: any) { } ) as APMConfig, uiFilters: {}, - esFilter: [], indices: mockIndices, dynamicIndexPattern: null as any, }; diff --git a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts b/x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts index f1e202df312c2..568769b52e2b4 100644 --- a/x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/breakdown/index.ts @@ -18,7 +18,11 @@ import { TRANSACTION_BREAKDOWN_COUNT, } from '../../../../common/elasticsearch_fieldnames'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { getMetricsDateHistogramParams } from '../../helpers/metrics'; import { MAX_KPIS } from './constants'; import { getVizColorForIndex } from '../../../../common/viz_colors'; @@ -26,19 +30,21 @@ import { withApmSpan } from '../../../utils/with_apm_span'; export function getTransactionBreakdown({ environment, + kuery, setup, serviceName, transactionName, transactionType, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; transactionName?: string; transactionType: string; }) { return withApmSpan('get_transaction_breakdown', async () => { - const { esFilter, apmEventClient, start, end, config } = setup; + const { apmEventClient, start, end, config } = setup; const subAggs = { sum_all_self_times: { @@ -86,7 +92,7 @@ export function getTransactionBreakdown({ { term: { [TRANSACTION_TYPE]: transactionType } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), { bool: { should: [ diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts index 7ed016cd4b4c6..fb7544e5fcb8d 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/index.ts @@ -20,7 +20,8 @@ import { joinByKey } from '../../../../../common/utils/join_by_key'; import { environmentQuery, rangeQuery, -} from '../../../../../common/utils/queries'; + kqlQuery, +} from '../../../../../server/utils/queries'; import { getDocumentTypeFilterForAggregatedTransactions, getProcessorEventForAggregatedTransactions, @@ -50,6 +51,7 @@ function getHistogramAggOptions({ export async function getBuckets({ environment, + kuery, serviceName, transactionName, transactionType, @@ -61,6 +63,7 @@ export async function getBuckets({ searchAggregatedTransactions, }: { environment?: string; + kuery?: string; serviceName: string; transactionName: string; transactionType: string; @@ -74,7 +77,7 @@ export async function getBuckets({ return withApmSpan( 'get_latency_distribution_buckets_with_samples', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const commonFilters = [ { term: { [SERVICE_NAME]: serviceName } }, @@ -82,7 +85,7 @@ export async function getBuckets({ { term: { [TRANSACTION_NAME]: transactionName } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; async function getSamplesForDistributionBuckets() { diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution_max.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution_max.ts index f8061ea989469..2e86f6bb84c81 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution_max.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_distribution_max.ts @@ -15,11 +15,16 @@ import { getProcessorEventForAggregatedTransactions, getTransactionDurationFieldForAggregatedTransactions, } from '../../helpers/aggregated_transactions'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; export async function getDistributionMax({ environment, + kuery, serviceName, transactionName, transactionType, @@ -27,6 +32,7 @@ export async function getDistributionMax({ searchAggregatedTransactions, }: { environment?: string; + kuery?: string; serviceName: string; transactionName: string; transactionType: string; @@ -34,7 +40,7 @@ export async function getDistributionMax({ searchAggregatedTransactions: boolean; }) { return withApmSpan('get_latency_distribution_max', async () => { - const { start, end, esFilter, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const params = { apm: { @@ -54,7 +60,7 @@ export async function getDistributionMax({ { term: { [TRANSACTION_NAME]: transactionName } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/index.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/index.ts index 92d1d96b4a8e3..ef92ce6edcafe 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/index.ts @@ -20,6 +20,7 @@ function getBucketSize(max: number) { } export async function getTransactionDistribution({ + kuery, environment, serviceName, transactionName, @@ -30,6 +31,7 @@ export async function getTransactionDistribution({ searchAggregatedTransactions, }: { environment?: string; + kuery?: string; serviceName: string; transactionName: string; transactionType: string; @@ -41,6 +43,7 @@ export async function getTransactionDistribution({ return withApmSpan('get_transaction_latency_distribution', async () => { const distributionMax = await getDistributionMax({ environment, + kuery, serviceName, transactionName, transactionType, @@ -56,6 +59,7 @@ export async function getTransactionDistribution({ const { buckets, noHits } = await getBuckets({ environment, + kuery, serviceName, transactionName, transactionType, diff --git a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts b/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts index d566f3a169e78..cfd09f0207536 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts @@ -7,7 +7,7 @@ import { ESSearchResponse } from '../../../../../../typings/elasticsearch'; import { PromiseReturnType } from '../../../../../observability/typings/common'; -import { rangeQuery } from '../../../../common/utils/queries'; +import { rangeQuery } from '../../../../server/utils/queries'; import { withApmSpan } from '../../../utils/with_apm_span'; import { Setup } from '../../helpers/setup_request'; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts index e1d3921d298c7..0be72c95b0a60 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_latency_charts/index.ts @@ -13,7 +13,11 @@ import { TRANSACTION_TYPE, } from '../../../../common/elasticsearch_fieldnames'; import { LatencyAggregationType } from '../../../../common/latency_aggregation_types'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { getDocumentTypeFilterForAggregatedTransactions, getProcessorEventForAggregatedTransactions, @@ -32,6 +36,7 @@ export type LatencyChartsSearchResponse = PromiseReturnType< function searchLatency({ environment, + kuery, serviceName, transactionType, transactionName, @@ -40,6 +45,7 @@ function searchLatency({ latencyAggregationType, }: { environment?: string; + kuery?: string; serviceName: string; transactionType: string | undefined; transactionName: string | undefined; @@ -47,7 +53,7 @@ function searchLatency({ searchAggregatedTransactions: boolean; latencyAggregationType: LatencyAggregationType; }) { - const { esFilter, start, end, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const { intervalString } = getBucketSize({ start, end }); const filter: ESFilter[] = [ @@ -57,7 +63,7 @@ function searchLatency({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; if (transactionName) { @@ -106,6 +112,7 @@ function searchLatency({ export function getLatencyTimeseries({ environment, + kuery, serviceName, transactionType, transactionName, @@ -114,6 +121,7 @@ export function getLatencyTimeseries({ latencyAggregationType, }: { environment?: string; + kuery?: string; serviceName: string; transactionType: string | undefined; transactionName: string | undefined; @@ -124,6 +132,7 @@ export function getLatencyTimeseries({ return withApmSpan('get_latency_charts', async () => { const response = await searchLatency({ environment, + kuery, serviceName, transactionType, transactionName, diff --git a/x-pack/plugins/apm/server/lib/transactions/get_throughput_charts/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_throughput_charts/index.ts index ec5dbf0eab3e9..3b7ffafff0d2a 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_throughput_charts/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_throughput_charts/index.ts @@ -13,7 +13,11 @@ import { TRANSACTION_RESULT, TRANSACTION_TYPE, } from '../../../../common/elasticsearch_fieldnames'; -import { environmentQuery, rangeQuery } from '../../../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../../../server/utils/queries'; import { getDocumentTypeFilterForAggregatedTransactions, getProcessorEventForAggregatedTransactions, @@ -29,6 +33,7 @@ export type ThroughputChartsResponse = PromiseReturnType< function searchThroughput({ environment, + kuery, serviceName, transactionType, transactionName, @@ -37,6 +42,7 @@ function searchThroughput({ intervalString, }: { environment?: string; + kuery?: string; serviceName: string; transactionType: string; transactionName: string | undefined; @@ -44,7 +50,7 @@ function searchThroughput({ searchAggregatedTransactions: boolean; intervalString: string; }) { - const { esFilter, start, end, apmEventClient } = setup; + const { start, end, apmEventClient } = setup; const filter: ESFilter[] = [ { term: { [SERVICE_NAME]: serviceName } }, @@ -54,7 +60,7 @@ function searchThroughput({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; if (transactionName) { @@ -95,6 +101,7 @@ function searchThroughput({ export async function getThroughputCharts({ environment, + kuery, serviceName, transactionType, transactionName, @@ -102,6 +109,7 @@ export async function getThroughputCharts({ searchAggregatedTransactions, }: { environment?: string; + kuery?: string; serviceName: string; transactionType: string; transactionName: string | undefined; @@ -113,6 +121,7 @@ export async function getThroughputCharts({ const response = await searchThroughput({ environment, + kuery, serviceName, transactionType, transactionName, diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts index 38d6b593dc72d..a089850e427e6 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts @@ -9,7 +9,7 @@ import { TRACE_ID, TRANSACTION_ID, } from '../../../../common/elasticsearch_fieldnames'; -import { rangeQuery } from '../../../../common/utils/queries'; +import { rangeQuery } from '../../../../server/utils/queries'; import { Setup, SetupTimeRange } from '../../helpers/setup_request'; import { ProcessorEvent } from '../../../../common/processor_event'; import { withApmSpan } from '../../../utils/with_apm_span'; diff --git a/x-pack/plugins/apm/server/projections/errors.ts b/x-pack/plugins/apm/server/projections/errors.ts index 342d78608efbf..341c7d13936ba 100644 --- a/x-pack/plugins/apm/server/projections/errors.ts +++ b/x-pack/plugins/apm/server/projections/errors.ts @@ -10,19 +10,25 @@ import { SERVICE_NAME, ERROR_GROUP_ID, } from '../../common/elasticsearch_fieldnames'; -import { environmentQuery, rangeQuery } from '../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../server/utils/queries'; import { ProcessorEvent } from '../../common/processor_event'; export function getErrorGroupsProjection({ environment, + kuery, setup, serviceName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; }) { - const { start, end, esFilter } = setup; + const { start, end } = setup; return { apm: { @@ -35,7 +41,7 @@ export function getErrorGroupsProjection({ { term: { [SERVICE_NAME]: serviceName } }, ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }, }, diff --git a/x-pack/plugins/apm/server/projections/metrics.ts b/x-pack/plugins/apm/server/projections/metrics.ts index a32c2ae46c870..ca43d0a8fb3c8 100644 --- a/x-pack/plugins/apm/server/projections/metrics.ts +++ b/x-pack/plugins/apm/server/projections/metrics.ts @@ -10,7 +10,11 @@ import { SERVICE_NAME, SERVICE_NODE_NAME, } from '../../common/elasticsearch_fieldnames'; -import { environmentQuery, rangeQuery } from '../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../server/utils/queries'; import { SERVICE_NODE_NAME_MISSING } from '../../common/service_nodes'; import { ProcessorEvent } from '../../common/processor_event'; @@ -28,23 +32,25 @@ function getServiceNodeNameFilters(serviceNodeName?: string) { export function getMetricsProjection({ environment, + kuery, setup, serviceName, serviceNodeName, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; }) { - const { start, end, esFilter } = setup; + const { start, end } = setup; const filter = [ { term: { [SERVICE_NAME]: serviceName } }, ...getServiceNodeNameFilters(serviceNodeName), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ]; return { diff --git a/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts b/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts index 1d5f7316b69ad..9c6ea6bc83511 100644 --- a/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts +++ b/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts @@ -11,9 +11,10 @@ import { TRANSACTION_TYPE, SERVICE_LANGUAGE_NAME, } from '../../common/elasticsearch_fieldnames'; -import { rangeQuery } from '../../common/utils/queries'; +import { rangeQuery } from '../../server/utils/queries'; import { ProcessorEvent } from '../../common/processor_event'; import { TRANSACTION_PAGE_LOAD } from '../../common/transaction_types'; +import { getEsFilter } from '../lib/rum_client/ui_filters/get_es_filter'; export function getRumPageLoadTransactionsProjection({ setup, @@ -24,7 +25,7 @@ export function getRumPageLoadTransactionsProjection({ urlQuery?: string; checkFetchStartFieldExists?: boolean; }) { - const { start, end, esFilter } = setup; + const { start, end, uiFilters } = setup; const bool = { filter: [ @@ -52,7 +53,7 @@ export function getRumPageLoadTransactionsProjection({ }, ] : []), - ...esFilter, + ...getEsFilter(uiFilters), ], }; @@ -75,7 +76,7 @@ export function getRumErrorsProjection({ setup: Setup & SetupTimeRange; urlQuery?: string; }) { - const { start, end, esFilter: esFilter } = setup; + const { start, end, uiFilters } = setup; const bool = { filter: [ @@ -86,7 +87,7 @@ export function getRumErrorsProjection({ [SERVICE_LANGUAGE_NAME]: 'javascript', }, }, - ...esFilter, + ...getEsFilter(uiFilters), ...(urlQuery ? [ { diff --git a/x-pack/plugins/apm/server/projections/service_nodes.ts b/x-pack/plugins/apm/server/projections/service_nodes.ts index 64e7406987fea..932309d9875c2 100644 --- a/x-pack/plugins/apm/server/projections/service_nodes.ts +++ b/x-pack/plugins/apm/server/projections/service_nodes.ts @@ -11,16 +11,19 @@ import { mergeProjection } from './util/merge_projection'; import { getMetricsProjection } from './metrics'; export function getServiceNodesProjection({ + kuery, setup, serviceName, serviceNodeName, }: { + kuery?: string; setup: Setup & SetupTimeRange; serviceName: string; serviceNodeName?: string; }) { return mergeProjection( getMetricsProjection({ + kuery, setup, serviceName, serviceNodeName, diff --git a/x-pack/plugins/apm/server/projections/services.ts b/x-pack/plugins/apm/server/projections/services.ts index a9f5a7efd0e67..3509e4fa5b339 100644 --- a/x-pack/plugins/apm/server/projections/services.ts +++ b/x-pack/plugins/apm/server/projections/services.ts @@ -7,18 +7,20 @@ import { Setup, SetupTimeRange } from '../../server/lib/helpers/setup_request'; import { SERVICE_NAME } from '../../common/elasticsearch_fieldnames'; -import { rangeQuery } from '../../common/utils/queries'; +import { rangeQuery, kqlQuery } from '../../server/utils/queries'; import { ProcessorEvent } from '../../common/processor_event'; import { getProcessorEventForAggregatedTransactions } from '../lib/helpers/aggregated_transactions'; export function getServicesProjection({ + kuery, setup, searchAggregatedTransactions, }: { + kuery?: string; setup: Setup & SetupTimeRange; searchAggregatedTransactions: boolean; }) { - const { start, end, esFilter } = setup; + const { start, end } = setup; return { apm: { @@ -34,7 +36,7 @@ export function getServicesProjection({ size: 0, query: { bool: { - filter: [...rangeQuery(start, end), ...esFilter], + filter: [...rangeQuery(start, end), ...kqlQuery(kuery)], }, }, aggs: { diff --git a/x-pack/plugins/apm/server/projections/transactions.ts b/x-pack/plugins/apm/server/projections/transactions.ts index 45ed5d2865a67..7955518d56f03 100644 --- a/x-pack/plugins/apm/server/projections/transactions.ts +++ b/x-pack/plugins/apm/server/projections/transactions.ts @@ -11,7 +11,11 @@ import { TRANSACTION_TYPE, TRANSACTION_NAME, } from '../../common/elasticsearch_fieldnames'; -import { environmentQuery, rangeQuery } from '../../common/utils/queries'; +import { + environmentQuery, + rangeQuery, + kqlQuery, +} from '../../server/utils/queries'; import { getProcessorEventForAggregatedTransactions, getDocumentTypeFilterForAggregatedTransactions, @@ -19,6 +23,7 @@ import { export function getTransactionsProjection({ environment, + kuery, setup, serviceName, transactionName, @@ -26,13 +31,14 @@ export function getTransactionsProjection({ searchAggregatedTransactions, }: { environment?: string; + kuery?: string; setup: Setup & SetupTimeRange; serviceName?: string; transactionName?: string; transactionType?: string; searchAggregatedTransactions: boolean; }) { - const { start, end, esFilter } = setup; + const { start, end } = setup; const transactionNameFilter = transactionName ? [{ term: { [TRANSACTION_NAME]: transactionName } }] @@ -54,7 +60,7 @@ export function getTransactionsProjection({ ), ...rangeQuery(start, end), ...environmentQuery(environment), - ...esFilter, + ...kqlQuery(kuery), ], }; diff --git a/x-pack/plugins/apm/server/routes/correlations.ts b/x-pack/plugins/apm/server/routes/correlations.ts index d4a0db3c0d6c7..48305d1a9df07 100644 --- a/x-pack/plugins/apm/server/routes/correlations.ts +++ b/x-pack/plugins/apm/server/routes/correlations.ts @@ -13,7 +13,7 @@ import { getCorrelationsForFailedTransactions } from '../lib/correlations/get_co import { getCorrelationsForSlowTransactions } from '../lib/correlations/get_correlations_for_slow_transactions'; import { setupRequest } from '../lib/helpers/setup_request'; import { createRoute } from './create_route'; -import { environmentRt, rangeRt } from './default_api_types'; +import { environmentRt, kueryRt, rangeRt } from './default_api_types'; const INVALID_LICENSE = i18n.translate( 'xpack.apm.significanTerms.license.text', @@ -36,8 +36,8 @@ export const correlationsForSlowTransactionsRoute = createRoute({ durationPercentile: t.string, fieldNames: t.string, }), - t.partial({ uiFilters: t.string }), environmentRt, + kueryRt, rangeRt, ]), }), @@ -49,6 +49,7 @@ export const correlationsForSlowTransactionsRoute = createRoute({ const setup = await setupRequest(context, request); const { environment, + kuery, serviceName, transactionType, transactionName, @@ -58,6 +59,7 @@ export const correlationsForSlowTransactionsRoute = createRoute({ return getCorrelationsForSlowTransactions({ environment, + kuery, serviceName, transactionType, transactionName, @@ -80,8 +82,8 @@ export const correlationsForFailedTransactionsRoute = createRoute({ t.type({ fieldNames: t.string, }), - t.partial({ uiFilters: t.string }), environmentRt, + kueryRt, rangeRt, ]), }), @@ -93,6 +95,7 @@ export const correlationsForFailedTransactionsRoute = createRoute({ const setup = await setupRequest(context, request); const { environment, + kuery, serviceName, transactionType, transactionName, @@ -101,6 +104,7 @@ export const correlationsForFailedTransactionsRoute = createRoute({ return getCorrelationsForFailedTransactions({ environment, + kuery, serviceName, transactionType, transactionName, diff --git a/x-pack/plugins/apm/server/routes/default_api_types.ts b/x-pack/plugins/apm/server/routes/default_api_types.ts index 990b462a520d2..10c50a384c2d7 100644 --- a/x-pack/plugins/apm/server/routes/default_api_types.ts +++ b/x-pack/plugins/apm/server/routes/default_api_types.ts @@ -20,4 +20,4 @@ export const comparisonRangeRt = t.partial({ export const environmentRt = t.partial({ environment: t.string }); -export const uiFiltersRt = t.type({ uiFilters: t.string }); +export const kueryRt = t.partial({ kuery: t.string }); diff --git a/x-pack/plugins/apm/server/routes/errors.ts b/x-pack/plugins/apm/server/routes/errors.ts index 073a91bfe1548..710e614165aa5 100644 --- a/x-pack/plugins/apm/server/routes/errors.ts +++ b/x-pack/plugins/apm/server/routes/errors.ts @@ -11,7 +11,7 @@ import { getErrorDistribution } from '../lib/errors/distribution/get_distributio import { getErrorGroupSample } from '../lib/errors/get_error_group_sample'; import { getErrorGroups } from '../lib/errors/get_error_groups'; import { setupRequest } from '../lib/helpers/setup_request'; -import { environmentRt, uiFiltersRt, rangeRt } from './default_api_types'; +import { environmentRt, kueryRt, rangeRt } from './default_api_types'; export const errorsRoute = createRoute({ endpoint: 'GET /api/apm/services/{serviceName}/errors', @@ -25,7 +25,7 @@ export const errorsRoute = createRoute({ sortDirection: t.union([t.literal('asc'), t.literal('desc')]), }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -34,10 +34,11 @@ export const errorsRoute = createRoute({ const setup = await setupRequest(context, request); const { params } = context; const { serviceName } = params.path; - const { environment, sortField, sortDirection } = params.query; + const { environment, kuery, sortField, sortDirection } = params.query; return getErrorGroups({ environment, + kuery, serviceName, sortField, sortDirection, @@ -53,15 +54,21 @@ export const errorGroupsRoute = createRoute({ serviceName: t.string, groupId: t.string, }), - query: t.intersection([environmentRt, uiFiltersRt, rangeRt]), + query: t.intersection([environmentRt, kueryRt, rangeRt]), }), options: { tags: ['access:apm'] }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); const { serviceName, groupId } = context.params.path; - const { environment } = context.params.query; + const { environment, kuery } = context.params.query; - return getErrorGroupSample({ environment, serviceName, groupId, setup }); + return getErrorGroupSample({ + environment, + groupId, + kuery, + serviceName, + setup, + }); }, }); @@ -76,7 +83,7 @@ export const errorDistributionRoute = createRoute({ groupId: t.string, }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -85,7 +92,13 @@ export const errorDistributionRoute = createRoute({ const setup = await setupRequest(context, request); const { params } = context; const { serviceName } = params.path; - const { environment, groupId } = params.query; - return getErrorDistribution({ environment, serviceName, groupId, setup }); + const { environment, kuery, groupId } = params.query; + return getErrorDistribution({ + environment, + kuery, + serviceName, + groupId, + setup, + }); }, }); diff --git a/x-pack/plugins/apm/server/routes/metrics.ts b/x-pack/plugins/apm/server/routes/metrics.ts index 08376ed0e37ff..c7e82e13d07b8 100644 --- a/x-pack/plugins/apm/server/routes/metrics.ts +++ b/x-pack/plugins/apm/server/routes/metrics.ts @@ -9,10 +9,10 @@ import * as t from 'io-ts'; import { setupRequest } from '../lib/helpers/setup_request'; import { getMetricsChartDataByAgent } from '../lib/metrics/get_metrics_chart_data_by_agent'; import { createRoute } from './create_route'; -import { environmentRt, uiFiltersRt, rangeRt } from './default_api_types'; +import { environmentRt, kueryRt, rangeRt } from './default_api_types'; export const metricsChartsRoute = createRoute({ - endpoint: `GET /api/apm/services/{serviceName}/metrics/charts`, + endpoint: 'GET /api/apm/services/{serviceName}/metrics/charts', params: t.type({ path: t.type({ serviceName: t.string, @@ -25,7 +25,7 @@ export const metricsChartsRoute = createRoute({ serviceNodeName: t.string, }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -34,9 +34,10 @@ export const metricsChartsRoute = createRoute({ const setup = await setupRequest(context, request); const { params } = context; const { serviceName } = params.path; - const { agentName, environment, serviceNodeName } = params.query; + const { agentName, environment, kuery, serviceNodeName } = params.query; return await getMetricsChartDataByAgent({ environment, + kuery, setup, serviceName, agentName, diff --git a/x-pack/plugins/apm/server/routes/rum_client.ts b/x-pack/plugins/apm/server/routes/rum_client.ts index c9fa4253bb58e..ecf56e2aec246 100644 --- a/x-pack/plugins/apm/server/routes/rum_client.ts +++ b/x-pack/plugins/apm/server/routes/rum_client.ts @@ -6,10 +6,8 @@ */ import * as t from 'io-ts'; -import { omit } from 'lodash'; import { jsonRt } from '../../common/runtime_types/json_rt'; import { LocalUIFilterName } from '../../common/ui_filter'; -import { getEsFilter } from '../lib/helpers/convert_ui_filters/get_es_filter'; import { Setup, setupRequest, @@ -31,7 +29,7 @@ import { localUIFilterNames } from '../lib/rum_client/ui_filters/local_ui_filter import { getRumPageLoadTransactionsProjection } from '../projections/rum_page_load_transactions'; import { Projection } from '../projections/typings'; import { createRoute } from './create_route'; -import { rangeRt, uiFiltersRt } from './default_api_types'; +import { rangeRt } from './default_api_types'; import { APMRequestHandlerContext } from './typings'; export const percentileRangeRt = t.partial({ @@ -39,6 +37,8 @@ export const percentileRangeRt = t.partial({ maxPercentile: t.string, }); +const uiFiltersRt = t.type({ uiFilters: t.string }); + const uxQueryRt = t.intersection([ uiFiltersRt, rangeRt, @@ -319,10 +319,7 @@ function createLocalFiltersRoute< const projection = await getProjection({ query, context, - setup: { - ...setup, - esFilter: getEsFilter(omit(uiFilters, filterNames)), - }, + setup, }); return getLocalUIFilters({ diff --git a/x-pack/plugins/apm/server/routes/service_map.ts b/x-pack/plugins/apm/server/routes/service_map.ts index 6a05431c5677a..33943d6e05d01 100644 --- a/x-pack/plugins/apm/server/routes/service_map.ts +++ b/x-pack/plugins/apm/server/routes/service_map.ts @@ -62,7 +62,7 @@ export const serviceMapRoute = createRoute({ }); export const serviceMapServiceNodeRoute = createRoute({ - endpoint: `GET /api/apm/service-map/service/{serviceName}`, + endpoint: 'GET /api/apm/service-map/service/{serviceName}', params: t.type({ path: t.type({ serviceName: t.string, diff --git a/x-pack/plugins/apm/server/routes/service_nodes.ts b/x-pack/plugins/apm/server/routes/service_nodes.ts index 9523c89a639c4..e65b0b679da5a 100644 --- a/x-pack/plugins/apm/server/routes/service_nodes.ts +++ b/x-pack/plugins/apm/server/routes/service_nodes.ts @@ -9,7 +9,7 @@ import * as t from 'io-ts'; import { createRoute } from './create_route'; import { setupRequest } from '../lib/helpers/setup_request'; import { getServiceNodes } from '../lib/service_nodes'; -import { rangeRt, uiFiltersRt } from './default_api_types'; +import { rangeRt, kueryRt } from './default_api_types'; export const serviceNodesRoute = createRoute({ endpoint: 'GET /api/apm/services/{serviceName}/serviceNodes', @@ -17,15 +17,17 @@ export const serviceNodesRoute = createRoute({ path: t.type({ serviceName: t.string, }), - query: t.intersection([rangeRt, uiFiltersRt]), + query: t.intersection([kueryRt, rangeRt]), }), options: { tags: ['access:apm'] }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); const { params } = context; const { serviceName } = params.path; + const { kuery } = params.query; return getServiceNodes({ + kuery, setup, serviceName, }); diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services.ts index 86f7853647894..58e6f6ccadc0a 100644 --- a/x-pack/plugins/apm/server/routes/services.ts +++ b/x-pack/plugins/apm/server/routes/services.ts @@ -30,8 +30,8 @@ import { jsonRt } from '../../common/runtime_types/json_rt'; import { comparisonRangeRt, environmentRt, + kueryRt, rangeRt, - uiFiltersRt, } from './default_api_types'; import { withApmSpan } from '../utils/with_apm_span'; import { getServiceProfilingStatistics } from '../lib/services/profiling/get_service_profiling_statistics'; @@ -45,18 +45,19 @@ import { export const servicesRoute = createRoute({ endpoint: 'GET /api/apm/services', params: t.type({ - query: t.intersection([environmentRt, uiFiltersRt, rangeRt]), + query: t.intersection([environmentRt, kueryRt, rangeRt]), }), options: { tags: ['access:apm'] }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); - const { environment } = context.params.query; + const { environment, kuery } = context.params.query; const searchAggregatedTransactions = await getSearchAggregatedTransactions( setup ); const services = await getServices({ environment, + kuery, setup, searchAggregatedTransactions, logger: context.logger, @@ -166,13 +167,20 @@ export const serviceNodeMetadataRoute = createRoute({ serviceName: t.string, serviceNodeName: t.string, }), - query: t.intersection([uiFiltersRt, rangeRt]), + query: t.intersection([kueryRt, rangeRt]), }), options: { tags: ['access:apm'] }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); const { serviceName, serviceNodeName } = context.params.path; - return getServiceNodeMetadata({ setup, serviceName, serviceNodeName }); + const { kuery } = context.params.query; + + return getServiceNodeMetadata({ + kuery, + setup, + serviceName, + serviceNodeName, + }); }, }); @@ -182,7 +190,7 @@ export const serviceAnnotationsRoute = createRoute({ path: t.type({ serviceName: t.string, }), - query: t.intersection([rangeRt, environmentRt]), + query: t.intersection([environmentRt, rangeRt]), }), options: { tags: ['access:apm'] }, handler: async ({ context, request }) => { @@ -205,10 +213,10 @@ export const serviceAnnotationsRoute = createRoute({ ]); return getServiceAnnotations({ + environment, setup, searchAggregatedTransactions, serviceName, - environment, annotationsClient, client: context.core.elasticsearch.client.asCurrentUser, logger: context.logger, @@ -285,8 +293,8 @@ export const serviceErrorGroupsPrimaryStatisticsRoute = createRoute({ }), query: t.intersection([ environmentRt, + kueryRt, rangeRt, - uiFiltersRt, t.type({ transactionType: t.string, }), @@ -298,9 +306,10 @@ export const serviceErrorGroupsPrimaryStatisticsRoute = createRoute({ const { path: { serviceName }, - query: { transactionType, environment }, + query: { kuery, transactionType, environment }, } = context.params; return getServiceErrorGroupPrimaryStatistics({ + kuery, serviceName, setup, transactionType, @@ -318,8 +327,8 @@ export const serviceErrorGroupsComparisonStatisticsRoute = createRoute({ }), query: t.intersection([ environmentRt, + kueryRt, rangeRt, - uiFiltersRt, t.type({ numBuckets: toNumberRt, transactionType: t.string, @@ -333,11 +342,12 @@ export const serviceErrorGroupsComparisonStatisticsRoute = createRoute({ const { path: { serviceName }, - query: { environment, numBuckets, transactionType, groupIds }, + query: { environment, kuery, numBuckets, transactionType, groupIds }, } = context.params; return getServiceErrorGroupComparisonStatistics({ environment, + kuery, serviceName, setup, numBuckets, @@ -356,7 +366,7 @@ export const serviceThroughputRoute = createRoute({ query: t.intersection([ t.type({ transactionType: t.string }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, comparisonRangeRt, ]), @@ -367,6 +377,7 @@ export const serviceThroughputRoute = createRoute({ const { serviceName } = context.params.path; const { environment, + kuery, transactionType, comparisonStart, comparisonEnd, @@ -378,6 +389,8 @@ export const serviceThroughputRoute = createRoute({ const { start, end } = setup; const commonProps = { + environment, + kuery, searchAggregatedTransactions, serviceName, setup, @@ -387,14 +400,12 @@ export const serviceThroughputRoute = createRoute({ const [currentPeriod, previousPeriod] = await Promise.all([ getThroughput({ ...commonProps, - environment, start, end, }), comparisonStart && comparisonEnd ? getThroughput({ ...commonProps, - environment, start: comparisonStart, end: comparisonEnd, }).then((coordinates) => @@ -427,7 +438,7 @@ export const serviceInstancesRoute = createRoute({ numBuckets: toNumberRt, }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -435,7 +446,12 @@ export const serviceInstancesRoute = createRoute({ handler: async ({ context, request }) => { const setup = await setupRequest(context, request); const { serviceName } = context.params.path; - const { environment, transactionType, numBuckets } = context.params.query; + const { + environment, + kuery, + transactionType, + numBuckets, + } = context.params.query; const latencyAggregationType = (context.params.query .latencyAggregationType as unknown) as LatencyAggregationType; @@ -445,6 +461,7 @@ export const serviceInstancesRoute = createRoute({ return getServiceInstances({ environment, + kuery, latencyAggregationType, serviceName, setup, @@ -493,13 +510,7 @@ export const serviceProfilingTimelineRoute = createRoute({ path: t.type({ serviceName: t.string, }), - query: t.intersection([ - rangeRt, - uiFiltersRt, - t.partial({ - environment: t.string, - }), - ]), + query: t.intersection([environmentRt, kueryRt, rangeRt]), }), options: { tags: ['access:apm'], @@ -509,10 +520,11 @@ export const serviceProfilingTimelineRoute = createRoute({ const { path: { serviceName }, - query: { environment }, + query: { environment, kuery }, } = context.params; return getServiceProfilingTimeline({ + kuery, setup, serviceName, environment, @@ -527,11 +539,9 @@ export const serviceProfilingStatisticsRoute = createRoute({ serviceName: t.string, }), query: t.intersection([ + environmentRt, + kueryRt, rangeRt, - uiFiltersRt, - t.partial({ - environment: t.string, - }), t.type({ valueType: t.union([ t.literal(ProfilingValueType.wallTime), @@ -553,10 +563,11 @@ export const serviceProfilingStatisticsRoute = createRoute({ const { path: { serviceName }, - query: { environment, valueType }, + query: { environment, kuery, valueType }, } = context.params; return getServiceProfilingStatistics({ + kuery, serviceName, environment, valueType, diff --git a/x-pack/plugins/apm/server/routes/traces.ts b/x-pack/plugins/apm/server/routes/traces.ts index 5d3f99be7af34..6287ffbf0c751 100644 --- a/x-pack/plugins/apm/server/routes/traces.ts +++ b/x-pack/plugins/apm/server/routes/traces.ts @@ -10,25 +10,25 @@ import { setupRequest } from '../lib/helpers/setup_request'; import { getTrace } from '../lib/traces/get_trace'; import { getTransactionGroupList } from '../lib/transaction_groups'; import { createRoute } from './create_route'; -import { environmentRt, rangeRt, uiFiltersRt } from './default_api_types'; +import { environmentRt, kueryRt, rangeRt } from './default_api_types'; import { getSearchAggregatedTransactions } from '../lib/helpers/aggregated_transactions'; import { getRootTransactionByTraceId } from '../lib/transactions/get_transaction_by_trace'; export const tracesRoute = createRoute({ endpoint: 'GET /api/apm/traces', params: t.type({ - query: t.intersection([environmentRt, rangeRt, uiFiltersRt]), + query: t.intersection([environmentRt, kueryRt, rangeRt]), }), options: { tags: ['access:apm'] }, handler: async ({ context, request }) => { const setup = await setupRequest(context, request); - const { environment } = context.params.query; + const { environment, kuery } = context.params.query; const searchAggregatedTransactions = await getSearchAggregatedTransactions( setup ); return getTransactionGroupList( - { environment, type: 'top_traces', searchAggregatedTransactions }, + { environment, kuery, type: 'top_traces', searchAggregatedTransactions }, setup ); }, diff --git a/x-pack/plugins/apm/server/routes/transactions.ts b/x-pack/plugins/apm/server/routes/transactions.ts index 960cc7f526424..330b4b4bdd12a 100644 --- a/x-pack/plugins/apm/server/routes/transactions.ts +++ b/x-pack/plugins/apm/server/routes/transactions.ts @@ -24,7 +24,7 @@ import { getThroughputCharts } from '../lib/transactions/get_throughput_charts'; import { getTransactionGroupList } from '../lib/transaction_groups'; import { getErrorRate } from '../lib/transaction_groups/get_error_rate'; import { createRoute } from './create_route'; -import { environmentRt, rangeRt, uiFiltersRt } from './default_api_types'; +import { environmentRt, kueryRt, rangeRt } from './default_api_types'; /** * Returns a list of transactions grouped by name @@ -39,7 +39,7 @@ export const transactionGroupsRoute = createRoute({ query: t.intersection([ t.type({ transactionType: t.string }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -47,7 +47,7 @@ export const transactionGroupsRoute = createRoute({ handler: async ({ context, request }) => { const setup = await setupRequest(context, request); const { serviceName } = context.params.path; - const { environment, transactionType } = context.params.query; + const { environment, kuery, transactionType } = context.params.query; const searchAggregatedTransactions = await getSearchAggregatedTransactions( setup @@ -56,6 +56,7 @@ export const transactionGroupsRoute = createRoute({ return getTransactionGroupList( { environment, + kuery, type: 'top_transactions', serviceName, transactionType, @@ -73,8 +74,8 @@ export const transactionGroupsPrimaryStatisticsRoute = createRoute({ path: t.type({ serviceName: t.string }), query: t.intersection([ environmentRt, + kueryRt, rangeRt, - uiFiltersRt, t.type({ transactionType: t.string, latencyAggregationType: latencyAggregationTypeRt, @@ -93,11 +94,12 @@ export const transactionGroupsPrimaryStatisticsRoute = createRoute({ const { path: { serviceName }, - query: { environment, latencyAggregationType, transactionType }, + query: { environment, kuery, latencyAggregationType, transactionType }, } = context.params; return getServiceTransactionGroups({ environment, + kuery, setup, serviceName, searchAggregatedTransactions, @@ -114,8 +116,8 @@ export const transactionGroupsComparisonStatisticsRoute = createRoute({ path: t.type({ serviceName: t.string }), query: t.intersection([ environmentRt, + kueryRt, rangeRt, - uiFiltersRt, t.type({ transactionNames: jsonRt.pipe(t.array(t.string)), numBuckets: toNumberRt, @@ -138,6 +140,7 @@ export const transactionGroupsComparisonStatisticsRoute = createRoute({ path: { serviceName }, query: { environment, + kuery, transactionNames, latencyAggregationType, numBuckets, @@ -147,6 +150,7 @@ export const transactionGroupsComparisonStatisticsRoute = createRoute({ return getServiceTransactionGroupComparisonStatistics({ environment, + kuery, setup, serviceName, transactionNames, @@ -173,7 +177,7 @@ export const transactionLatencyChartsRoute = createRoute({ latencyAggregationType: latencyAggregationTypeRt, }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -184,6 +188,7 @@ export const transactionLatencyChartsRoute = createRoute({ const { serviceName } = context.params.path; const { environment, + kuery, transactionType, transactionName, latencyAggregationType, @@ -195,6 +200,7 @@ export const transactionLatencyChartsRoute = createRoute({ const options = { environment, + kuery, serviceName, transactionType, transactionName, @@ -235,9 +241,9 @@ export const transactionThroughputChartsRoute = createRoute({ query: t.intersection([ t.type({ transactionType: t.string }), t.partial({ transactionName: t.string }), - uiFiltersRt, - rangeRt, environmentRt, + kueryRt, + rangeRt, ]), }), options: { tags: ['access:apm'] }, @@ -246,6 +252,7 @@ export const transactionThroughputChartsRoute = createRoute({ const { serviceName } = context.params.path; const { environment, + kuery, transactionType, transactionName, } = context.params.query; @@ -256,6 +263,7 @@ export const transactionThroughputChartsRoute = createRoute({ return await getThroughputCharts({ environment, + kuery, serviceName, transactionType, transactionName, @@ -282,7 +290,7 @@ export const transactionChartsDistributionRoute = createRoute({ traceId: t.string, }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -292,6 +300,7 @@ export const transactionChartsDistributionRoute = createRoute({ const { serviceName } = context.params.path; const { environment, + kuery, transactionType, transactionName, transactionId = '', @@ -304,6 +313,7 @@ export const transactionChartsDistributionRoute = createRoute({ return getTransactionDistribution({ environment, + kuery, serviceName, transactionType, transactionName, @@ -325,7 +335,7 @@ export const transactionChartsBreakdownRoute = createRoute({ t.type({ transactionType: t.string }), t.partial({ transactionName: t.string }), environmentRt, - uiFiltersRt, + kueryRt, rangeRt, ]), }), @@ -335,12 +345,14 @@ export const transactionChartsBreakdownRoute = createRoute({ const { serviceName } = context.params.path; const { environment, + kuery, transactionName, transactionType, } = context.params.query; return getTransactionBreakdown({ environment, + kuery, serviceName, transactionName, transactionType, @@ -358,7 +370,7 @@ export const transactionChartsErrorRateRoute = createRoute({ }), query: t.intersection([ environmentRt, - uiFiltersRt, + kueryRt, rangeRt, t.type({ transactionType: t.string }), t.partial({ transactionName: t.string }), @@ -369,7 +381,12 @@ export const transactionChartsErrorRateRoute = createRoute({ const setup = await setupRequest(context, request); const { params } = context; const { serviceName } = params.path; - const { environment, transactionType, transactionName } = params.query; + const { + environment, + kuery, + transactionType, + transactionName, + } = params.query; const searchAggregatedTransactions = await getSearchAggregatedTransactions( setup @@ -377,6 +394,7 @@ export const transactionChartsErrorRateRoute = createRoute({ return getErrorRate({ environment, + kuery, serviceName, transactionType, transactionName, diff --git a/x-pack/plugins/apm/common/utils/queries.test.ts b/x-pack/plugins/apm/server/utils/queries.test.ts similarity index 85% rename from x-pack/plugins/apm/common/utils/queries.test.ts rename to x-pack/plugins/apm/server/utils/queries.test.ts index 546c8627def69..9fa97940db8f3 100644 --- a/x-pack/plugins/apm/common/utils/queries.test.ts +++ b/x-pack/plugins/apm/server/utils/queries.test.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { SERVICE_ENVIRONMENT } from '../elasticsearch_fieldnames'; -import { ENVIRONMENT_NOT_DEFINED } from '../environment_filter_values'; +import { SERVICE_ENVIRONMENT } from '../../common/elasticsearch_fieldnames'; +import { ENVIRONMENT_NOT_DEFINED } from '../../common/environment_filter_values'; import { environmentQuery } from './queries'; describe('environmentQuery', () => { diff --git a/x-pack/plugins/apm/common/utils/queries.ts b/x-pack/plugins/apm/server/utils/queries.ts similarity index 73% rename from x-pack/plugins/apm/common/utils/queries.ts rename to x-pack/plugins/apm/server/utils/queries.ts index dbbbf324b964a..6eab50d089821 100644 --- a/x-pack/plugins/apm/common/utils/queries.ts +++ b/x-pack/plugins/apm/server/utils/queries.ts @@ -5,12 +5,13 @@ * 2.0. */ +import { esKuery } from '../../../../../src/plugins/data/server'; import { ESFilter } from '../../../../typings/elasticsearch'; +import { SERVICE_ENVIRONMENT } from '../../common/elasticsearch_fieldnames'; import { - ENVIRONMENT_NOT_DEFINED, ENVIRONMENT_ALL, -} from '../environment_filter_values'; -import { SERVICE_ENVIRONMENT } from '../elasticsearch_fieldnames'; + ENVIRONMENT_NOT_DEFINED, +} from '../../common/environment_filter_values'; type QueryContainer = ESFilter; @@ -43,3 +44,12 @@ export function rangeQuery( }, ]; } + +export function kqlQuery(kql?: string) { + if (!kql) { + return []; + } + + const ast = esKuery.fromKueryExpression(kql); + return [esKuery.toElasticsearchQuery(ast) as ESFilter]; +} diff --git a/x-pack/plugins/apm/server/utils/test_helpers.tsx b/x-pack/plugins/apm/server/utils/test_helpers.tsx index 4df638cc2c5df..e804183c78867 100644 --- a/x-pack/plugins/apm/server/utils/test_helpers.tsx +++ b/x-pack/plugins/apm/server/utils/test_helpers.tsx @@ -8,7 +8,6 @@ import { APMConfig } from '../'; import { PromiseReturnType } from '../../../observability/typings/common'; import { - ESFilter, ESSearchRequest, ESSearchResponse, } from '../../../../typings/elasticsearch'; @@ -27,7 +26,6 @@ interface MockSetup { internalClient: any; config: APMConfig; uiFilters: UIFilters; - esFilter: ESFilter[]; indices: { /* eslint-disable @typescript-eslint/naming-convention */ 'apm_oss.sourcemapIndices': string; @@ -89,7 +87,6 @@ export async function inspectSearchParams( } ) as APMConfig, uiFilters: {}, - esFilter: [{ term: { 'service.environment': 'test' } }], indices: { /* eslint-disable @typescript-eslint/naming-convention */ 'apm_oss.sourcemapIndices': 'myIndex', diff --git a/x-pack/test/apm_api_integration/tests/feature_controls.ts b/x-pack/test/apm_api_integration/tests/feature_controls.ts index 45114dd506716..e82b14d6cb7e6 100644 --- a/x-pack/test/apm_api_integration/tests/feature_controls.ts +++ b/x-pack/test/apm_api_integration/tests/feature_controls.ts @@ -44,39 +44,39 @@ export default function featureControlsTests({ getService }: FtrProviderContext) { // this doubles as a smoke test for the _debug query parameter req: { - url: `/api/apm/services/foo/errors?start=${start}&end=${end}&uiFilters=%7B%7D&_debug=true`, + url: `/api/apm/services/foo/errors?start=${start}&end=${end}&_debug=true`, }, expectForbidden: expect403, expectResponse: expect200, }, { - req: { url: `/api/apm/services/foo/errors/bar?start=${start}&end=${end}&uiFilters=%7B%7D` }, + req: { url: `/api/apm/services/foo/errors/bar?start=${start}&end=${end}` }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/errors/distribution?start=${start}&end=${end}&groupId=bar&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/errors/distribution?start=${start}&end=${end}&groupId=bar`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/errors/distribution?start=${start}&end=${end}&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/errors/distribution?start=${start}&end=${end}`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/metrics/charts?start=${start}&end=${end}&agentName=cool-agent&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/metrics/charts?start=${start}&end=${end}&agentName=cool-agent`, }, expectForbidden: expect403, expectResponse: expect200, }, { - req: { url: `/api/apm/services?start=${start}&end=${end}&uiFilters=%7B%7D` }, + req: { url: `/api/apm/services?start=${start}&end=${end}` }, expectForbidden: expect403, expectResponse: expect200, }, @@ -91,7 +91,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expectResponse: expect200, }, { - req: { url: `/api/apm/traces?start=${start}&end=${end}&uiFilters=%7B%7D` }, + req: { url: `/api/apm/traces?start=${start}&end=${end}` }, expectForbidden: expect403, expectResponse: expect200, }, @@ -102,42 +102,42 @@ export default function featureControlsTests({ getService }: FtrProviderContext) }, { req: { - url: `/api/apm/services/foo/transactions/groups?start=${start}&end=${end}&transactionType=bar&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/transactions/groups?start=${start}&end=${end}&transactionType=bar`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=bar&latencyAggregationType=avg&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=bar&latencyAggregationType=avg`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=bar&latencyAggregationType=avg&transactionName=baz&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=bar&latencyAggregationType=avg&transactionName=baz`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/transactions/charts/throughput?environment=testing&start=${start}&end=${end}&transactionType=bar&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/transactions/charts/throughput?environment=testing&start=${start}&end=${end}&transactionType=bar`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/transactions/charts/throughput?environment=testing&start=${start}&end=${end}&transactionType=bar&transactionName=baz&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/transactions/charts/throughput?environment=testing&start=${start}&end=${end}&transactionType=bar&transactionName=baz`, }, expectForbidden: expect403, expectResponse: expect200, }, { req: { - url: `/api/apm/services/foo/transactions/charts/distribution?start=${start}&end=${end}&transactionType=bar&transactionName=baz&uiFilters=%7B%7D`, + url: `/api/apm/services/foo/transactions/charts/distribution?start=${start}&end=${end}&transactionType=bar&transactionName=baz`, }, expectForbidden: expect403, expectResponse: expect200, diff --git a/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.ts b/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.ts index 78dc0fa44c5de..b767eaae1c203 100644 --- a/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.ts +++ b/x-pack/test/apm_api_integration/tests/metrics_charts/metrics_charts.ts @@ -27,14 +27,13 @@ export default function ApiTest({ getService }: FtrProviderContext) { describe('for opbeans-node', () => { const start = encodeURIComponent('2020-09-08T14:50:00.000Z'); const end = encodeURIComponent('2020-09-08T14:55:00.000Z'); - const uiFilters = encodeURIComponent(JSON.stringify({})); const agentName = 'nodejs'; describe('returns metrics data', () => { let chartsResponse: ChartResponse; before(async () => { chartsResponse = await supertest.get( - `/api/apm/services/opbeans-node/metrics/charts?start=${start}&end=${end}&uiFilters=${uiFilters}&agentName=${agentName}` + `/api/apm/services/opbeans-node/metrics/charts?start=${start}&end=${end}&agentName=${agentName}` ); }); it('contains CPU usage and System memory usage chart data', async () => { @@ -113,7 +112,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); describe('for opbeans-java', () => { - const uiFilters = encodeURIComponent(JSON.stringify({})); const agentName = 'java'; describe('returns metrics data', () => { @@ -123,7 +121,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { let chartsResponse: ChartResponse; before(async () => { chartsResponse = await supertest.get( - `/api/apm/services/opbeans-java/metrics/charts?start=${start}&end=${end}&uiFilters=${uiFilters}&agentName=${agentName}` + `/api/apm/services/opbeans-java/metrics/charts?start=${start}&end=${end}&agentName=${agentName}` ); }); @@ -412,7 +410,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { const end = encodeURIComponent('2020-09-08T15:05:00.000Z'); const chartsResponse: ChartResponse = await supertest.get( - `/api/apm/services/opbeans-java/metrics/charts?start=${start}&end=${end}&uiFilters=${uiFilters}&agentName=${agentName}` + `/api/apm/services/opbeans-java/metrics/charts?start=${start}&end=${end}&agentName=${agentName}` ); const systemMemoryUsageChart = chartsResponse.body.charts.find( diff --git a/x-pack/test/apm_api_integration/tests/service_overview/instances.ts b/x-pack/test/apm_api_integration/tests/service_overview/instances.ts index cca40a6950007..8ff493b5575b0 100644 --- a/x-pack/test/apm_api_integration/tests/service_overview/instances.ts +++ b/x-pack/test/apm_api_integration/tests/service_overview/instances.ts @@ -40,7 +40,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { end, numBuckets: 20, transactionType: 'request', - uiFilters: '{}', }, }) ); @@ -69,7 +68,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { end, numBuckets: 20, transactionType: 'request', - uiFilters: '{}', }, }) ); @@ -153,7 +151,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { end, numBuckets: 20, transactionType: 'request', - uiFilters: '{}', }, }) ); diff --git a/x-pack/test/apm_api_integration/tests/services/error_groups_comparison_statistics.ts b/x-pack/test/apm_api_integration/tests/services/error_groups_comparison_statistics.ts index a13a76e2ddb46..4a19efac5a809 100644 --- a/x-pack/test/apm_api_integration/tests/services/error_groups_comparison_statistics.ts +++ b/x-pack/test/apm_api_integration/tests/services/error_groups_comparison_statistics.ts @@ -39,7 +39,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, transactionType: 'request', groupIds: JSON.stringify(groupIds), @@ -63,7 +62,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, transactionType: 'request', groupIds: JSON.stringify(groupIds), @@ -94,7 +92,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, transactionType: 'request', groupIds: JSON.stringify(['foo']), diff --git a/x-pack/test/apm_api_integration/tests/services/error_groups_primary_statistics.ts b/x-pack/test/apm_api_integration/tests/services/error_groups_primary_statistics.ts index 8a334ca567f0e..61a44619ea905 100644 --- a/x-pack/test/apm_api_integration/tests/services/error_groups_primary_statistics.ts +++ b/x-pack/test/apm_api_integration/tests/services/error_groups_primary_statistics.ts @@ -32,7 +32,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', transactionType: 'request', }, }) @@ -58,7 +57,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', transactionType: 'request', environment: 'production', }, diff --git a/x-pack/test/apm_api_integration/tests/services/throughput.ts b/x-pack/test/apm_api_integration/tests/services/throughput.ts index 787436ea37b05..4f568aafe33cc 100644 --- a/x-pack/test/apm_api_integration/tests/services/throughput.ts +++ b/x-pack/test/apm_api_integration/tests/services/throughput.ts @@ -29,7 +29,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { `/api/apm/services/opbeans-java/throughput?${qs.stringify({ start: metadata.start, end: metadata.end, - uiFilters: encodeURIComponent('{}'), transactionType: 'request', })}` ); @@ -49,7 +48,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { `/api/apm/services/opbeans-java/throughput?${qs.stringify({ start: metadata.start, end: metadata.end, - uiFilters: encodeURIComponent('{}'), transactionType: 'request', })}` ); @@ -96,7 +94,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { before(async () => { const response = await supertest.get( `/api/apm/services/opbeans-java/throughput?${qs.stringify({ - uiFilters: encodeURIComponent('{}'), transactionType: 'request', start: moment(metadata.end).subtract(15, 'minutes').toISOString(), end: metadata.end, diff --git a/x-pack/test/apm_api_integration/tests/services/top_services.ts b/x-pack/test/apm_api_integration/tests/services/top_services.ts index 3afaec653fcb3..3896bc1c6fabc 100644 --- a/x-pack/test/apm_api_integration/tests/services/top_services.ts +++ b/x-pack/test/apm_api_integration/tests/services/top_services.ts @@ -25,16 +25,12 @@ export default function ApiTest({ getService }: FtrProviderContext) { const start = encodeURIComponent(range.start); const end = encodeURIComponent(range.end); - const uiFilters = encodeURIComponent(JSON.stringify({})); - registry.when( 'APM Services Overview with a basic license when data is not loaded', { config: 'basic', archives: [] }, () => { it('handles the empty state', async () => { - const response = await supertest.get( - `/api/apm/services?start=${start}&end=${end}&uiFilters=${uiFilters}` - ); + const response = await supertest.get(`/api/apm/services?start=${start}&end=${end}`); expect(response.status).to.be(200); expect(response.body.hasHistoricalData).to.be(false); @@ -56,9 +52,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { let sortedItems: typeof response.body.items; before(async () => { - response = await supertest.get( - `/api/apm/services?start=${start}&end=${end}&uiFilters=${uiFilters}` - ); + response = await supertest.get(`/api/apm/services?start=${start}&end=${end}`); sortedItems = sortBy(response.body.items, 'serviceName'); }); @@ -273,9 +267,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }; before(async () => { - response = await supertest.get( - `/api/apm/services?start=${start}&end=${end}&uiFilters=${uiFilters}` - ); + response = await supertest.get(`/api/apm/services?start=${start}&end=${end}`); }); it('the response is successful', () => { @@ -321,7 +313,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { let response: PromiseReturnType; before(async () => { response = await supertestAsApmReadUserWithoutMlAccess.get( - `/api/apm/services?start=${start}&end=${end}&uiFilters=${uiFilters}` + `/api/apm/services?start=${start}&end=${end}` ); }); @@ -346,8 +338,8 @@ export default function ApiTest({ getService }: FtrProviderContext) { let response: PromiseReturnType; before(async () => { response = await supertest.get( - `/api/apm/services?environment=ENVIRONMENT_ALL&start=${start}&end=${end}&uiFilters=${encodeURIComponent( - `{"kuery":"service.name:opbeans-java"}` + `/api/apm/services?environment=ENVIRONMENT_ALL&start=${start}&end=${end}&kuery=${encodeURIComponent( + 'service.name:opbeans-java' )}` ); }); diff --git a/x-pack/test/apm_api_integration/tests/traces/top_traces.ts b/x-pack/test/apm_api_integration/tests/traces/top_traces.ts index fb19c74e05cf4..40f87be3dc402 100644 --- a/x-pack/test/apm_api_integration/tests/traces/top_traces.ts +++ b/x-pack/test/apm_api_integration/tests/traces/top_traces.ts @@ -20,13 +20,10 @@ export default function ApiTest({ getService }: FtrProviderContext) { // url parameters const start = encodeURIComponent(metadata.start); const end = encodeURIComponent(metadata.end); - const uiFilters = encodeURIComponent(JSON.stringify({})); registry.when('Top traces when data is not loaded', { config: 'basic', archives: [] }, () => { it('handles empty state', async () => { - const response = await supertest.get( - `/api/apm/traces?start=${start}&end=${end}&uiFilters=${uiFilters}` - ); + const response = await supertest.get(`/api/apm/traces?start=${start}&end=${end}`); expect(response.status).to.be(200); expect(response.body.items.length).to.be(0); @@ -40,9 +37,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { () => { let response: any; before(async () => { - response = await supertest.get( - `/api/apm/traces?start=${start}&end=${end}&uiFilters=${uiFilters}` - ); + response = await supertest.get(`/api/apm/traces?start=${start}&end=${end}`); }); it('returns the correct status code', async () => { diff --git a/x-pack/test/apm_api_integration/tests/transactions/breakdown.ts b/x-pack/test/apm_api_integration/tests/transactions/breakdown.ts index 90ade5bb9c8a9..8e29004deb4f3 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/breakdown.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/breakdown.ts @@ -20,12 +20,11 @@ export default function ApiTest({ getService }: FtrProviderContext) { const end = encodeURIComponent(metadata.end); const transactionType = 'request'; const transactionName = 'GET /api'; - const uiFilters = encodeURIComponent(JSON.stringify({})); registry.when('Breakdown when data is not loaded', { config: 'basic', archives: [] }, () => { it('handles the empty state', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` + `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&transactionType=${transactionType}` ); expect(response.status).to.be(200); expect(response.body).to.eql({ timeseries: [] }); @@ -35,7 +34,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { registry.when('when data is loaded', { config: 'basic', archives: [archiveName] }, () => { it('returns the transaction breakdown for a service', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` + `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&transactionType=${transactionType}` ); expect(response.status).to.be(200); @@ -43,7 +42,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); it('returns the transaction breakdown for a transaction group', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}&transactionName=${transactionName}` + `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&transactionType=${transactionType}&transactionName=${transactionName}` ); expect(response.status).to.be(200); @@ -102,7 +101,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); it('returns the transaction breakdown sorted by name', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` + `/api/apm/services/opbeans-node/transaction/charts/breakdown?start=${start}&end=${end}&transactionType=${transactionType}` ); expect(response.status).to.be(200); diff --git a/x-pack/test/apm_api_integration/tests/transactions/distribution.ts b/x-pack/test/apm_api_integration/tests/transactions/distribution.ts index 56d5e217068a4..770fc90267680 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/distribution.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/distribution.ts @@ -21,7 +21,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { const url = `/api/apm/services/opbeans-java/transactions/charts/distribution?${qs.stringify({ start: metadata.start, end: metadata.end, - uiFilters: encodeURIComponent('{}'), transactionName: 'APIRestController#stats', transactionType: 'request', })}`; diff --git a/x-pack/test/apm_api_integration/tests/transactions/error_rate.ts b/x-pack/test/apm_api_integration/tests/transactions/error_rate.ts index 73b40648b5377..2b94816466aa7 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/error_rate.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/error_rate.ts @@ -19,12 +19,11 @@ export default function ApiTest({ getService }: FtrProviderContext) { // url parameters const { start, end } = archives_metadata[archiveName]; - const uiFilters = '{}'; const transactionType = 'request'; const url = format({ pathname: '/api/apm/services/opbeans-java/transactions/charts/error_rate', - query: { start, end, uiFilters, transactionType }, + query: { start, end, transactionType }, }); registry.when('Error rate when data is not loaded', { config: 'basic', archives: [] }, () => { diff --git a/x-pack/test/apm_api_integration/tests/transactions/latency.ts b/x-pack/test/apm_api_integration/tests/transactions/latency.ts index 523139717b309..4b9409ce6f16b 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/latency.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/latency.ts @@ -26,10 +26,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { 'Latency with a basic license when data is not loaded ', { config: 'basic', archives: [] }, () => { - const uiFilters = encodeURIComponent(JSON.stringify({})); it('returns 400 when latencyAggregationType is not informed', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=request` + `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=request` ); expect(response.status).to.be(400); @@ -37,7 +36,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { it('returns 400 when transactionType is not informed', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&uiFilters=${uiFilters}&latencyAggregationType=avg` + `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&latencyAggregationType=avg` ); expect(response.status).to.be(400); @@ -45,7 +44,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { it('handles the empty state', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&uiFilters=${uiFilters}&latencyAggregationType=avg&transactionType=request` + `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&latencyAggregationType=avg&transactionType=request` ); expect(response.status).to.be(200); @@ -62,12 +61,10 @@ export default function ApiTest({ getService }: FtrProviderContext) { () => { let response: PromiseReturnType; - const uiFilters = encodeURIComponent(JSON.stringify({})); - describe('average latency type', () => { before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=request&latencyAggregationType=avg` + `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=request&latencyAggregationType=avg` ); }); @@ -81,7 +78,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { describe('95th percentile latency type', () => { before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=request&latencyAggregationType=p95` + `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=request&latencyAggregationType=p95` ); }); @@ -95,7 +92,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { describe('99th percentile latency type', () => { before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=request&latencyAggregationType=p99` + `/api/apm/services/opbeans-node/transactions/charts/latency?environment=testing&start=${start}&end=${end}&transactionType=request&latencyAggregationType=p99` ); }); @@ -117,10 +114,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { const transactionType = 'request'; describe('without an environment', () => { - const uiFilters = encodeURIComponent(JSON.stringify({})); before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-java/transactions/charts/latency?start=${start}&end=${end}&transactionType=${transactionType}&uiFilters=${uiFilters}&latencyAggregationType=avg` + `/api/apm/services/opbeans-java/transactions/charts/latency?start=${start}&end=${end}&transactionType=${transactionType}&latencyAggregationType=avg` ); }); @@ -129,22 +125,10 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); }); - describe('without uiFilters', () => { - before(async () => { - response = await supertest.get( - `/api/apm/services/opbeans-java/transactions/charts/latency?start=${start}&end=${end}&transactionType=${transactionType}&latencyAggregationType=avg` - ); - }); - it('should return an error response', () => { - expect(response.status).to.eql(400); - }); - }); - describe('with environment selected', () => { - const uiFilters = encodeURIComponent(JSON.stringify({})); before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-java/transactions/charts/latency?environment=production&start=${start}&end=${end}&transactionType=${transactionType}&uiFilters=${uiFilters}&latencyAggregationType=avg` + `/api/apm/services/opbeans-java/transactions/charts/latency?environment=production&start=${start}&end=${end}&transactionType=${transactionType}&latencyAggregationType=avg` ); }); @@ -168,10 +152,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); describe('when not defined environment is selected', () => { - const uiFilters = encodeURIComponent(JSON.stringify({})); before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-python/transactions/charts/latency?environment=ENVIRONMENT_NOT_DEFINED&start=${start}&end=${end}&transactionType=${transactionType}&uiFilters=${uiFilters}&latencyAggregationType=avg` + `/api/apm/services/opbeans-python/transactions/charts/latency?environment=ENVIRONMENT_NOT_DEFINED&start=${start}&end=${end}&transactionType=${transactionType}&latencyAggregationType=avg` ); }); @@ -194,10 +177,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); describe('with all environments selected', () => { - const uiFilters = encodeURIComponent(JSON.stringify({})); before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-java/transactions/charts/latency?environment=ENVIRONMENT_ALL&start=${start}&end=${end}&transactionType=${transactionType}&uiFilters=${uiFilters}&latencyAggregationType=avg` + `/api/apm/services/opbeans-java/transactions/charts/latency?environment=ENVIRONMENT_ALL&start=${start}&end=${end}&transactionType=${transactionType}&latencyAggregationType=avg` ); }); @@ -211,10 +193,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }); describe('with environment selected and empty kuery filter', () => { - const uiFilters = encodeURIComponent(JSON.stringify({ kuery: '' })); before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-java/transactions/charts/latency?environment=production&start=${start}&end=${end}&transactionType=${transactionType}&uiFilters=${uiFilters}&latencyAggregationType=avg` + `/api/apm/services/opbeans-java/transactions/charts/latency?environment=production&start=${start}&end=${end}&transactionType=${transactionType}&latencyAggregationType=avg` ); }); diff --git a/x-pack/test/apm_api_integration/tests/transactions/throughput.ts b/x-pack/test/apm_api_integration/tests/transactions/throughput.ts index 430392a32bfb8..5c2de185fdf79 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/throughput.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/throughput.ts @@ -20,7 +20,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { // url parameters const { start, end } = metadata; - const uiFilters = JSON.stringify({}); registry.when('Throughput when data is not loaded', { config: 'basic', archives: [] }, () => { it('handles the empty state', async () => { @@ -31,7 +30,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { environment: 'testing', start, end, - uiFilters, transactionType: 'request', }, }) @@ -57,7 +55,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { environment: 'testing', start, end, - uiFilters, transactionType: 'request', }, }) diff --git a/x-pack/test/apm_api_integration/tests/transactions/top_transaction_groups.ts b/x-pack/test/apm_api_integration/tests/transactions/top_transaction_groups.ts index 165853203429f..32effa64e60db 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/top_transaction_groups.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/top_transaction_groups.ts @@ -24,7 +24,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { // url parameters const start = encodeURIComponent(metadata.start); const end = encodeURIComponent(metadata.end); - const uiFilters = encodeURIComponent(JSON.stringify({})); const transactionType = 'request'; registry.when( @@ -33,7 +32,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { () => { it('handles empty state', async () => { const response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/groups?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` + `/api/apm/services/opbeans-node/transactions/groups?start=${start}&end=${end}&transactionType=${transactionType}` ); expect(response.status).to.be(200); @@ -51,7 +50,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { let response: any; before(async () => { response = await supertest.get( - `/api/apm/services/opbeans-node/transactions/groups?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` + `/api/apm/services/opbeans-node/transactions/groups?start=${start}&end=${end}&transactionType=${transactionType}` ); }); diff --git a/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_comparison_statistics.ts b/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_comparison_statistics.ts index 414e2189a63fe..fdc499594aad0 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_comparison_statistics.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_comparison_statistics.ts @@ -33,7 +33,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, latencyAggregationType: 'avg', transactionType: 'request', @@ -59,7 +58,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, transactionType: 'request', latencyAggregationType: 'avg', @@ -103,7 +101,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, transactionType: 'request', latencyAggregationType: 'p99', @@ -141,7 +138,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', numBuckets: 20, transactionType: 'request', latencyAggregationType: 'avg', diff --git a/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_primary_statistics.ts b/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_primary_statistics.ts index 7d8417bc5bf63..b6fd4054a351c 100644 --- a/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_primary_statistics.ts +++ b/x-pack/test/apm_api_integration/tests/transactions/transactions_groups_primary_statistics.ts @@ -32,7 +32,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', latencyAggregationType: 'avg', transactionType: 'request', }, @@ -58,7 +57,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', transactionType: 'request', latencyAggregationType: 'avg', }, @@ -131,7 +129,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { query: { start, end, - uiFilters: '{}', transactionType: 'request', latencyAggregationType: 'p99', },