Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c81411c
[APM] Add kibana config for the limit of number of services in a serv…
younesmln May 10, 2022
2590947
change kibana config label & description
younesmln May 10, 2022
94c78d9
Allow only positive numbers for service group limit
younesmln May 10, 2022
e1ced6d
Add apm prefix to the kibana config
younesmln May 11, 2022
ec29850
fix a missing renaming
younesmln May 11, 2022
10a4068
revert back to using a constant when getting the list of service groups
younesmln May 16, 2022
3ccaa6f
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
younesmln May 16, 2022
aeb90b0
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
kibanamachine May 19, 2022
5d62b7c
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
younesmln May 23, 2022
2f050fb
Parallelize uiSettings with setupRequest
younesmln May 23, 2022
ebb2406
(Fix) Parallelizing getting the value from uiSettings with setupRequest
younesmln May 23, 2022
4b0ff70
delete uiSettingsClient usage from lookupServices
younesmln May 23, 2022
f72c1a1
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
younesmln May 23, 2022
301a429
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
younesmln May 30, 2022
a5e4cfc
Use kibana advanced config for limiting the number of services
younesmln Jun 1, 2022
3f449b0
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
kibanamachine Jun 7, 2022
125eba2
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
kibanamachine Jun 13, 2022
58bbf97
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
kibanamachine Jun 15, 2022
ae242e3
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
kibanamachine Jun 17, 2022
bc9b686
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
MiriamAparicio Jun 22, 2022
a31d98b
Merge branch 'main' into younesmln-kibana-config-for-max-number-of-se…
kibanamachine Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ import {
} from '../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../common/processor_event';
import { Setup } from '../../lib/helpers/setup_request';
import { MAX_NUMBER_OF_SERVICE_GROUPS } from '../../../common/service_groups';

export async function lookupServices({
setup,
kuery,
start,
end,
maxNumberOfServices,
}: {
setup: Setup;
kuery: string;
start: number;
end: number;
maxNumberOfServices: number;
}) {
const { apmEventClient } = setup;

Expand All @@ -49,7 +50,7 @@ export async function lookupServices({
services: {
terms: {
field: SERVICE_NAME,
size: MAX_NUMBER_OF_SERVICE_GROUPS,
size: maxNumberOfServices,
},
aggs: {
environments: {
Expand Down
36 changes: 29 additions & 7 deletions x-pack/plugins/apm/server/routes/service_groups/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import * as t from 'io-ts';
import { apmServiceGroupMaxNumberOfServices } from '@kbn/observability-plugin/common';
import { setupRequest } from '../../lib/helpers/setup_request';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import { kueryRt, rangeRt } from '../default_api_types';
Expand All @@ -28,8 +29,12 @@ const serviceGroupsRoute = createApmServerRoute({
resources
): Promise<{ serviceGroups: SavedServiceGroup[] }> => {
const { context } = resources;
const savedObjectsClient = (await context.core).savedObjects.client;
const serviceGroups = await getServiceGroups({ savedObjectsClient });
const {
savedObjects: { client: savedObjectsClient },
} = await context.core;
const serviceGroups = await getServiceGroups({
savedObjectsClient,
});
return { serviceGroups };
},
});
Expand All @@ -46,7 +51,9 @@ const serviceGroupRoute = createApmServerRoute({
},
handler: async (resources): Promise<{ serviceGroup: SavedServiceGroup }> => {
const { context, params } = resources;
const savedObjectsClient = (await context.core).savedObjects.client;
const {
savedObjects: { client: savedObjectsClient },
} = await context.core;
const serviceGroup = await getServiceGroup({
savedObjectsClient,
serviceGroupId: params.query.serviceGroup,
Expand Down Expand Up @@ -75,13 +82,21 @@ const serviceGroupSaveRoute = createApmServerRoute({
handler: async (resources): Promise<void> => {
const { context, params } = resources;
const { start, end, serviceGroupId } = params.query;
const savedObjectsClient = (await context.core).savedObjects.client;
const setup = await setupRequest(resources);
const {
savedObjects: { client: savedObjectsClient },
uiSettings: { client: uiSettingsClient },
} = await context.core;
const [setup, maxNumberOfServices] = await Promise.all([
setupRequest(resources),
uiSettingsClient.get<number>(apmServiceGroupMaxNumberOfServices),
]);

const items = await lookupServices({
setup,
kuery: params.body.kuery,
start,
end,
maxNumberOfServices,
});
const serviceNames = items.map(({ serviceName }): string => serviceName);
const serviceGroup: ServiceGroup = {
Expand Down Expand Up @@ -126,14 +141,21 @@ const serviceGroupServicesRoute = createApmServerRoute({
handler: async (
resources
): Promise<{ items: Awaited<ReturnType<typeof lookupServices>> }> => {
const { params } = resources;
const { params, context } = resources;
const { kuery = '', start, end } = params.query;
const setup = await setupRequest(resources);
const {
uiSettings: { client: uiSettingsClient },
} = await context.core;
const [setup, maxNumberOfServices] = await Promise.all([
setupRequest(resources),
uiSettingsClient.get<number>(apmServiceGroupMaxNumberOfServices),
]);
const items = await lookupServices({
setup,
kuery,
start,
end,
maxNumberOfServices,
});
return { items };
},
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/observability/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
defaultApmServiceEnvironment,
apmServiceInventoryOptimizedSorting,
apmProgressiveLoading,
apmServiceGroupMaxNumberOfServices,
} from './ui_settings_keys';

export {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/observability/common/ui_settings_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export const apmProgressiveLoading = 'observability:apmProgressiveLoading';
export const enableServiceGroups = 'observability:enableServiceGroups';
export const apmServiceInventoryOptimizedSorting =
'observability:apmServiceInventoryOptimizedSorting';
export const apmServiceGroupMaxNumberOfServices =
'observability:apmServiceGroupMaxNumberOfServices';
1 change: 1 addition & 0 deletions x-pack/plugins/observability/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export {
enableInfrastructureView,
enableServiceGroups,
enableNewSyntheticsView,
apmServiceGroupMaxNumberOfServices,
} from '../common/ui_settings_keys';
export { uptimeOverviewLocatorID } from '../common';

Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/observability/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
enableServiceGroups,
apmServiceInventoryOptimizedSorting,
enableNewSyntheticsView,
apmServiceGroupMaxNumberOfServices,
} from '../common/ui_settings_keys';

const technicalPreviewLabel = i18n.translate(
Expand Down Expand Up @@ -187,4 +188,15 @@ export const uiSettings: Record<string, UiSettingsParams<boolean | number | stri
requiresPageReload: false,
type: 'boolean',
},
[apmServiceGroupMaxNumberOfServices]: {
category: [observabilityFeatureId],
name: i18n.translate('xpack.observability.serviceGroupMaxServicesUiSettingName', {
defaultMessage: 'Maximum services in a service group',
}),
value: 500,
description: i18n.translate('xpack.observability.serviceGroupMaxServicesUiSettingDescription', {
defaultMessage: 'Limit the number of services in a given service group',
}),
schema: schema.number({ min: 1 }),
},
};