[APM] Ensure APM data view is available across all spaces (#167704)

This commit is contained in:
Søren Louv-Jansen 2023-10-02 13:01:23 +02:00 committed by GitHub
parent df3d0a60e9
commit b0ef90dad1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import {
Logger,
Plugin,
PluginInitializerContext,
SavedObjectsClient,
} from '@kbn/core/server';
import { isEmpty, mapValues } from 'lodash';
import { Dataset } from '@kbn/rule-registry-plugin/server';
@ -48,6 +49,7 @@ import { scheduleSourceMapMigration } from './routes/source_maps/schedule_source
import { createApmSourceMapIndexTemplate } from './routes/source_maps/create_apm_source_map_index_template';
import { addApiKeysToEveryPackagePolicyIfMissing } from './routes/fleet/api_keys/add_api_keys_to_policies_if_missing';
import { apmTutorialCustomIntegration } from '../common/tutorial/tutorials';
import { APM_STATIC_DATA_VIEW_ID } from '../common/data_view_constants';
export class APMPlugin
implements
@ -119,6 +121,26 @@ export class APMPlugin
],
});
// ensure that the APM data view is globally available
getCoreStart()
.then(async (coreStart) => {
const soClient = new SavedObjectsClient(
coreStart.savedObjects.createInternalRepository()
);
await soClient.updateObjectsSpaces(
[{ id: APM_STATIC_DATA_VIEW_ID, type: 'index-pattern' }],
['*'],
[]
);
})
.catch((e) => {
this.logger?.error(
'Failed to make APM data view available globally',
e
);
});
const resourcePlugins = mapValues(plugins, (value, key) => {
return {
setup: value,