Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Adds new configuration 'xpack.apm.maxServiceEnvironments' #82090

Merged
merged 9 commits into from
Nov 6, 2020
3 changes: 3 additions & 0 deletions docs/settings/apm-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Changing these settings may disable features of the APM App.
| `xpack.apm.ui.transactionGroupBucketSize`
| Number of top transaction groups displayed in the APM app. Defaults to `1000`.

| `xpack.apm.ui.maxServiceEnvironments`
| Maximum number of unique service environments recognized by the UI. Defaults to `100`.

| `xpack.apm.ui.maxTraceItems` {ess-icon}
| Maximum number of child items displayed when viewing trace details. Defaults to `1000`.

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/apm/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const config = {
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
transactionGroupBucketSize: schema.number({ defaultValue: 1000 }),
maxServiceEnvironments: schema.number({ defaultValue: 100 }),
Copy link
Member

@sorenlouv sorenlouv Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'm not sure we should have a "ui" section in the first place. Doesn't all the settings affect the ui somehow? Eg serviceMapEnabled: false will certainly be visible in the ui... Should it then be under ui? Makes it a little hard to draw the line about which things belong there or not.

Copy link
Contributor Author

@ogupte ogupte Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that the nesting under ui is pretty arbitrary, we have similar configurations for bucket sizes and max items both with and with that ui section. I'll go ahead and change the new setting to remove it, but we'll have to wait for the 8.0 to migrate other configs out of ui.

maxTraceItems: schema.number({ defaultValue: 1000 }),
}),
searchAggregatedTransactions: schema.oneOf(
Expand Down Expand Up @@ -74,6 +75,7 @@ export function mergeConfigs(
'xpack.apm.serviceMapMaxTracesPerRequest':
apmConfig.serviceMapMaxTracesPerRequest,
'xpack.apm.ui.enabled': apmConfig.ui.enabled,
'xpack.apm.ui.maxServiceEnvironments': apmConfig.ui.maxServiceEnvironments,
'xpack.apm.ui.maxTraceItems': apmConfig.ui.maxTraceItems,
'xpack.apm.ui.transactionGroupBucketSize':
apmConfig.ui.transactionGroupBucketSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function registerErrorCountAlertType({
config,
savedObjectsClient: services.savedObjectsClient,
});
const maxServiceEnvironments =
config['xpack.apm.ui.maxServiceEnvironments'];

const searchParams = {
index: indices['apm_oss.errorIndices'],
Expand Down Expand Up @@ -100,6 +102,7 @@ export function registerErrorCountAlertType({
environments: {
terms: {
field: SERVICE_ENVIRONMENT,
size: maxServiceEnvironments,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export function registerTransactionDurationAlertType({
config,
savedObjectsClient: services.savedObjectsClient,
});
const maxServiceEnvironments =
config['xpack.apm.ui.maxServiceEnvironments'];

const searchParams = {
index: indices['apm_oss.transactionIndices'],
Expand Down Expand Up @@ -112,6 +114,7 @@ export function registerTransactionDurationAlertType({
environments: {
terms: {
field: SERVICE_ENVIRONMENT,
size: maxServiceEnvironments,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export function registerTransactionErrorRateAlertType({
config,
savedObjectsClient: services.savedObjectsClient,
});
const maxServiceEnvironments =
config['xpack.apm.ui.maxServiceEnvironments'];

const searchParams = {
index: indices['apm_oss.transactionIndices'],
Expand Down Expand Up @@ -120,6 +122,7 @@ export function registerTransactionErrorRateAlertType({
environments: {
terms: {
field: SERVICE_ENVIRONMENT,
size: maxServiceEnvironments,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export async function getAllEnvironments({
searchAggregatedTransactions: boolean;
includeMissing?: boolean;
}) {
const { apmEventClient } = setup;
const { apmEventClient, config } = setup;
const maxServiceEnvironments = config['xpack.apm.ui.maxServiceEnvironments'];

// omit filter for service.name if "All" option is selected
const serviceNameFilter = serviceName
Expand Down Expand Up @@ -55,7 +56,7 @@ export async function getAllEnvironments({
environments: {
terms: {
field: SERVICE_ENVIRONMENT,
size: 100,
size: maxServiceEnvironments,
...(!serviceName ? { min_doc_count: 0 } : {}),
missing: includeMissing ? ENVIRONMENT_NOT_DEFINED.value : undefined,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export async function getTraceSampleIds({
? config['xpack.apm.serviceMapTraceIdBucketSize']
: config['xpack.apm.serviceMapTraceIdGlobalBucketSize'];

const maxServiceEnvironments = config['xpack.apm.ui.maxServiceEnvironments'];

const samplerShardSize = traceIdBucketSize * 10;

const params = {
Expand Down Expand Up @@ -90,6 +92,7 @@ export async function getTraceSampleIds({
terms: {
field: SERVICE_ENVIRONMENT,
missing_bucket: true,
size: maxServiceEnvironments,
},
},
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ export const getEnvironments = async ({
setup,
projection,
}: AggregationParams) => {
const { apmEventClient } = setup;
const { apmEventClient, config } = setup;
const maxServiceEnvironments = config['xpack.apm.ui.maxServiceEnvironments'];
const response = await apmEventClient.search(
mergeProjection(projection, {
body: {
Expand All @@ -352,6 +353,7 @@ export const getEnvironments = async ({
environments: {
terms: {
field: SERVICE_ENVIRONMENT,
size: maxServiceEnvironments,
},
},
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export async function getExistingEnvironmentsForService({
serviceName: string | undefined;
setup: Setup;
}) {
const { internalClient, indices } = setup;
const { internalClient, indices, config } = setup;
const maxServiceEnvironments = config['xpack.apm.ui.maxServiceEnvironments'];

const bool = serviceName
? { filter: [{ term: { [SERVICE_NAME]: serviceName } }] }
Expand All @@ -34,7 +35,7 @@ export async function getExistingEnvironmentsForService({
terms: {
field: SERVICE_ENVIRONMENT,
missing: ALL_OPTION_VALUE,
size: 50,
size: maxServiceEnvironments,
},
},
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion x-pack/plugins/apm/server/lib/ui_filters/get_environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function getEnvironments({
serviceName?: string;
searchAggregatedTransactions: boolean;
}) {
const { start, end, apmEventClient } = setup;
const { start, end, apmEventClient, config } = setup;

const filter: ESFilter[] = [{ range: rangeFilter(start, end) }];

Expand All @@ -34,6 +34,8 @@ export async function getEnvironments({
});
}

const maxServiceEnvironments = config['xpack.apm.ui.maxServiceEnvironments'];

const params = {
apm: {
events: [
Expand All @@ -56,6 +58,7 @@ export async function getEnvironments({
terms: {
field: SERVICE_ENVIRONMENT,
missing: ENVIRONMENT_NOT_DEFINED.value,
size: maxServiceEnvironments,
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/apm/server/utils/test_helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export async function inspectSearchParams(

case 'xpack.apm.metricsInterval':
return 30;

case 'xpack.apm.ui.maxServiceEnvironments':
return 100;
}
},
}
Expand Down