From 93e96aae75b1bd0fd4acd532455e160d5ee69b6e Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Wed, 19 Apr 2023 06:28:31 -0400 Subject: [PATCH] [dot-kibana-split] Adapt usages of `core.savedObjects.getKibanaIndex` to use the correct index (#155155) ### **this PR is targeting the `dot-kibana-split` feature branch and not `main`** ## Summary Part of https://github.com/elastic/kibana/pull/154888 In https://github.com/elastic/kibana/pull/154888, we're going to split the `.kibana` savedObject index into multiple ones. For this reason, calls to `core.savedObjects.getKibanaIndex` will not necessarily return the correct value (e.g types that were moved out of this index) This PR introduces the following SO APIs: - `getDefaultIndex` - `getIndexForType` - `getIndicesForTypes` - `getAllIndices` And adapt plugins code to replace usages of `core.savedObjects.getKibanaIndex` with the proper alternative --- .../src/plugin_context.ts | 7 +- .../src/saved_objects_service.test.ts | 89 +++++++++++++++++++ .../src/saved_objects_service.ts | 20 ++++- .../src/saved_objects_service.mock.ts | 14 ++- .../src/contracts.ts | 30 ++++++- .../dashboard_telemetry_collection_task.ts | 6 +- .../kql_telemetry/kql_telemetry_service.ts | 4 +- .../usage_collector/fetch.test.ts | 2 +- .../kql_telemetry/usage_collector/fetch.ts | 6 +- .../make_kql_usage_collector.test.ts | 6 +- .../make_kql_usage_collector.ts | 7 +- .../server/search/collectors/search/fetch.ts | 5 +- .../search/collectors/search/register.ts | 7 +- .../collectors/search_session/fetch.test.ts | 3 +- .../search/collectors/search_session/fetch.ts | 5 +- .../collectors/search_session/register.ts | 4 +- .../data/server/search/search_service.ts | 10 +-- .../sample_data/sample_data_registry.ts | 7 +- .../services/sample_data/usage/collector.ts | 4 +- .../sample_data/usage/collector_fetch.test.ts | 12 +-- .../sample_data/usage/collector_fetch.ts | 3 +- .../kibana_usage_collector.test.ts | 3 +- .../kibana_usage_collector.ts | 5 +- .../kibana_usage_collection/server/plugin.ts | 8 +- src/plugins/usage_collection/server/plugin.ts | 2 +- .../actions/server/actions_client.test.ts | 26 +++--- .../plugins/actions/server/actions_client.ts | 18 ++-- x-pack/plugins/actions/server/plugin.ts | 18 ++-- x-pack/plugins/actions/server/usage/task.ts | 29 ++---- x-pack/plugins/alerting/server/plugin.ts | 10 +-- .../lib/get_telemetry_from_kibana.test.ts | 8 +- .../usage/lib/get_telemetry_from_kibana.ts | 10 +-- x-pack/plugins/alerting/server/usage/task.ts | 22 ++--- .../canvas/server/collectors/collector.ts | 4 +- .../collectors/custom_element_collector.ts | 5 +- .../server/collectors/workpad_collector.ts | 5 +- x-pack/plugins/canvas/server/plugin.ts | 8 +- x-pack/plugins/canvas/types/telemetry.ts | 5 +- x-pack/plugins/event_log/server/plugin.ts | 4 +- x-pack/plugins/ml/server/plugin.ts | 6 +- x-pack/plugins/ml/server/usage/collector.ts | 12 ++- x-pack/plugins/monitoring/server/plugin.ts | 2 +- .../monitoring_collection/server/plugin.ts | 2 +- .../rollup/server/collectors/register.test.ts | 7 +- .../rollup/server/collectors/register.ts | 11 ++- x-pack/plugins/rollup/server/plugin.ts | 4 +- .../saved_objects_tagging/server/plugin.ts | 6 +- .../server/usage/tag_usage_collector.ts | 9 +- x-pack/plugins/security/server/plugin.ts | 2 +- .../server/lib/telemetry/receiver.ts | 14 +-- .../security_solution/server/plugin.ts | 5 +- x-pack/plugins/spaces/server/plugin.ts | 4 +- .../spaces_usage_collector.test.ts | 9 +- .../spaces_usage_collector.ts | 7 +- x-pack/plugins/task_manager/server/plugin.ts | 4 +- 55 files changed, 354 insertions(+), 191 deletions(-) diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts b/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts index 80caa2e9f2336..191fb3a729135 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts @@ -245,7 +245,8 @@ export function createPluginSetupContext( setSecurityExtension: deps.savedObjects.setSecurityExtension, setSpacesExtension: deps.savedObjects.setSpacesExtension, registerType: deps.savedObjects.registerType, - getKibanaIndex: deps.savedObjects.getKibanaIndex, + getDefaultIndex: deps.savedObjects.getDefaultIndex, + getAllIndices: deps.savedObjects.getAllIndices, }, status: { core$: deps.status.core$, @@ -313,6 +314,10 @@ export function createPluginStartContext( createExporter: deps.savedObjects.createExporter, createImporter: deps.savedObjects.createImporter, getTypeRegistry: deps.savedObjects.getTypeRegistry, + getDefaultIndex: deps.savedObjects.getDefaultIndex, + getIndexForType: deps.savedObjects.getIndexForType, + getIndicesForTypes: deps.savedObjects.getIndicesForTypes, + getAllIndices: deps.savedObjects.getAllIndices, }, metrics: { collectionInterval: deps.metrics.collectionInterval, diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts index fc2cc5a4c91bc..72e36826bb89e 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts @@ -23,6 +23,7 @@ import { type RawPackageInfo, Env } from '@kbn/config'; import { ByteSizeValue } from '@kbn/config-schema'; import { REPO_ROOT } from '@kbn/repo-info'; import { getEnvOptions } from '@kbn/config-mocks'; +import { SavedObjectsType, MAIN_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks'; import { nodeServiceMock } from '@kbn/core-node-server-mocks'; import { mockCoreContext } from '@kbn/core-base-server-mocks'; @@ -55,6 +56,14 @@ import { getSavedObjectsDeprecationsProvider } from './deprecations'; jest.mock('./object_types'); jest.mock('./deprecations'); +const createType = (parts: Partial): SavedObjectsType => ({ + name: 'test-type', + hidden: false, + namespaceType: 'single', + mappings: { properties: {} }, + ...parts, +}); + describe('SavedObjectsService', () => { let deprecationsSetup: ReturnType; @@ -630,5 +639,85 @@ describe('SavedObjectsService', () => { expect(includedHiddenTypes).toEqual(['someHiddenType']); }); }); + + describe('index retrieval APIs', () => { + let soService: SavedObjectsService; + + beforeEach(async () => { + const coreContext = createCoreContext({ skipMigration: false }); + soService = new SavedObjectsService(coreContext); + + typeRegistryInstanceMock.getType.mockImplementation((type: string) => { + if (type === 'dashboard') { + return createType({ + name: 'dashboard', + }); + } else if (type === 'foo') { + return createType({ + name: 'foo', + indexPattern: '.kibana_foo', + }); + } else if (type === 'bar') { + return createType({ + name: 'bar', + indexPattern: '.kibana_bar', + }); + } else if (type === 'bar_too') { + return createType({ + name: 'bar_too', + indexPattern: '.kibana_bar', + }); + } else { + return undefined; + } + }); + + await soService.setup(createSetupDeps()); + }); + + describe('#getDefaultIndex', () => { + it('return the default index', async () => { + const { getDefaultIndex } = await soService.start(createStartDeps()); + expect(getDefaultIndex()).toEqual(MAIN_SAVED_OBJECT_INDEX); + }); + }); + + describe('#getIndexForType', () => { + it('return the correct index for type specifying its indexPattern', async () => { + const { getIndexForType } = await soService.start(createStartDeps()); + expect(getIndexForType('bar')).toEqual('.kibana_bar'); + }); + it('return the correct index for type not specifying its indexPattern', async () => { + const { getIndexForType } = await soService.start(createStartDeps()); + expect(getIndexForType('dashboard')).toEqual(MAIN_SAVED_OBJECT_INDEX); + }); + it('return the default index for unknown type', async () => { + const { getIndexForType } = await soService.start(createStartDeps()); + expect(getIndexForType('unknown_type')).toEqual(MAIN_SAVED_OBJECT_INDEX); + }); + }); + + describe('#getIndicesForTypes', () => { + it('return the correct indices for specified types', async () => { + const { getIndicesForTypes } = await soService.start(createStartDeps()); + expect(getIndicesForTypes(['dashboard', 'foo', 'bar'])).toEqual([ + MAIN_SAVED_OBJECT_INDEX, + '.kibana_foo', + '.kibana_bar', + ]); + }); + it('ignore duplicate indices', async () => { + const { getIndicesForTypes } = await soService.start(createStartDeps()); + expect(getIndicesForTypes(['bar', 'bar_too'])).toEqual(['.kibana_bar']); + }); + it('return the default index for unknown type', async () => { + const { getIndicesForTypes } = await soService.start(createStartDeps()); + expect(getIndicesForTypes(['unknown', 'foo'])).toEqual([ + MAIN_SAVED_OBJECT_INDEX, + '.kibana_foo', + ]); + }); + }); + }); }); }); diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts index 1c04c109df83a..1172118b72e64 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts @@ -52,7 +52,7 @@ import { import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { DeprecationRegistryProvider } from '@kbn/core-deprecations-server'; import type { NodeInfo } from '@kbn/core-node-server'; -import { MAIN_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server'; +import { MAIN_SAVED_OBJECT_INDEX, SavedObjectsIndexPatterns } from '@kbn/core-saved-objects-server'; import { registerRoutes } from './routes'; import { calculateStatus$ } from './status'; import { registerCoreObjectTypes } from './object_types'; @@ -197,7 +197,8 @@ export class SavedObjectsService this.typeRegistry.registerType(type); }, getTypeRegistry: () => this.typeRegistry, - getKibanaIndex: () => MAIN_SAVED_OBJECT_INDEX, + getDefaultIndex: () => MAIN_SAVED_OBJECT_INDEX, + getAllIndices: () => [...SavedObjectsIndexPatterns], }; } @@ -340,6 +341,21 @@ export class SavedObjectsService importSizeLimit: options?.importSizeLimit ?? this.config!.maxImportExportSize, }), getTypeRegistry: () => this.typeRegistry, + getDefaultIndex: () => MAIN_SAVED_OBJECT_INDEX, + getIndexForType: (type: string) => { + const definition = this.typeRegistry.getType(type); + return definition?.indexPattern ?? MAIN_SAVED_OBJECT_INDEX; + }, + getIndicesForTypes: (types: string[]) => { + const indices = new Set(); + types.forEach((type) => { + const definition = this.typeRegistry.getType(type); + const index = definition?.indexPattern ?? MAIN_SAVED_OBJECT_INDEX; + indices.add(index); + }); + return [...indices]; + }, + getAllIndices: () => [...SavedObjectsIndexPatterns], }; } diff --git a/packages/core/saved-objects/core-saved-objects-server-mocks/src/saved_objects_service.mock.ts b/packages/core/saved-objects/core-saved-objects-server-mocks/src/saved_objects_service.mock.ts index 5bccf3b55055c..2d7d5ff847330 100644 --- a/packages/core/saved-objects/core-saved-objects-server-mocks/src/saved_objects_service.mock.ts +++ b/packages/core/saved-objects/core-saved-objects-server-mocks/src/saved_objects_service.mock.ts @@ -42,6 +42,10 @@ const createStartContractMock = (typeRegistry?: jest.Mocked { setSecurityExtension: jest.fn(), setSpacesExtension: jest.fn(), registerType: jest.fn(), - getKibanaIndex: jest.fn(), + getDefaultIndex: jest.fn(), + getAllIndices: jest.fn(), }; - setupContract.getKibanaIndex.mockReturnValue(MAIN_SAVED_OBJECT_INDEX); + setupContract.getDefaultIndex.mockReturnValue(MAIN_SAVED_OBJECT_INDEX); + setupContract.getAllIndices.mockReturnValue([MAIN_SAVED_OBJECT_INDEX]); return setupContract; }; diff --git a/packages/core/saved-objects/core-saved-objects-server/src/contracts.ts b/packages/core/saved-objects/core-saved-objects-server/src/contracts.ts index 3ee6e9c262c54..e08da10172f3c 100644 --- a/packages/core/saved-objects/core-saved-objects-server/src/contracts.ts +++ b/packages/core/saved-objects/core-saved-objects-server/src/contracts.ts @@ -136,7 +136,14 @@ export interface SavedObjectsServiceSetup { /** * Returns the default index used for saved objects. */ - getKibanaIndex: () => string; + getDefaultIndex: () => string; + + /** + * Returns all (aliases to) kibana system indices used for saved object storage. + * + * @deprecated use the `start` contract counterpart. + */ + getAllIndices: () => string[]; } /** @@ -209,4 +216,25 @@ export interface SavedObjectsServiceStart { * {@link SavedObjectsType | saved object types} */ getTypeRegistry: () => ISavedObjectTypeRegistry; + /** + * Returns the (alias to the) index that the specified saved object type is stored in. + * + * @param type The SO type to retrieve the index/alias for. + */ + getIndexForType: (type: string) => string; + /** + * Returns the (alias to the) index that the specified saved object type is stored in. + * + * @remark if multiple types are living in the same index, duplicates will be removed. + * @param types The SO types to retrieve the index/alias for. + */ + getIndicesForTypes: (types: string[]) => string[]; + /** + * Returns the default index used for saved objects. + */ + getDefaultIndex: () => string; + /** + * Returns all (aliases to) kibana system indices used for saved object storage. + */ + getAllIndices: () => string[]; } diff --git a/src/plugins/dashboard/server/usage/dashboard_telemetry_collection_task.ts b/src/plugins/dashboard/server/usage/dashboard_telemetry_collection_task.ts index 1ca13b4308586..bac38fdbb5c75 100644 --- a/src/plugins/dashboard/server/usage/dashboard_telemetry_collection_task.ts +++ b/src/plugins/dashboard/server/usage/dashboard_telemetry_collection_task.ts @@ -114,12 +114,14 @@ export function dashboardTaskRunner(logger: Logger, core: CoreSetup, embeddable: return dashboardData; }; - const kibanaIndex = core.savedObjects.getKibanaIndex(); + const dashboardIndex = await core + .getStartServices() + .then(([coreStart]) => coreStart.savedObjects.getIndexForType('dashboard')); const pageSize = 50; const searchParams = { size: pageSize, - index: kibanaIndex, + index: dashboardIndex, ignore_unavailable: true, filter_path: ['hits.hits', '_scroll_id'], body: { query: { bool: { filter: { term: { type: 'dashboard' } } } } }, diff --git a/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts b/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts index 6302af57166c4..35a285f2f5f30 100644 --- a/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts +++ b/src/plugins/data/server/kql_telemetry/kql_telemetry_service.ts @@ -28,7 +28,9 @@ export class KqlTelemetryService implements Plugin { if (usageCollection) { try { - makeKQLUsageCollector(usageCollection, savedObjects.getKibanaIndex()); + const getIndexForType = (type: string) => + getStartServices().then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); + makeKQLUsageCollector(usageCollection, getIndexForType); } catch (e) { this.initializerContext.logger .get('kql-telemetry') diff --git a/src/plugins/data/server/kql_telemetry/usage_collector/fetch.test.ts b/src/plugins/data/server/kql_telemetry/usage_collector/fetch.test.ts index 679b2e67158eb..91158343885ab 100644 --- a/src/plugins/data/server/kql_telemetry/usage_collector/fetch.test.ts +++ b/src/plugins/data/server/kql_telemetry/usage_collector/fetch.test.ts @@ -75,7 +75,7 @@ function setupMockCallCluster( describe('makeKQLUsageCollector', () => { describe('fetch method', () => { beforeEach(() => { - fetch = fetchProvider('.kibana'); + fetch = fetchProvider(() => Promise.resolve('.kibana')); }); it('should return opt in data from the .kibana/kql-telemetry doc', async () => { diff --git a/src/plugins/data/server/kql_telemetry/usage_collector/fetch.ts b/src/plugins/data/server/kql_telemetry/usage_collector/fetch.ts index 3f0d2129c6b92..90499f1e920bc 100644 --- a/src/plugins/data/server/kql_telemetry/usage_collector/fetch.ts +++ b/src/plugins/data/server/kql_telemetry/usage_collector/fetch.ts @@ -18,19 +18,19 @@ export interface Usage { defaultQueryLanguage: string; } -export function fetchProvider(index: string) { +export function fetchProvider(getIndexForType: (type: string) => Promise) { return async ({ esClient }: CollectorFetchContext): Promise => { const [response, config] = await Promise.all([ esClient.get( { - index, + index: await getIndexForType('kql-telemetry'), id: 'kql-telemetry:kql-telemetry', }, { ignore: [404] } ), esClient.search( { - index, + index: await getIndexForType('config'), body: { query: { term: { type: 'config' } } }, }, { ignore: [404] } diff --git a/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.test.ts b/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.test.ts index 129bf59ca80a9..a96346714c0f9 100644 --- a/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.test.ts +++ b/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.test.ts @@ -12,6 +12,8 @@ import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server'; describe('makeKQLUsageCollector', () => { let usageCollectionMock: jest.Mocked; + const getIndexForType = () => Promise.resolve('.kibana'); + beforeEach(() => { usageCollectionMock = { makeUsageCollector: jest.fn(), @@ -20,12 +22,12 @@ describe('makeKQLUsageCollector', () => { }); it('should call registerCollector', () => { - makeKQLUsageCollector(usageCollectionMock as UsageCollectionSetup, '.kibana'); + makeKQLUsageCollector(usageCollectionMock as UsageCollectionSetup, getIndexForType); expect(usageCollectionMock.registerCollector).toHaveBeenCalledTimes(1); }); it('should call makeUsageCollector with type = kql', () => { - makeKQLUsageCollector(usageCollectionMock as UsageCollectionSetup, '.kibana'); + makeKQLUsageCollector(usageCollectionMock as UsageCollectionSetup, getIndexForType); expect(usageCollectionMock.makeUsageCollector).toHaveBeenCalledTimes(1); expect(usageCollectionMock.makeUsageCollector.mock.calls[0][0].type).toBe('kql'); }); diff --git a/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.ts b/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.ts index 885c6b1807e92..6a9190a953fdd 100644 --- a/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.ts +++ b/src/plugins/data/server/kql_telemetry/usage_collector/make_kql_usage_collector.ts @@ -9,10 +9,13 @@ import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server'; import { fetchProvider, Usage } from './fetch'; -export function makeKQLUsageCollector(usageCollection: UsageCollectionSetup, kibanaIndex: string) { +export function makeKQLUsageCollector( + usageCollection: UsageCollectionSetup, + getIndexForType: (type: string) => Promise +) { const kqlUsageCollector = usageCollection.makeUsageCollector({ type: 'kql', - fetch: fetchProvider(kibanaIndex), + fetch: fetchProvider(getIndexForType), isReady: () => true, schema: { optInCount: { type: 'long' }, diff --git a/src/plugins/data/server/search/collectors/search/fetch.ts b/src/plugins/data/server/search/collectors/search/fetch.ts index 08f365d0a6073..5fcecd1e60a65 100644 --- a/src/plugins/data/server/search/collectors/search/fetch.ts +++ b/src/plugins/data/server/search/collectors/search/fetch.ts @@ -13,11 +13,12 @@ interface SearchTelemetry { 'search-telemetry': CollectedUsage; } -export function fetchProvider(kibanaIndex: string) { +export function fetchProvider(getIndexForType: (type: string) => Promise) { return async ({ esClient }: CollectorFetchContext): Promise => { + const searchIndex = await getIndexForType('search-telemetry'); const esResponse = await esClient.search( { - index: kibanaIndex, + index: searchIndex, body: { query: { term: { type: { value: 'search-telemetry' } } }, }, diff --git a/src/plugins/data/server/search/collectors/search/register.ts b/src/plugins/data/server/search/collectors/search/register.ts index 927c5274e8128..f335e8c5de7c5 100644 --- a/src/plugins/data/server/search/collectors/search/register.ts +++ b/src/plugins/data/server/search/collectors/search/register.ts @@ -21,12 +21,15 @@ export interface ReportedUsage { averageDuration: number | null; } -export function registerUsageCollector(usageCollection: UsageCollectionSetup, kibanaIndex: string) { +export function registerUsageCollector( + usageCollection: UsageCollectionSetup, + getIndexForType: (type: string) => Promise +) { try { const collector = usageCollection.makeUsageCollector({ type: 'search', isReady: () => true, - fetch: fetchProvider(kibanaIndex), + fetch: fetchProvider(getIndexForType), schema: { successCount: { type: 'long' }, errorCount: { type: 'long' }, diff --git a/src/plugins/data/server/search/collectors/search_session/fetch.test.ts b/src/plugins/data/server/search/collectors/search_session/fetch.test.ts index 1290b06b94ee0..e0fc723de44d1 100644 --- a/src/plugins/data/server/search/collectors/search_session/fetch.test.ts +++ b/src/plugins/data/server/search/collectors/search_session/fetch.test.ts @@ -17,12 +17,13 @@ describe('fetchProvider', () => { beforeEach(async () => { const kibanaIndex = '123'; + const getIndexForType = () => Promise.resolve(kibanaIndex); mockLogger = { warn: jest.fn(), debug: jest.fn(), } as any; esClient = elasticsearchServiceMock.createElasticsearchClient(); - fetchFn = fetchProvider(kibanaIndex, mockLogger); + fetchFn = fetchProvider(getIndexForType, mockLogger); }); test('returns when ES returns no results', async () => { diff --git a/src/plugins/data/server/search/collectors/search_session/fetch.ts b/src/plugins/data/server/search/collectors/search_session/fetch.ts index 536ca4b168188..08660f4adb136 100644 --- a/src/plugins/data/server/search/collectors/search_session/fetch.ts +++ b/src/plugins/data/server/search/collectors/search_session/fetch.ts @@ -17,11 +17,12 @@ interface SessionPersistedTermsBucket { doc_count: number; } -export function fetchProvider(kibanaIndex: string, logger: Logger) { +export function fetchProvider(getIndexForType: (type: string) => Promise, logger: Logger) { return async ({ esClient }: CollectorFetchContext): Promise => { try { + const searchSessionIndex = await getIndexForType(SEARCH_SESSION_TYPE); const esResponse = await esClient.search({ - index: kibanaIndex, + index: searchSessionIndex, body: { size: 0, aggs: { diff --git a/src/plugins/data/server/search/collectors/search_session/register.ts b/src/plugins/data/server/search/collectors/search_session/register.ts index c6ea85a2b53d3..b30b1fb888797 100644 --- a/src/plugins/data/server/search/collectors/search_session/register.ts +++ b/src/plugins/data/server/search/collectors/search_session/register.ts @@ -18,14 +18,14 @@ export interface ReportedUsage { export function registerUsageCollector( usageCollection: UsageCollectionSetup, - kibanaIndex: string, + getIndexForType: (type: string) => Promise, logger: Logger ) { try { const collector = usageCollection.makeUsageCollector({ type: 'search-session', isReady: () => true, - fetch: fetchProvider(kibanaIndex, logger), + fetch: fetchProvider(getIndexForType, logger), schema: { transientCount: { type: 'long' }, persistedCount: { type: 'long' }, diff --git a/src/plugins/data/server/search/search_service.ts b/src/plugins/data/server/search/search_service.ts index eba7ea22acf4f..8189177c4b58b 100644 --- a/src/plugins/data/server/search/search_service.ts +++ b/src/plugins/data/server/search/search_service.ts @@ -213,12 +213,10 @@ export class SearchService implements Plugin { core.savedObjects.registerType(searchTelemetry); if (usageCollection) { - registerSearchUsageCollector(usageCollection, core.savedObjects.getKibanaIndex()); - registerSearchSessionUsageCollector( - usageCollection, - core.savedObjects.getKibanaIndex(), - this.logger - ); + const getIndexForType = (type: string) => + core.getStartServices().then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); + registerSearchUsageCollector(usageCollection, getIndexForType); + registerSearchSessionUsageCollector(usageCollection, getIndexForType, this.logger); } expressions.registerFunction(getEsaggs({ getStartServices: core.getStartServices })); diff --git a/src/plugins/home/server/services/sample_data/sample_data_registry.ts b/src/plugins/home/server/services/sample_data/sample_data_registry.ts index a5cf89f65cb21..47ddc122f82cb 100644 --- a/src/plugins/home/server/services/sample_data/sample_data_registry.ts +++ b/src/plugins/home/server/services/sample_data/sample_data_registry.ts @@ -31,6 +31,7 @@ import { registerSampleDatasetWithIntegration } from './lib/register_with_integr export class SampleDataRegistry { constructor(private readonly initContext: PluginInitializerContext) {} + private readonly sampleDatasets: SampleDatasetSchema[] = []; private readonly appLinksMap = new Map(); @@ -68,8 +69,9 @@ export class SampleDataRegistry { isDevMode?: boolean ) { if (usageCollections) { - const kibanaIndex = core.savedObjects.getKibanaIndex(); - makeSampleDataUsageCollector(usageCollections, kibanaIndex); + const getIndexForType = (type: string) => + core.getStartServices().then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); + makeSampleDataUsageCollector(usageCollections, getIndexForType); } const usageTracker = usage( core.getStartServices().then(([coreStart]) => coreStart.savedObjects), @@ -176,6 +178,7 @@ export class SampleDataRegistry { return {}; } } + /** @public */ export type SampleDataRegistrySetup = ReturnType; diff --git a/src/plugins/home/server/services/sample_data/usage/collector.ts b/src/plugins/home/server/services/sample_data/usage/collector.ts index 5f32d4c79369c..716e630b55215 100644 --- a/src/plugins/home/server/services/sample_data/usage/collector.ts +++ b/src/plugins/home/server/services/sample_data/usage/collector.ts @@ -11,11 +11,11 @@ import { fetchProvider, TelemetryResponse } from './collector_fetch'; export function makeSampleDataUsageCollector( usageCollection: UsageCollectionSetup, - kibanaIndex: string + getIndexForType: (type: string) => Promise ) { const collector = usageCollection.makeUsageCollector({ type: 'sample-data', - fetch: fetchProvider(kibanaIndex), + fetch: fetchProvider(getIndexForType), isReady: () => true, schema: { installed: { type: 'array', items: { type: 'keyword' } }, diff --git a/src/plugins/home/server/services/sample_data/usage/collector_fetch.test.ts b/src/plugins/home/server/services/sample_data/usage/collector_fetch.test.ts index 54df964e4bdec..fcf49eb7f744d 100644 --- a/src/plugins/home/server/services/sample_data/usage/collector_fetch.test.ts +++ b/src/plugins/home/server/services/sample_data/usage/collector_fetch.test.ts @@ -19,8 +19,10 @@ const getMockFetchClients = (hits?: unknown[]) => { describe('Sample Data Fetch', () => { let collectorFetchContext: CollectorFetchContext; + const getIndexForType = (index: string) => (type: string) => Promise.resolve(index); + test('uninitialized .kibana', async () => { - const fetch = fetchProvider('index'); + const fetch = fetchProvider(getIndexForType('index')); collectorFetchContext = getMockFetchClients(); const telemetry = await fetch(collectorFetchContext); @@ -28,7 +30,7 @@ describe('Sample Data Fetch', () => { }); test('installed data set', async () => { - const fetch = fetchProvider('index'); + const fetch = fetchProvider(getIndexForType('index')); collectorFetchContext = getMockFetchClients([ { _id: 'sample-data-telemetry:test1', @@ -55,7 +57,7 @@ Object { }); test('multiple installed data sets', async () => { - const fetch = fetchProvider('index'); + const fetch = fetchProvider(getIndexForType('index')); collectorFetchContext = getMockFetchClients([ { _id: 'sample-data-telemetry:test1', @@ -90,7 +92,7 @@ Object { }); test('installed data set, missing counts', async () => { - const fetch = fetchProvider('index'); + const fetch = fetchProvider(getIndexForType('index')); collectorFetchContext = getMockFetchClients([ { _id: 'sample-data-telemetry:test1', @@ -112,7 +114,7 @@ Object { }); test('installed and uninstalled data sets', async () => { - const fetch = fetchProvider('index'); + const fetch = fetchProvider(getIndexForType('index')); collectorFetchContext = getMockFetchClients([ { _id: 'sample-data-telemetry:test0', diff --git a/src/plugins/home/server/services/sample_data/usage/collector_fetch.ts b/src/plugins/home/server/services/sample_data/usage/collector_fetch.ts index a5673fdc12a2f..28e753cb46b60 100644 --- a/src/plugins/home/server/services/sample_data/usage/collector_fetch.ts +++ b/src/plugins/home/server/services/sample_data/usage/collector_fetch.ts @@ -33,8 +33,9 @@ export interface TelemetryResponse { type ESResponse = SearchResponse; -export function fetchProvider(index: string) { +export function fetchProvider(getIndexForType: (type: string) => Promise) { return async ({ esClient }: CollectorFetchContext) => { + const index = await getIndexForType('sample-data-telemetry'); const response = await esClient.search( { index, diff --git a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.test.ts b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.test.ts index cdf2ca35d6ecc..7d6e600ded94b 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.test.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.test.ts @@ -27,8 +27,9 @@ describe('kibana_usage', () => { }); const kibanaIndex = '.kibana-tests'; + const getIndicesForTypes = () => Promise.resolve([kibanaIndex]); - beforeAll(() => registerKibanaUsageCollector(usageCollectionMock, kibanaIndex)); + beforeAll(() => registerKibanaUsageCollector(usageCollectionMock, getIndicesForTypes)); afterAll(() => jest.clearAllTimers()); afterEach(() => getSavedObjectsCountsMock.mockReset()); diff --git a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.ts b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.ts index 9a128888f05d5..c51cd374ee736 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/kibana_usage_collector.ts @@ -43,7 +43,7 @@ export async function getKibanaSavedObjectCounts( export function registerKibanaUsageCollector( usageCollection: UsageCollectionSetup, - kibanaIndex: string + getIndexForTypes: (types: string[]) => Promise ) { usageCollection.registerCollector( usageCollection.makeUsageCollector({ @@ -80,8 +80,9 @@ export function registerKibanaUsageCollector( }, }, async fetch({ soClient }) { + const indices = await getIndexForTypes(['dashboard', 'visualization', 'search']); return { - index: kibanaIndex, + index: indices[0], ...(await getKibanaSavedObjectCounts(soClient)), }; }, diff --git a/src/plugins/kibana_usage_collection/server/plugin.ts b/src/plugins/kibana_usage_collection/server/plugin.ts index 8787d085c692e..497829a3ef4c7 100644 --- a/src/plugins/kibana_usage_collection/server/plugin.ts +++ b/src/plugins/kibana_usage_collection/server/plugin.ts @@ -123,7 +123,6 @@ export class KibanaUsageCollectionPlugin implements Plugin { pluginStop$: Subject, registerType: SavedObjectsRegisterType ) { - const kibanaIndex = coreSetup.savedObjects.getKibanaIndex(); const getSavedObjectsClient = () => this.savedObjectsClient; const getUiSettingsClient = () => this.uiSettingsClient; const getCoreUsageDataService = () => this.coreUsageData!; @@ -138,7 +137,12 @@ export class KibanaUsageCollectionPlugin implements Plugin { registerUsageCountersUsageCollector(usageCollection); registerOpsStatsCollector(usageCollection, metric$); - registerKibanaUsageCollector(usageCollection, kibanaIndex); + + const getIndexForTypes = (types: string[]) => + coreSetup + .getStartServices() + .then(([coreStart]) => coreStart.savedObjects.getIndicesForTypes(types)); + registerKibanaUsageCollector(usageCollection, getIndexForTypes); const coreStartPromise = coreSetup.getStartServices().then(([coreStart]) => coreStart); const getAllSavedObjectTypes = async () => { diff --git a/src/plugins/usage_collection/server/plugin.ts b/src/plugins/usage_collection/server/plugin.ts index c8c44679cfa23..7139de5091b50 100644 --- a/src/plugins/usage_collection/server/plugin.ts +++ b/src/plugins/usage_collection/server/plugin.ts @@ -98,7 +98,7 @@ export class UsageCollectionPlugin implements Plugin { public setup(core: CoreSetup): UsageCollectionSetup { const config = this.initializerContext.config.get(); - const kibanaIndex = core.savedObjects.getKibanaIndex(); + const kibanaIndex = core.savedObjects.getDefaultIndex(); const collectorSet = new CollectorSet({ logger: this.logger.get('usage-collection', 'collector-set'), diff --git a/x-pack/plugins/actions/server/actions_client.test.ts b/x-pack/plugins/actions/server/actions_client.test.ts index 3c4b1a876c522..c24379894c47b 100644 --- a/x-pack/plugins/actions/server/actions_client.test.ts +++ b/x-pack/plugins/actions/server/actions_client.test.ts @@ -92,7 +92,7 @@ jest.mock('uuid', () => ({ v4: () => 'uuidv4', })); -const defaultKibanaIndex = '.kibana'; +const kibanaIndices = ['.kibana']; const unsecuredSavedObjectsClient = savedObjectsClientMock.create(); const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient(); const actionExecutor = actionExecutorMock.create(); @@ -141,7 +141,7 @@ beforeEach(() => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, preconfiguredActions: [], actionExecutor, executionEnqueuer, @@ -601,7 +601,7 @@ describe('create()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, preconfiguredActions: [], actionExecutor, executionEnqueuer, @@ -719,7 +719,7 @@ describe('get()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -780,7 +780,7 @@ describe('get()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -903,7 +903,7 @@ describe('get()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -979,7 +979,7 @@ describe('getAll()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -1122,7 +1122,7 @@ describe('getAll()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -1205,7 +1205,7 @@ describe('getBulk()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -1342,7 +1342,7 @@ describe('getBulk()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -1402,7 +1402,7 @@ describe('getOAuthAccessToken()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -2623,7 +2623,7 @@ describe('isPreconfigured()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, @@ -2662,7 +2662,7 @@ describe('isPreconfigured()', () => { actionTypeRegistry, unsecuredSavedObjectsClient, scopedClusterClient, - defaultKibanaIndex, + kibanaIndices, actionExecutor, executionEnqueuer, ephemeralExecutionEnqueuer, diff --git a/x-pack/plugins/actions/server/actions_client.ts b/x-pack/plugins/actions/server/actions_client.ts index 867fc4f9c7e47..5dd65dfc7c7e1 100644 --- a/x-pack/plugins/actions/server/actions_client.ts +++ b/x-pack/plugins/actions/server/actions_client.ts @@ -110,7 +110,7 @@ export interface CreateOptions { interface ConstructorOptions { logger: Logger; - defaultKibanaIndex: string; + kibanaIndices: string[]; scopedClusterClient: IScopedClusterClient; actionTypeRegistry: ActionTypeRegistry; unsecuredSavedObjectsClient: SavedObjectsClientContract; @@ -134,7 +134,7 @@ export interface UpdateOptions { export class ActionsClient { private readonly logger: Logger; - private readonly defaultKibanaIndex: string; + private readonly kibanaIndices: string[]; private readonly scopedClusterClient: IScopedClusterClient; private readonly unsecuredSavedObjectsClient: SavedObjectsClientContract; private readonly actionTypeRegistry: ActionTypeRegistry; @@ -153,7 +153,7 @@ export class ActionsClient { constructor({ logger, actionTypeRegistry, - defaultKibanaIndex, + kibanaIndices, scopedClusterClient, unsecuredSavedObjectsClient, preconfiguredActions, @@ -172,7 +172,7 @@ export class ActionsClient { this.actionTypeRegistry = actionTypeRegistry; this.unsecuredSavedObjectsClient = unsecuredSavedObjectsClient; this.scopedClusterClient = scopedClusterClient; - this.defaultKibanaIndex = defaultKibanaIndex; + this.kibanaIndices = kibanaIndices; this.preconfiguredActions = preconfiguredActions; this.actionExecutor = actionExecutor; this.executionEnqueuer = executionEnqueuer; @@ -449,11 +449,7 @@ export class ActionsClient { isDeprecated: isConnectorDeprecated(preconfiguredAction), })), ].sort((a, b) => a.name.localeCompare(b.name)); - return await injectExtraFindData( - this.defaultKibanaIndex, - this.scopedClusterClient, - mergedResult - ); + return await injectExtraFindData(this.kibanaIndices, this.scopedClusterClient, mergedResult); } /** @@ -888,7 +884,7 @@ function actionFromSavedObject( } async function injectExtraFindData( - defaultKibanaIndex: string, + kibanaIndices: string[], scopedClusterClient: IScopedClusterClient, actionResults: ActionResult[] ): Promise { @@ -927,7 +923,7 @@ async function injectExtraFindData( }; } const aggregationResult = await scopedClusterClient.asInternalUser.search({ - index: defaultKibanaIndex, + index: kibanaIndices, body: { aggs, size: 0, diff --git a/x-pack/plugins/actions/server/plugin.ts b/x-pack/plugins/actions/server/plugin.ts index 63bea300af7f7..128c3efe50295 100644 --- a/x-pack/plugins/actions/server/plugin.ts +++ b/x-pack/plugins/actions/server/plugin.ts @@ -116,13 +116,16 @@ export interface PluginSetupContract { >( actionType: ActionType ): void; + registerSubActionConnectorType< Config extends ActionTypeConfig = ActionTypeConfig, Secrets extends ActionTypeSecrets = ActionTypeSecrets >( connector: SubActionConnectorType ): void; + isPreconfiguredConnector(connectorId: string): boolean; + getSubActionConnectorClass: () => IServiceAbstract; getCaseConnectorClass: () => IServiceAbstract; getActionsHealth: () => { hasPermanentEncryptionKey: boolean }; @@ -197,7 +200,6 @@ export class ActionsPlugin implements Plugin, plugins: ActionsPluginsSetup ): PluginSetupContract { - this.kibanaIndex = core.savedObjects.getKibanaIndex(); - this.licenseState = new LicenseState(plugins.licensing.license$); this.isESOCanEncrypt = plugins.encryptedSavedObjects.canEncrypt; @@ -295,17 +295,15 @@ export class ActionsPlugin implements Plugin( 'actions', - this.createRouteHandlerContext(core, this.kibanaIndex) + this.createRouteHandlerContext(core) ); if (usageCollection) { const eventLogIndex = this.eventLogService.getIndexPattern(); - const kibanaIndex = this.kibanaIndex; initializeActionsTelemetry( this.telemetryLogger, plugins.taskManager, core, - kibanaIndex, this.preconfiguredActions, eventLogIndex ); @@ -381,7 +379,6 @@ export class ActionsPlugin implements Plugin, - defaultKibanaIndex: string + core: CoreSetup ): IContextProvider => { const { actionTypeRegistry, @@ -622,7 +618,7 @@ export class ActionsPlugin implements Plugin client.asInternalUser ); + const getActionIndex = () => + core + .getStartServices() + .then(([coreStart]) => coreStart.savedObjects.getIndexForType('action')); return { async run() { + const actionIndex = await getActionIndex(); const esClient = await getEsClient(); return Promise.all([ - getTotalCount(esClient, kibanaIndex, logger, preconfiguredActions), - getInUseTotalCount(esClient, kibanaIndex, logger, undefined, preconfiguredActions), + getTotalCount(esClient, actionIndex, logger, preconfiguredActions), + getInUseTotalCount(esClient, actionIndex, logger, undefined, preconfiguredActions), getExecutionsPerDayCount(esClient, eventLogIndex, logger), ]).then(([totalAggegations, totalInUse, totalExecutionsPerDay]) => { const hasErrors = diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index 2902848b6dea5..152b7f9096193 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -131,6 +131,7 @@ export interface PluginSetupContract { RecoveryActionGroupId > ): void; + getSecurityHealth: () => Promise; getConfig: () => AlertingRulesConfig; frameworkAlerts: PublicFrameworkAlertsService; @@ -219,7 +220,6 @@ export class AlertingPlugin { core: CoreSetup, plugins: AlertingPluginsSetup ): PluginSetupContract { - const kibanaIndex = core.savedObjects.getKibanaIndex(); this.kibanaBaseUrl = core.http.basePath.publicBaseUrl; this.licenseState = new LicenseState(plugins.licensing.license$); this.security = plugins.security; @@ -284,13 +284,7 @@ export class AlertingPlugin { core.getStartServices().then(([_, { taskManager }]) => taskManager) ); const eventLogIndex = this.eventLogService.getIndexPattern(); - initializeAlertingTelemetry( - this.telemetryLogger, - core, - plugins.taskManager, - kibanaIndex, - eventLogIndex - ); + initializeAlertingTelemetry(this.telemetryLogger, core, plugins.taskManager, eventLogIndex); } // Usage counter for telemetry diff --git a/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.test.ts b/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.test.ts index d16b76d91afa9..58a449d5f7004 100644 --- a/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.test.ts +++ b/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.test.ts @@ -157,7 +157,7 @@ describe('kibana index telemetry', () => { const telemetry = await getTotalCountAggregations({ esClient, - kibanaIndex: 'test', + alertIndex: 'test', logger, }); @@ -228,7 +228,7 @@ describe('kibana index telemetry', () => { const telemetry = await getTotalCountAggregations({ esClient, - kibanaIndex: 'test', + alertIndex: 'test', logger, }); @@ -333,7 +333,7 @@ describe('kibana index telemetry', () => { const telemetry = await getTotalCountInUse({ esClient, - kibanaIndex: 'test', + alertIndex: 'test', logger, }); @@ -357,7 +357,7 @@ describe('kibana index telemetry', () => { const telemetry = await getTotalCountInUse({ esClient, - kibanaIndex: 'test', + alertIndex: 'test', logger, }); diff --git a/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.ts b/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.ts index 0c6d01016c313..a1055aa075521 100644 --- a/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.ts +++ b/x-pack/plugins/alerting/server/usage/lib/get_telemetry_from_kibana.ts @@ -25,7 +25,7 @@ import { parseSimpleRuleTypeBucket } from './parse_simple_rule_type_bucket'; interface Opts { esClient: ElasticsearchClient; - kibanaIndex: string; + alertIndex: string; logger: Logger; } @@ -57,12 +57,12 @@ interface GetTotalCountInUseResults { export async function getTotalCountAggregations({ esClient, - kibanaIndex, + alertIndex, logger, }: Opts): Promise { try { const query = { - index: kibanaIndex, + index: alertIndex, size: 0, body: { query: { @@ -400,12 +400,12 @@ export async function getTotalCountAggregations({ export async function getTotalCountInUse({ esClient, - kibanaIndex, + alertIndex, logger, }: Opts): Promise { try { const query = { - index: kibanaIndex, + index: alertIndex, size: 0, body: { query: { diff --git a/x-pack/plugins/alerting/server/usage/task.ts b/x-pack/plugins/alerting/server/usage/task.ts index e17d17dc6f4f5..9c6a3607535ee 100644 --- a/x-pack/plugins/alerting/server/usage/task.ts +++ b/x-pack/plugins/alerting/server/usage/task.ts @@ -29,10 +29,9 @@ export function initializeAlertingTelemetry( logger: Logger, core: CoreSetup, taskManager: TaskManagerSetupContract, - kibanaIndex: string, eventLogIndex: string ) { - registerAlertingTelemetryTask(logger, core, taskManager, kibanaIndex, eventLogIndex); + registerAlertingTelemetryTask(logger, core, taskManager, eventLogIndex); } export function scheduleAlertingTelemetry(logger: Logger, taskManager?: TaskManagerStartContract) { @@ -45,20 +44,13 @@ function registerAlertingTelemetryTask( logger: Logger, core: CoreSetup, taskManager: TaskManagerSetupContract, - kibanaIndex: string, eventLogIndex: string ) { taskManager.registerTaskDefinitions({ [TELEMETRY_TASK_TYPE]: { title: 'Alerting usage fetch task', timeout: '5m', - createTaskRunner: telemetryTaskRunner( - logger, - core, - kibanaIndex, - eventLogIndex, - taskManager.index - ), + createTaskRunner: telemetryTaskRunner(logger, core, eventLogIndex, taskManager.index), }, }); } @@ -80,7 +72,6 @@ async function scheduleTasks(logger: Logger, taskManager: TaskManagerStartContra export function telemetryTaskRunner( logger: Logger, core: CoreSetup, - kibanaIndex: string, eventLogIndex: string, taskManagerIndex: string ) { @@ -94,13 +85,18 @@ export function telemetryTaskRunner( }, ]) => client.asInternalUser ); + const getAlertIndex = () => + core + .getStartServices() + .then(([coreStart]) => coreStart.savedObjects.getIndexForType('alert')); return { async run() { const esClient = await getEsClient(); + const alertIndex = await getAlertIndex(); return Promise.all([ - getTotalCountAggregations({ esClient, kibanaIndex, logger }), - getTotalCountInUse({ esClient, kibanaIndex, logger }), + getTotalCountAggregations({ esClient, alertIndex, logger }), + getTotalCountInUse({ esClient, alertIndex, logger }), getExecutionsPerDayCount({ esClient, eventLogIndex, logger }), getExecutionTimeoutsPerDayCount({ esClient, eventLogIndex, logger }), getFailedAndUnrecognizedTasksPerDay({ esClient, taskManagerIndex, logger }), diff --git a/x-pack/plugins/canvas/server/collectors/collector.ts b/x-pack/plugins/canvas/server/collectors/collector.ts index f98bd319a8ac0..31919bc663c1e 100644 --- a/x-pack/plugins/canvas/server/collectors/collector.ts +++ b/x-pack/plugins/canvas/server/collectors/collector.ts @@ -29,7 +29,7 @@ const collectors: TelemetryCollector[] = [workpadCollector, customElementCollect */ export function registerCanvasUsageCollector( usageCollection: UsageCollectionSetup | undefined, - kibanaIndex: string + getIndexForType: (type: string) => Promise ) { if (!usageCollection) { return; @@ -40,7 +40,7 @@ export function registerCanvasUsageCollector( isReady: () => true, fetch: async ({ esClient }: CollectorFetchContext) => { const collectorResults = await Promise.all( - collectors.map((collector) => collector(kibanaIndex, esClient)) + collectors.map((collector) => collector(getIndexForType, esClient)) ); return collectorResults.reduce((reduction, usage) => { diff --git a/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts b/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts index 66238abfe89df..51aa616f4e5a7 100644 --- a/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts +++ b/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts @@ -141,12 +141,13 @@ export function summarizeCustomElements( } const customElementCollector: TelemetryCollector = async function customElementCollector( - kibanaIndex, + getIndexForType, esClient ) { + const index = await getIndexForType(CUSTOM_ELEMENT_TYPE); const customElementParams = { size: 10000, - index: kibanaIndex, + index, ignore_unavailable: true, filter_path: [`hits.hits._source.${CUSTOM_ELEMENT_TYPE}.content`], body: { query: { bool: { filter: { term: { type: CUSTOM_ELEMENT_TYPE } } } } }, diff --git a/x-pack/plugins/canvas/server/collectors/workpad_collector.ts b/x-pack/plugins/canvas/server/collectors/workpad_collector.ts index 6ab5f62f8f5d2..252d05bfc4f7e 100644 --- a/x-pack/plugins/canvas/server/collectors/workpad_collector.ts +++ b/x-pack/plugins/canvas/server/collectors/workpad_collector.ts @@ -377,10 +377,11 @@ export function summarizeWorkpads(workpadDocs: CanvasWorkpad[]): WorkpadTelemetr }; } -const workpadCollector: TelemetryCollector = async function (kibanaIndex, esClient) { +const workpadCollector: TelemetryCollector = async function (getIndexForType, esClient) { + const index = await getIndexForType(CANVAS_TYPE); const searchParams = { size: 10000, // elasticsearch index.max_result_window default value - index: kibanaIndex, + index, ignore_unavailable: true, filter_path: ['hits.hits._source.canvas-workpad', '-hits.hits._source.canvas-workpad.assets'], body: { query: { bool: { filter: { term: { type: CANVAS_TYPE } } } } }, diff --git a/x-pack/plugins/canvas/server/plugin.ts b/x-pack/plugins/canvas/server/plugin.ts index ec5cb4969be19..8c9748cc47887 100644 --- a/x-pack/plugins/canvas/server/plugin.ts +++ b/x-pack/plugins/canvas/server/plugin.ts @@ -90,9 +90,11 @@ export class CanvasPlugin implements Plugin { plugins.home.sampleData.addAppLinksToSampleDataset ); - // we need the kibana index for the Canvas usage collector - const kibanaIndex = coreSetup.savedObjects.getKibanaIndex(); - registerCanvasUsageCollector(plugins.usageCollection, kibanaIndex); + const getIndexForType = (type: string) => + coreSetup + .getStartServices() + .then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); + registerCanvasUsageCollector(plugins.usageCollection, getIndexForType); } public start(coreStart: CoreStart) { diff --git a/x-pack/plugins/canvas/types/telemetry.ts b/x-pack/plugins/canvas/types/telemetry.ts index 2f9f6d48ecda7..24c8126d29de6 100644 --- a/x-pack/plugins/canvas/types/telemetry.ts +++ b/x-pack/plugins/canvas/types/telemetry.ts @@ -8,11 +8,10 @@ import type { ElasticsearchClient } from '@kbn/core/server'; /** - Function for collecting information about canvas usage + Function for collecting information about canvas usage */ export type TelemetryCollector = ( - /** The server instance */ - kibanaIndex: string, + getIndexForType: (type: string) => Promise, /** Function for calling elasticsearch */ esClient: ElasticsearchClient ) => Record; diff --git a/x-pack/plugins/event_log/server/plugin.ts b/x-pack/plugins/event_log/server/plugin.ts index 98ddd770ac962..d5bf14a1259c1 100644 --- a/x-pack/plugins/event_log/server/plugin.ts +++ b/x-pack/plugins/event_log/server/plugin.ts @@ -61,13 +61,11 @@ export class Plugin implements CorePlugin + coreSetup + .getStartServices() + .then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); + registerCollector(plugins.usageCollection, getIndexForType); } if (plugins.cases) { diff --git a/x-pack/plugins/ml/server/usage/collector.ts b/x-pack/plugins/ml/server/usage/collector.ts index be09ccae6367a..876e604fcf6f2 100644 --- a/x-pack/plugins/ml/server/usage/collector.ts +++ b/x-pack/plugins/ml/server/usage/collector.ts @@ -31,7 +31,10 @@ export interface MlUsageData { }; } -export function registerCollector(usageCollection: UsageCollectionSetup, kibanaIndex: string) { +export function registerCollector( + usageCollection: UsageCollectionSetup, + getIndexForType: (type: string) => Promise +) { const collector = usageCollection.makeUsageCollector({ type: 'ml', schema: { @@ -86,11 +89,12 @@ export function registerCollector(usageCollection: UsageCollectionSetup, kibanaI }, }, }, - isReady: () => !!kibanaIndex, + isReady: () => true, fetch: async ({ esClient }) => { + const alertIndex = await getIndexForType('alert'); const result = await esClient.search( { - index: kibanaIndex, + index: alertIndex, size: 0, body: { query: { @@ -137,7 +141,7 @@ export function registerCollector(usageCollection: UsageCollectionSetup, kibanaI }; }>( { - index: kibanaIndex, + index: alertIndex, size: 10000, body: { query: { diff --git a/x-pack/plugins/monitoring/server/plugin.ts b/x-pack/plugins/monitoring/server/plugin.ts index c81fb90e614cb..5996eb125b6dc 100644 --- a/x-pack/plugins/monitoring/server/plugin.ts +++ b/x-pack/plugins/monitoring/server/plugin.ts @@ -104,7 +104,7 @@ export class MonitoringPlugin kibanaStats: { uuid: this.initializerContext.env.instanceUuid, name: serverInfo.name, - index: coreSetup.savedObjects.getKibanaIndex(), + index: coreSetup.savedObjects.getDefaultIndex(), host: serverInfo.hostname, locale: i18n.getLocale(), port: serverInfo.port.toString(), diff --git a/x-pack/plugins/monitoring_collection/server/plugin.ts b/x-pack/plugins/monitoring_collection/server/plugin.ts index 1c30a8439cf3c..fdfe532ced5db 100644 --- a/x-pack/plugins/monitoring_collection/server/plugin.ts +++ b/x-pack/plugins/monitoring_collection/server/plugin.ts @@ -72,7 +72,7 @@ export class MonitoringCollectionPlugin implements Plugin { const mockIndex = 'mock_index'; + const getIndexForType = () => Promise.resolve(mockIndex); it('makes a usage collector and registers it`', () => { const mockCollectorSet = createUsageCollectionSetupMock(); - registerRollupUsageCollector(mockCollectorSet, mockIndex); + registerRollupUsageCollector(mockCollectorSet, getIndexForType); expect(mockCollectorSet.makeUsageCollector).toBeCalledTimes(1); expect(mockCollectorSet.registerCollector).toBeCalledTimes(1); }); it('makeUsageCollector configs fit the shape', () => { const mockCollectorSet = createUsageCollectionSetupMock(); - registerRollupUsageCollector(mockCollectorSet, mockIndex); + registerRollupUsageCollector(mockCollectorSet, getIndexForType); expect(mockCollectorSet.makeUsageCollector).toHaveBeenCalledWith({ type: 'rollups', isReady: expect.any(Function), @@ -81,7 +82,7 @@ describe('registerRollupUsageCollector', () => { it('makeUsageCollector config.isReady returns true', () => { const mockCollectorSet = createUsageCollectionSetupMock(); - registerRollupUsageCollector(mockCollectorSet, mockIndex); + registerRollupUsageCollector(mockCollectorSet, getIndexForType); const usageCollectorConfig = mockCollectorSet.makeUsageCollector.mock.calls[0][0]; expect(usageCollectorConfig.isReady()).toBe(true); }); diff --git a/x-pack/plugins/rollup/server/collectors/register.ts b/x-pack/plugins/rollup/server/collectors/register.ts index 6fe44ee0309f9..6c893e058f0e7 100644 --- a/x-pack/plugins/rollup/server/collectors/register.ts +++ b/x-pack/plugins/rollup/server/collectors/register.ts @@ -38,7 +38,7 @@ interface Usage { export function registerRollupUsageCollector( usageCollection: UsageCollectionSetup, - kibanaIndex: string + getIndexForType: (type: string) => Promise ): void { const collector = usageCollection.makeUsageCollector({ type: 'rollups', @@ -92,23 +92,26 @@ export function registerRollupUsageCollector( }, }, fetch: async ({ esClient }: CollectorFetchContext) => { - const rollupIndexPatterns = await fetchRollupIndexPatterns(kibanaIndex, esClient); + const indexPatternIndex = await getIndexForType('index-pattern'); + const rollupIndexPatterns = await fetchRollupIndexPatterns(indexPatternIndex, esClient); const rollupIndexPatternToFlagMap = createIdToFlagMap(rollupIndexPatterns); + const searchIndex = await getIndexForType('search'); const rollupSavedSearches = await fetchRollupSavedSearches( - kibanaIndex, + searchIndex, esClient, rollupIndexPatternToFlagMap ); const rollupSavedSearchesToFlagMap = createIdToFlagMap(rollupSavedSearches); + const visualizationIndex = await getIndexForType('visualization'); const { rollupVisualizations, rollupVisualizationsFromSavedSearches, rollupLensVisualizations, rollupLensVisualizationsFromSavedSearches, } = await fetchRollupVisualizations( - kibanaIndex, + visualizationIndex, esClient, rollupIndexPatternToFlagMap, rollupSavedSearchesToFlagMap diff --git a/x-pack/plugins/rollup/server/plugin.ts b/x-pack/plugins/rollup/server/plugin.ts index 91538ae9a375d..06416685ab508 100644 --- a/x-pack/plugins/rollup/server/plugin.ts +++ b/x-pack/plugins/rollup/server/plugin.ts @@ -92,7 +92,9 @@ export class RollupPlugin implements Plugin { if (usageCollection) { try { - registerRollupUsageCollector(usageCollection, savedObjects.getKibanaIndex()); + const getIndexForType = (type: string) => + getStartServices().then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); + registerRollupUsageCollector(usageCollection, getIndexForType); } catch (e) { this.logger.warn(`Registering Rollup collector failed: ${e}`); } diff --git a/x-pack/plugins/saved_objects_tagging/server/plugin.ts b/x-pack/plugins/saved_objects_tagging/server/plugin.ts index 59c40ab4f124b..0b3d8570d66e5 100644 --- a/x-pack/plugins/saved_objects_tagging/server/plugin.ts +++ b/x-pack/plugins/saved_objects_tagging/server/plugin.ts @@ -36,7 +36,7 @@ export class SavedObjectTaggingPlugin implements Plugin<{}, SavedObjectTaggingStart, SetupDeps, StartDeps> { public setup( - { savedObjects, http }: CoreSetup, + { savedObjects, http, getStartServices }: CoreSetup, { features, usageCollection, security }: SetupDeps ) { savedObjects.registerType(tagType); @@ -54,10 +54,12 @@ export class SavedObjectTaggingPlugin features.registerKibanaFeature(savedObjectsTaggingFeature); if (usageCollection) { + const getIndexForType = (type: string) => + getStartServices().then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); usageCollection.registerCollector( createTagUsageCollector({ usageCollection, - kibanaIndex: savedObjects.getKibanaIndex(), + getIndexForType, }) ); } diff --git a/x-pack/plugins/saved_objects_tagging/server/usage/tag_usage_collector.ts b/x-pack/plugins/saved_objects_tagging/server/usage/tag_usage_collector.ts index 6e4494f225fe7..2ddb9c50b395a 100644 --- a/x-pack/plugins/saved_objects_tagging/server/usage/tag_usage_collector.ts +++ b/x-pack/plugins/saved_objects_tagging/server/usage/tag_usage_collector.ts @@ -12,17 +12,18 @@ import { tagUsageCollectorSchema } from './schema'; export const createTagUsageCollector = ({ usageCollection, - kibanaIndex, + getIndexForType, }: { usageCollection: UsageCollectionSetup; - kibanaIndex: string; + getIndexForType: (type: string) => Promise; }) => { return usageCollection.makeUsageCollector({ type: 'saved_objects_tagging', isReady: () => true, schema: tagUsageCollectorSchema, - fetch: ({ esClient }) => { - return fetchTagUsageData({ esClient, kibanaIndex }); + fetch: async ({ esClient }) => { + const index = await getIndexForType('tag'); + return fetchTagUsageData({ esClient, kibanaIndex: index }); }, }); }; diff --git a/x-pack/plugins/security/server/plugin.ts b/x-pack/plugins/security/server/plugin.ts index 7e29008ae754b..137d54308dc31 100644 --- a/x-pack/plugins/security/server/plugin.ts +++ b/x-pack/plugins/security/server/plugin.ts @@ -229,7 +229,7 @@ export class SecurityPlugin core: CoreSetup, { features, licensing, taskManager, usageCollection, spaces }: PluginSetupDependencies ) { - this.kibanaIndexName = core.savedObjects.getKibanaIndex(); + this.kibanaIndexName = core.savedObjects.getDefaultIndex(); const config$ = this.initializerContext.config.create>().pipe( map((rawConfig) => createConfig(rawConfig, this.initializerContext.logger.get('config'), { diff --git a/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts b/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts index 03614a4bfc0ac..9526ec07ea2a6 100644 --- a/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts +++ b/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts @@ -73,7 +73,7 @@ import { PREBUILT_RULES_PACKAGE_NAME } from '../../../common/detection_engine/co export interface ITelemetryReceiver { start( core?: CoreStart, - kibanaIndex?: string, + getIndexForType?: (type: string) => string, alertsIndex?: string, endpointContextService?: EndpointAppContextService, exceptionListClient?: ExceptionListClient, @@ -185,7 +185,7 @@ export class TelemetryReceiver implements ITelemetryReceiver { private esClient?: ElasticsearchClient; private exceptionListClient?: ExceptionListClient; private soClient?: SavedObjectsClientContract; - private kibanaIndex?: string; + private getIndexForType?: (type: string) => string; private alertsIndex?: string; private clusterInfo?: ESClusterInfo; private processTreeFetcher?: Fetcher; @@ -198,13 +198,13 @@ export class TelemetryReceiver implements ITelemetryReceiver { public async start( core?: CoreStart, - kibanaIndex?: string, + getIndexForType?: (type: string) => string, alertsIndex?: string, endpointContextService?: EndpointAppContextService, exceptionListClient?: ExceptionListClient, packageService?: PackageService ) { - this.kibanaIndex = kibanaIndex; + this.getIndexForType = getIndexForType; this.alertsIndex = alertsIndex; this.agentClient = endpointContextService?.getInternalFleetServices().agent; this.agentPolicyService = endpointContextService?.getInternalFleetServices().agentPolicy; @@ -493,7 +493,7 @@ export class TelemetryReceiver implements ITelemetryReceiver { const query: SearchRequest = { expand_wildcards: ['open' as const, 'hidden' as const], - index: `${this.kibanaIndex}*`, + index: this.getIndexForType?.('alert'), ignore_unavailable: true, body: { size: this.maxRecords, @@ -924,7 +924,7 @@ export class TelemetryReceiver implements ITelemetryReceiver { }; const exceptionListQuery: SearchRequest = { expand_wildcards: ['open' as const, 'hidden' as const], - index: `${this.kibanaIndex}*`, + index: this.getIndexForType?.('exception-list'), ignore_unavailable: true, body: { size: 0, // no query results required - only aggregation quantity @@ -944,7 +944,7 @@ export class TelemetryReceiver implements ITelemetryReceiver { }; const indicatorMatchRuleQuery: SearchRequest = { expand_wildcards: ['open' as const, 'hidden' as const], - index: `${this.kibanaIndex}*`, + index: this.getIndexForType?.('alert'), ignore_unavailable: true, body: { size: 0, diff --git a/x-pack/plugins/security_solution/server/plugin.ts b/x-pack/plugins/security_solution/server/plugin.ts index 2b6048c122f27..c5008e20d1a7b 100644 --- a/x-pack/plugins/security_solution/server/plugin.ts +++ b/x-pack/plugins/security_solution/server/plugin.ts @@ -128,7 +128,6 @@ export class Plugin implements ISecuritySolutionPlugin { private checkMetadataTransformsTask: CheckMetadataTransformsTask | undefined; private artifactsCache: LRU; private telemetryUsageCounter?: UsageCounter; - private kibanaIndex?: string; private endpointContext: EndpointAppContext; constructor(context: PluginInitializerContext) { @@ -159,7 +158,6 @@ export class Plugin implements ISecuritySolutionPlugin { const { appClientFactory, pluginContext, config, logger } = this; const experimentalFeatures = config.experimentalFeatures; - this.kibanaIndex = core.savedObjects.getKibanaIndex(); initSavedObjects(core.savedObjects); initUiSettings(core.uiSettings, experimentalFeatures); @@ -511,8 +509,7 @@ export class Plugin implements ISecuritySolutionPlugin { this.telemetryReceiver.start( core, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.kibanaIndex!, + (type: string) => core.savedObjects.getIndexForType(type), DEFAULT_ALERTS_INDEX, this.endpointAppContextService, exceptionListClient, diff --git a/x-pack/plugins/spaces/server/plugin.ts b/x-pack/plugins/spaces/server/plugin.ts index ad73be5e5c19b..19c79c244e6c1 100644 --- a/x-pack/plugins/spaces/server/plugin.ts +++ b/x-pack/plugins/spaces/server/plugin.ts @@ -173,8 +173,10 @@ export class SpacesPlugin setupCapabilities(core, getSpacesService, this.log); if (plugins.usageCollection) { + const getIndexForType = (type: string) => + core.getStartServices().then(([coreStart]) => coreStart.savedObjects.getIndexForType(type)); registerSpacesUsageCollector(plugins.usageCollection, { - kibanaIndex: core.savedObjects.getKibanaIndex(), + getIndexForType, features: plugins.features, licensing: plugins.licensing, usageStatsServicePromise, diff --git a/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.test.ts b/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.test.ts index 1d93fb7787050..36d2c99503c11 100644 --- a/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.test.ts +++ b/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.test.ts @@ -45,6 +45,7 @@ const MOCK_USAGE_STATS: UsageStats = { }; const kibanaIndex = '.kibana-tests'; +const getIndexForType = () => Promise.resolve(kibanaIndex); function setup({ license = { isAvailable: true }, @@ -122,7 +123,7 @@ describe('error handling', () => { license: { isAvailable: true, type: 'basic' }, }); const collector = getSpacesUsageCollector(usageCollection as any, { - kibanaIndex, + getIndexForType, features, licensing, usageStatsServicePromise: Promise.resolve(usageStatsService), @@ -146,7 +147,7 @@ describe('with a basic license', () => { beforeAll(async () => { const collector = getSpacesUsageCollector(usageCollection as any, { - kibanaIndex, + getIndexForType, features, licensing, usageStatsServicePromise: Promise.resolve(usageStatsService), @@ -205,7 +206,7 @@ describe('with no license', () => { beforeAll(async () => { const collector = getSpacesUsageCollector(usageCollection as any, { - kibanaIndex, + getIndexForType, features, licensing, usageStatsServicePromise: Promise.resolve(usageStatsService), @@ -246,7 +247,7 @@ describe('with platinum license', () => { beforeAll(async () => { const collector = getSpacesUsageCollector(usageCollection as any, { - kibanaIndex, + getIndexForType, features, licensing, usageStatsServicePromise: Promise.resolve(usageStatsService), diff --git a/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.ts b/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.ts index d994d42f85a8a..bb41531ea9100 100644 --- a/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.ts +++ b/x-pack/plugins/spaces/server/usage_collection/spaces_usage_collector.ts @@ -149,7 +149,7 @@ export interface UsageData extends UsageStats { } interface CollectorDeps { - kibanaIndex: string; + getIndexForType: (type: string) => Promise; features: PluginsSetup['features']; licensing: PluginsSetup['licensing']; usageStatsServicePromise: Promise; @@ -453,11 +453,12 @@ export function getSpacesUsageCollector( }, }, fetch: async ({ esClient }: CollectorFetchContext) => { - const { licensing, kibanaIndex, features, usageStatsServicePromise } = deps; + const { licensing, getIndexForType, features, usageStatsServicePromise } = deps; const license = await firstValueFrom(licensing.license$); const available = license.isAvailable; // some form of spaces is available for all valid licenses - const usageData = await getSpacesUsage(esClient, kibanaIndex, features, available); + const spaceIndex = await getIndexForType('space'); + const usageData = await getSpacesUsage(esClient, spaceIndex, features, available); const usageStats = await getUsageStats(usageStatsServicePromise, available); return { diff --git a/x-pack/plugins/task_manager/server/plugin.ts b/x-pack/plugins/task_manager/server/plugin.ts index 1fb28465f5bce..98b6d711b5539 100644 --- a/x-pack/plugins/task_manager/server/plugin.ts +++ b/x-pack/plugins/task_manager/server/plugin.ts @@ -127,7 +127,7 @@ export class TaskManagerPlugin config: this.config!, usageCounter: this.usageCounter!, kibanaVersion: this.kibanaVersion, - kibanaIndexName: core.savedObjects.getKibanaIndex(), + kibanaIndexName: core.savedObjects.getDefaultIndex(), getClusterClient: () => startServicesPromise.then(({ elasticsearch }) => elasticsearch.client), shouldRunTasks: this.shouldRunBackgroundTasks, @@ -141,7 +141,7 @@ export class TaskManagerPlugin config: this.config!, usageCounter: this.usageCounter!, kibanaVersion: this.kibanaVersion, - kibanaIndexName: core.savedObjects.getKibanaIndex(), + kibanaIndexName: core.savedObjects.getDefaultIndex(), getClusterClient: () => startServicesPromise.then(({ elasticsearch }) => elasticsearch.client), });