From 8c09455b3e15c5a2c542f96712b3415fea2f8b67 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Fri, 7 Dec 2018 22:57:53 -0800 Subject: [PATCH] [APM] Transaction group agg size config (#26683) * [APM] Fixes #24204 by adding default configs to kibana.yml * [APM] fixes #25940 by adding APM config to control top transation group agg size * Revert the default configs added to kibana.yml and define joi validations for `xpack.apm.ui.transactionGroupBucketSize` * fix broken test for incorrect config * [APM] add docs entry for `xpack.apm.ui.transactionGroupBucketSize` --- docs/settings/apm-settings.asciidoc | 2 ++ x-pack/plugins/apm/index.js | 3 ++- .../apm/server/lib/transaction_groups/fetcher.test.ts | 9 ++++++++- .../plugins/apm/server/lib/transaction_groups/fetcher.ts | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/settings/apm-settings.asciidoc b/docs/settings/apm-settings.asciidoc index e4daf8b4ce32e..fc2fc0a4ed7ad 100644 --- a/docs/settings/apm-settings.asciidoc +++ b/docs/settings/apm-settings.asciidoc @@ -17,6 +17,8 @@ xpack.apm.enabled:: Set to `false` to disabled the APM plugin {kib}. Defaults to xpack.apm.ui.enabled:: Set to `false` to hide the APM plugin {kib} from the menu. Defaults to `true`. +xpack.apm.ui.transactionGroupBucketSize:: Number of top transaction groups displayed in APM plugin in Kibana. Defaults to `100`. + apm_oss.indexPattern:: Index pattern is used for integrations with Machine Learning and Kuery Bar. It must match all apm indices. Defaults to `apm-*`. apm_oss.errorIndices:: Matcher for indices containing error documents. Defaults to `apm-*`. diff --git a/x-pack/plugins/apm/index.js b/x-pack/plugins/apm/index.js index 5337aa5817276..b9965ccac70ec 100644 --- a/x-pack/plugins/apm/index.js +++ b/x-pack/plugins/apm/index.js @@ -51,7 +51,8 @@ export function apm(kibana) { return Joi.object({ // display menu item ui: Joi.object({ - enabled: Joi.boolean().default(true) + enabled: Joi.boolean().default(true), + transactionGroupBucketSize: Joi.number().default(100) }).default(), // enable plugin diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts index cfbffe77222f3..6dc8680a706c4 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.test.ts @@ -17,7 +17,14 @@ describe('transactionGroupsFetcher', () => { end: 1528977600000, client: clientSpy, config: { - get: () => 'myIndex' as any + get: jest.fn((key: string) => { + switch (key) { + case 'apm_oss.transactionIndices': + return 'myIndex'; + case 'xpack.apm.ui.transactionGroupBucketSize': + return 100; + } + }) } }; const bodyQuery = { my: 'bodyQuery' }; 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 ad0aa00d35bc9..eda72b750a7aa 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -53,7 +53,7 @@ export function transactionGroupsFetcher( terms: { field: `${TRANSACTION_NAME}.keyword`, order: { sum: 'desc' }, - size: 100 + size: config.get('xpack.apm.ui.transactionGroupBucketSize') }, aggs: { sample: {