diff --git a/src/plugins/apm_oss/server/mocks.ts b/src/plugins/apm_oss/server/mocks.ts index 68cb00440802e..30904ab30d865 100644 --- a/src/plugins/apm_oss/server/mocks.ts +++ b/src/plugins/apm_oss/server/mocks.ts @@ -24,6 +24,7 @@ import { APMOSSPluginSetup } from './plugin'; const apmStar = 'apm-*'; const defaultConfig = { + enabled: true, errorIndices: apmStar, indexPattern: apmStar, metricsIndices: apmStar, diff --git a/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts b/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts index dd142dded6e71..f45ebf60f0264 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts @@ -3,16 +3,28 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { uniq } from 'lodash'; +import { uniq, pick } from 'lodash'; +import { APMOSSConfig } from '../../../../../../src/plugins/apm_oss/server'; -export const extractIndexPatterns = (apmConfig: Record): string[] => - uniq( - [ - 'sourcemapIndices', - 'errorIndices', - 'transactionIndices', - 'spanIndices', - 'metricsIndices', - 'onboardingIndices', - ].map(type => apmConfig[type]!) - ); +type APMIndexConfig = Pick< + APMOSSConfig, + | 'sourcemapIndices' + | 'errorIndices' + | 'transactionIndices' + | 'spanIndices' + | 'metricsIndices' + | 'onboardingIndices' +>; + +export const extractIndexPatterns = (apmConfig: APMOSSConfig): string[] => { + const indexConfigs = pick(apmConfig, [ + 'sourcemapIndices', + 'errorIndices', + 'transactionIndices', + 'spanIndices', + 'metricsIndices', + 'onboardingIndices', + ]); + + return uniq(Object.values(indexConfigs)); +};