kibana/x-pack/plugins/apm/server/routes/ui_filters.ts

276 lines
7.4 KiB
TypeScript
Raw Normal View History

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import * as t from 'io-ts';
import { omit } from 'lodash';
import {
setupRequest,
Setup,
2020-05-22 09:08:58 +02:00
SetupTimeRange,
} from '../lib/helpers/setup_request';
import { getEnvironments } from '../lib/ui_filters/get_environments';
import { Projection } from '../projections/typings';
2020-09-30 10:24:38 +02:00
import { localUIFilterNames } from '../lib/ui_filters/local_ui_filters/config';
import { getEsFilter } from '../lib/helpers/convert_ui_filters/get_es_filter';
import { getLocalUIFilters } from '../lib/ui_filters/local_ui_filters';
import { getServicesProjection } from '../projections/services';
import { getTransactionGroupsProjection } from '../projections/transaction_groups';
import { getMetricsProjection } from '../projections/metrics';
import { getErrorGroupsProjection } from '../projections/errors';
import { getTransactionsProjection } from '../projections/transactions';
import { createRoute } from './create_route';
import { uiFiltersRt, rangeRt } from './default_api_types';
import { jsonRt } from '../../common/runtime_types/json_rt';
import { getServiceNodesProjection } from '../projections/service_nodes';
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
import { getRumPageLoadTransactionsProjection } from '../projections/rum_page_load_transactions';
import { getSearchAggregatedTransactions } from '../lib/helpers/aggregated_transactions';
import { APMRequestHandlerContext } from './typings';
2020-09-30 10:24:38 +02:00
import { LocalUIFilterName } from '../../common/ui_filter';
export const uiFiltersEnvironmentsRoute = createRoute(() => ({
path: '/api/apm/ui_filters/environments',
params: {
query: t.intersection([
t.partial({
2020-05-22 09:08:58 +02:00
serviceName: t.string,
}),
2020-05-22 09:08:58 +02:00
rangeRt,
]),
},
handler: async ({ context, request }) => {
const setup = await setupRequest(context, request);
const { serviceName } = context.params.query;
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
setup
);
return getEnvironments({
setup,
serviceName,
searchAggregatedTransactions,
});
2020-05-22 09:08:58 +02:00
},
}));
const filterNamesRt = t.type({
filterNames: jsonRt.pipe(
t.array(
t.keyof(
Object.fromEntries(
2020-05-22 09:08:58 +02:00
localUIFilterNames.map((filterName) => [filterName, null])
) as Record<LocalUIFilterName, null>
)
)
2020-05-22 09:08:58 +02:00
),
});
const localUiBaseQueryRt = t.intersection([
filterNamesRt,
uiFiltersRt,
2020-05-22 09:08:58 +02:00
rangeRt,
]);
function createLocalFiltersRoute<
TPath extends string,
TProjection extends Projection,
TQueryRT extends t.HasProps
>({
path,
getProjection,
2020-05-22 09:08:58 +02:00
queryRt,
}: {
path: TPath;
Bump TypeScript to v3.9 (#67666) * add babel support for export type * bump ts version to 3.9.3 * rebuild kbn-pm * bump typescript-eslint * fix error in security plugin UI * check export as works * fix app migration type * use correct test subj attribute * fix errors from the old PR * embeddable is already passed in props * explicitly define type of fetch * add some types for viz * fix fetch type p.2 * add null to allow spreading without type errors due to override * add type guard to fix type error * cast to any, since cannot assign unknown * add timestamp to known types * fix type error in fetch * fix type error. id is always defined in attibutes * declare a type * move ts-ignore to the lines with errors * declare tuple type explicitly * mute type error. cannot assign unknown * fix errors. id is always defined * fix error type * fix override errors. id is always defined * fix error. extends any doesn't work anymore * fix type error. type is always defined * env doesn't always contain values * fix type error * cast to string * add: logs is already declared in getNodeLogsUrl * state is already passed in props * fix some errors in timelion * number of fragments is always defined * 'absolute' is not just string, but value * TEMP: option is always defined * always true if cast to promise manually * both props are always defined * explicitly define returned SO type * workaround type * bump tslib to be compatible with ts v3.9 * test private property * rebuild kbn-pm * Fix ts errors for beats management * Fix type inference broken by the TS 3.9 upgrade * Fix ingest manager saved object attributes typings * Fix TS errors in cross_cluster_replication and index_management. * Fix TS error in Watcher. * roll back colorRange wrong type * fix security plugin types * TypeScript 3.9 fixes for APM * Fix ColorRange types. * fix actions & alerts errors. ByGidi * fix lists error * More APM fixes * Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.) * Add option chain for case in registerTransactionDurationAlertType * Cast `overallValue` in transform_metrics_chart * Use more specific type for custom link filters * Add more option chaining for local UI filters buckets response * Remove unused parameters from routes * Fix getProjection type parameter * Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error * Revert `UnionToIntersection` change in `AggregationResponseMap` Fixes #67804. * fix platform type error * Fix visualizations types. * Fix data plugin types. * bump TS version to 3.9.5 * Fix telemetry TS errors * Fix dashboard code * Adding Canvas Fixes for TS 3.9 * Fix case and security_solution types * roll back to the old export syntax. new one might cause problems in api-extractor * update docs * Fix timelion code * Fix meta * Fix types * fix type errors om ingest_manager * bump babel deps * enable private props & methods syntax * update kbn-pm dist * whitelist 0BSD license * use @babel/plugin-proposal-private-methods in default set as well * disable new babel plugins * Revert "disable new babel plugins" This reverts commit 04d959431d456a082666bf7834f129f1aafd0772. * cleanup security_solution types * Fixes type error for newer TypeScript * update docs Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co> Co-authored-by: Felix Stürmer <stuermer@weltenwort.de> Co-authored-by: CJ Cenizal <cj@cenizal.com> Co-authored-by: Larry Gregory <larry.gregory@elastic.co> Co-authored-by: Nathan L Smith <smith@nlsmith.com> Co-authored-by: Walter Rafelsberger <walter@elastic.co> Co-authored-by: Luke Elmers <luke.elmers@elastic.co> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> Co-authored-by: Tim Roes <tim.roes@elastic.co> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
getProjection: GetProjection<
TProjection,
t.IntersectionC<[TQueryRT, BaseQueryType]>
>;
queryRt: TQueryRT;
}) {
return createRoute(() => ({
path,
params: {
2020-05-22 09:08:58 +02:00
query: t.intersection([localUiBaseQueryRt, queryRt]),
},
handler: async ({ context, request }) => {
const setup = await setupRequest(context, request);
const { uiFilters } = setup;
const { query } = context.params;
const { filterNames } = query;
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
const projection = await getProjection({
query,
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
context,
setup: {
...setup,
esFilter: getEsFilter(omit(uiFilters, filterNames)),
2020-05-22 09:08:58 +02:00
},
});
return getLocalUIFilters({
projection,
setup,
uiFilters,
2020-05-22 09:08:58 +02:00
localFilterNames: filterNames,
});
2020-05-22 09:08:58 +02:00
},
}));
}
export const servicesLocalFiltersRoute = createLocalFiltersRoute({
path: `/api/apm/ui_filters/local_filters/services`,
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
getProjection: async ({ context, setup }) => {
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
setup
);
return getServicesProjection({ setup, searchAggregatedTransactions });
},
2020-05-22 09:08:58 +02:00
queryRt: t.type({}),
});
export const transactionGroupsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/transactionGroups',
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
getProjection: async ({ context, setup, query }) => {
const { transactionType, serviceName, transactionName } = query;
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
setup
);
return getTransactionGroupsProjection({
setup,
options: {
type: 'top_transactions',
transactionType,
serviceName,
2020-05-22 09:08:58 +02:00
transactionName,
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
searchAggregatedTransactions,
2020-05-22 09:08:58 +02:00
},
});
},
queryRt: t.intersection([
t.type({
serviceName: t.string,
2020-05-22 09:08:58 +02:00
transactionType: t.string,
}),
t.partial({
2020-05-22 09:08:58 +02:00
transactionName: t.string,
}),
]),
});
export const tracesLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/traces',
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
getProjection: async ({ setup, context }) => {
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
setup
);
return getTransactionGroupsProjection({
setup,
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
options: { type: 'top_traces', searchAggregatedTransactions },
});
},
2020-05-22 09:08:58 +02:00
queryRt: t.type({}),
});
export const transactionsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/transactions',
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
getProjection: async ({ context, setup, query }) => {
const { transactionType, serviceName, transactionName } = query;
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
setup
);
return getTransactionsProjection({
setup,
transactionType,
serviceName,
2020-05-22 09:08:58 +02:00
transactionName,
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
searchAggregatedTransactions,
});
},
queryRt: t.type({
transactionType: t.string,
transactionName: t.string,
2020-05-22 09:08:58 +02:00
serviceName: t.string,
}),
});
export const metricsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/metrics',
getProjection: ({ setup, query }) => {
const { serviceName, serviceNodeName } = query;
return getMetricsProjection({
setup,
serviceName,
2020-05-22 09:08:58 +02:00
serviceNodeName,
});
},
queryRt: t.intersection([
t.type({
2020-05-22 09:08:58 +02:00
serviceName: t.string,
}),
t.partial({
2020-05-22 09:08:58 +02:00
serviceNodeName: t.string,
}),
]),
});
export const errorGroupsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/errorGroups',
getProjection: ({ setup, query }) => {
const { serviceName } = query;
return getErrorGroupsProjection({
setup,
2020-05-22 09:08:58 +02:00
serviceName,
});
},
queryRt: t.type({
2020-05-22 09:08:58 +02:00
serviceName: t.string,
}),
});
export const serviceNodesLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/serviceNodes',
getProjection: ({ setup, query }) => {
Bump TypeScript to v3.9 (#67666) * add babel support for export type * bump ts version to 3.9.3 * rebuild kbn-pm * bump typescript-eslint * fix error in security plugin UI * check export as works * fix app migration type * use correct test subj attribute * fix errors from the old PR * embeddable is already passed in props * explicitly define type of fetch * add some types for viz * fix fetch type p.2 * add null to allow spreading without type errors due to override * add type guard to fix type error * cast to any, since cannot assign unknown * add timestamp to known types * fix type error in fetch * fix type error. id is always defined in attibutes * declare a type * move ts-ignore to the lines with errors * declare tuple type explicitly * mute type error. cannot assign unknown * fix errors. id is always defined * fix error type * fix override errors. id is always defined * fix error. extends any doesn't work anymore * fix type error. type is always defined * env doesn't always contain values * fix type error * cast to string * add: logs is already declared in getNodeLogsUrl * state is already passed in props * fix some errors in timelion * number of fragments is always defined * 'absolute' is not just string, but value * TEMP: option is always defined * always true if cast to promise manually * both props are always defined * explicitly define returned SO type * workaround type * bump tslib to be compatible with ts v3.9 * test private property * rebuild kbn-pm * Fix ts errors for beats management * Fix type inference broken by the TS 3.9 upgrade * Fix ingest manager saved object attributes typings * Fix TS errors in cross_cluster_replication and index_management. * Fix TS error in Watcher. * roll back colorRange wrong type * fix security plugin types * TypeScript 3.9 fixes for APM * Fix ColorRange types. * fix actions & alerts errors. ByGidi * fix lists error * More APM fixes * Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.) * Add option chain for case in registerTransactionDurationAlertType * Cast `overallValue` in transform_metrics_chart * Use more specific type for custom link filters * Add more option chaining for local UI filters buckets response * Remove unused parameters from routes * Fix getProjection type parameter * Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error * Revert `UnionToIntersection` change in `AggregationResponseMap` Fixes #67804. * fix platform type error * Fix visualizations types. * Fix data plugin types. * bump TS version to 3.9.5 * Fix telemetry TS errors * Fix dashboard code * Adding Canvas Fixes for TS 3.9 * Fix case and security_solution types * roll back to the old export syntax. new one might cause problems in api-extractor * update docs * Fix timelion code * Fix meta * Fix types * fix type errors om ingest_manager * bump babel deps * enable private props & methods syntax * update kbn-pm dist * whitelist 0BSD license * use @babel/plugin-proposal-private-methods in default set as well * disable new babel plugins * Revert "disable new babel plugins" This reverts commit 04d959431d456a082666bf7834f129f1aafd0772. * cleanup security_solution types * Fixes type error for newer TypeScript * update docs Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co> Co-authored-by: Felix Stürmer <stuermer@weltenwort.de> Co-authored-by: CJ Cenizal <cj@cenizal.com> Co-authored-by: Larry Gregory <larry.gregory@elastic.co> Co-authored-by: Nathan L Smith <smith@nlsmith.com> Co-authored-by: Walter Rafelsberger <walter@elastic.co> Co-authored-by: Luke Elmers <luke.elmers@elastic.co> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> Co-authored-by: Tim Roes <tim.roes@elastic.co> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
const { serviceName } = query;
return getServiceNodesProjection({
setup,
Bump TypeScript to v3.9 (#67666) * add babel support for export type * bump ts version to 3.9.3 * rebuild kbn-pm * bump typescript-eslint * fix error in security plugin UI * check export as works * fix app migration type * use correct test subj attribute * fix errors from the old PR * embeddable is already passed in props * explicitly define type of fetch * add some types for viz * fix fetch type p.2 * add null to allow spreading without type errors due to override * add type guard to fix type error * cast to any, since cannot assign unknown * add timestamp to known types * fix type error in fetch * fix type error. id is always defined in attibutes * declare a type * move ts-ignore to the lines with errors * declare tuple type explicitly * mute type error. cannot assign unknown * fix errors. id is always defined * fix error type * fix override errors. id is always defined * fix error. extends any doesn't work anymore * fix type error. type is always defined * env doesn't always contain values * fix type error * cast to string * add: logs is already declared in getNodeLogsUrl * state is already passed in props * fix some errors in timelion * number of fragments is always defined * 'absolute' is not just string, but value * TEMP: option is always defined * always true if cast to promise manually * both props are always defined * explicitly define returned SO type * workaround type * bump tslib to be compatible with ts v3.9 * test private property * rebuild kbn-pm * Fix ts errors for beats management * Fix type inference broken by the TS 3.9 upgrade * Fix ingest manager saved object attributes typings * Fix TS errors in cross_cluster_replication and index_management. * Fix TS error in Watcher. * roll back colorRange wrong type * fix security plugin types * TypeScript 3.9 fixes for APM * Fix ColorRange types. * fix actions & alerts errors. ByGidi * fix lists error * More APM fixes * Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.) * Add option chain for case in registerTransactionDurationAlertType * Cast `overallValue` in transform_metrics_chart * Use more specific type for custom link filters * Add more option chaining for local UI filters buckets response * Remove unused parameters from routes * Fix getProjection type parameter * Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error * Revert `UnionToIntersection` change in `AggregationResponseMap` Fixes #67804. * fix platform type error * Fix visualizations types. * Fix data plugin types. * bump TS version to 3.9.5 * Fix telemetry TS errors * Fix dashboard code * Adding Canvas Fixes for TS 3.9 * Fix case and security_solution types * roll back to the old export syntax. new one might cause problems in api-extractor * update docs * Fix timelion code * Fix meta * Fix types * fix type errors om ingest_manager * bump babel deps * enable private props & methods syntax * update kbn-pm dist * whitelist 0BSD license * use @babel/plugin-proposal-private-methods in default set as well * disable new babel plugins * Revert "disable new babel plugins" This reverts commit 04d959431d456a082666bf7834f129f1aafd0772. * cleanup security_solution types * Fixes type error for newer TypeScript * update docs Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co> Co-authored-by: Felix Stürmer <stuermer@weltenwort.de> Co-authored-by: CJ Cenizal <cj@cenizal.com> Co-authored-by: Larry Gregory <larry.gregory@elastic.co> Co-authored-by: Nathan L Smith <smith@nlsmith.com> Co-authored-by: Walter Rafelsberger <walter@elastic.co> Co-authored-by: Luke Elmers <luke.elmers@elastic.co> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co> Co-authored-by: Tim Roes <tim.roes@elastic.co> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co> Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com> Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
serviceName,
});
},
queryRt: t.type({
2020-05-22 09:08:58 +02:00
serviceName: t.string,
}),
});
export const rumOverviewLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/rumOverview',
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
getProjection: async ({ setup }) => {
return getRumPageLoadTransactionsProjection({
setup,
});
},
queryRt: t.type({}),
});
type BaseQueryType = typeof localUiBaseQueryRt;
type GetProjection<
TProjection extends Projection,
TQueryRT extends t.HasProps
> = ({
query,
2020-05-22 09:08:58 +02:00
setup,
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
context,
}: {
query: t.TypeOf<TQueryRT>;
setup: Setup & SetupTimeRange;
[APM] Metrics-powered UI (#73953) * [APM] Optimize service overview queries * Review feedback * Use correct indices/filters for service overview metrics * [APM] Optimize traces overview * Separate queries into separate file * Support union types for aggregations * [APM] Don't fetch dynamic index pattern in setupRequest We don't need a dynamic index pattern for parsing the filters from the query bar. Additionally, instead of fetching uiIndices in `getParamsForSearchRequest`, we can use `indices` that we already fetched in `setupRequest`. * use join utility function to merge requests * Correct path for UI_SETTINGS import * Query transaction indices in getEnvironments() * [APM] Introduce apm.types Instead of using a combination of index + terms filters on processor.event, add a top-level setting that allows you to define a type, which can be a processor event type, agent configuration or custom link. This allows us to more easily compose queries. * Set size of terms agg on error rate aggregation * Metrics * Use separate clients for apm events and other uses * Separate function for calculating relative impact * use UIProcessorEvent type in IURLParams type * Remove unused import * Split out strategy in helper functions * Use cloneDeep in apmEventClient.search * Consistent usage of getUseAggregatedTransactions * Update traces functional test * Update API tests * Update responses for functional tests * Review feedback * Fix type for filter/filters aggregation * Review feedback * Rename useAggregatedTransactions > searchAggregatedTransactions * Use correct route name for transaction redirect page * Closes #67744. * Review feedback; offer other strategies than 'auto' * Fix functional tests * [APM] Always load esarchives from common Instead of requiring every test suite to store its archives under {suite}/fixtures/es_archiver, always load them from common/fixtures/es_archiver. * Update script * Make sure tests pass * Update snapshots for API tests * Filter for transaction.root when fetching top traces * Make sure must_not clause is formatted correctly Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-16 19:20:08 +02:00
context: APMRequestHandlerContext;
}) => Promise<TProjection> | TProjection;