Skip to content

Commit

Permalink
[APM] Ensure APM data view is available across all spaces (elastic#16…
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv authored Oct 2, 2023
1 parent df3d0a6 commit b0ef90d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b0ef90d

Please sign in to comment.