mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] Make UI indices space aware (support for spaces) (#126378)
* changing structure of the saved object when migrating * addressing PR changes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
33d85a3384
commit
0fb24a095f
3 changed files with 31 additions and 41 deletions
|
@ -8,7 +8,6 @@
|
|||
import { SavedObjectsType } from 'src/core/server';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { updateApmOssIndexPaths } from './migrations/update_apm_oss_index_paths';
|
||||
import { ApmIndicesConfigName } from '..';
|
||||
|
||||
export interface APMIndices {
|
||||
apmIndices?: {
|
||||
|
@ -22,32 +21,14 @@ export interface APMIndices {
|
|||
isSpaceAware?: boolean;
|
||||
}
|
||||
|
||||
const properties: {
|
||||
apmIndices: {
|
||||
properties: {
|
||||
[Property in ApmIndicesConfigName]: { type: 'keyword' };
|
||||
};
|
||||
};
|
||||
isSpaceAware: { type: 'boolean' };
|
||||
} = {
|
||||
apmIndices: {
|
||||
properties: {
|
||||
sourcemap: { type: 'keyword' },
|
||||
error: { type: 'keyword' },
|
||||
onboarding: { type: 'keyword' },
|
||||
span: { type: 'keyword' },
|
||||
transaction: { type: 'keyword' },
|
||||
metric: { type: 'keyword' },
|
||||
},
|
||||
},
|
||||
isSpaceAware: { type: 'boolean' },
|
||||
};
|
||||
|
||||
export const apmIndices: SavedObjectsType = {
|
||||
name: 'apm-indices',
|
||||
hidden: false,
|
||||
namespaceType: 'single',
|
||||
mappings: { properties },
|
||||
mappings: {
|
||||
dynamic: false,
|
||||
properties: {}, // several fields exist, but we don't need to search or aggregate on them, so we exclude them from the mappings
|
||||
},
|
||||
management: {
|
||||
importableAndExportable: true,
|
||||
icon: 'apmApp',
|
||||
|
@ -61,5 +42,9 @@ export const apmIndices: SavedObjectsType = {
|
|||
const attributes = updateApmOssIndexPaths(doc.attributes);
|
||||
return { ...doc, attributes };
|
||||
},
|
||||
'8.2.0': (doc) => {
|
||||
// Any future changes on this structure should be also tested on migrateLegacyAPMIndicesToSpaceAware
|
||||
return { ...doc, attributes: { apmIndices: doc.attributes } };
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -81,12 +81,14 @@ describe('migrateLegacyAPMIndicesToSpaceAware', () => {
|
|||
updated_at: '2022-02-22T14:17:10.584Z',
|
||||
version: 'WzE1OSwxXQ==',
|
||||
attributes: {
|
||||
transaction: 'default-apm-*',
|
||||
span: 'default-apm-*',
|
||||
error: 'default-apm-*',
|
||||
metric: 'default-apm-*',
|
||||
sourcemap: 'default-apm-*',
|
||||
onboarding: 'default-apm-*',
|
||||
apmIndices: {
|
||||
transaction: 'default-apm-*',
|
||||
span: 'default-apm-*',
|
||||
error: 'default-apm-*',
|
||||
metric: 'default-apm-*',
|
||||
sourcemap: 'default-apm-*',
|
||||
onboarding: 'default-apm-*',
|
||||
},
|
||||
},
|
||||
references: [],
|
||||
migrationVersion: {
|
||||
|
@ -154,12 +156,14 @@ describe('migrateLegacyAPMIndicesToSpaceAware', () => {
|
|||
}),
|
||||
});
|
||||
const attributes = {
|
||||
transaction: 'space-apm-*',
|
||||
span: 'space-apm-*',
|
||||
error: 'space-apm-*',
|
||||
metric: 'space-apm-*',
|
||||
sourcemap: 'space-apm-*',
|
||||
onboarding: 'space-apm-*',
|
||||
apmIndices: {
|
||||
transaction: 'space-apm-*',
|
||||
span: 'space-apm-*',
|
||||
error: 'space-apm-*',
|
||||
metric: 'space-apm-*',
|
||||
sourcemap: 'space-apm-*',
|
||||
onboarding: 'space-apm-*',
|
||||
},
|
||||
};
|
||||
const core = {
|
||||
savedObjects: {
|
||||
|
@ -197,7 +201,7 @@ describe('migrateLegacyAPMIndicesToSpaceAware', () => {
|
|||
type: APM_INDEX_SETTINGS_SAVED_OBJECT_TYPE,
|
||||
id: APM_INDEX_SETTINGS_SAVED_OBJECT_ID,
|
||||
initialNamespaces: [id],
|
||||
attributes: { apmIndices: attributes, isSpaceAware: true },
|
||||
attributes: { ...attributes, isSpaceAware: true },
|
||||
};
|
||||
})
|
||||
);
|
||||
|
|
|
@ -19,9 +19,10 @@ import { APMIndices } from '../apm_indices';
|
|||
|
||||
async function fetchLegacyAPMIndices(repository: ISavedObjectsRepository) {
|
||||
try {
|
||||
const apmIndices = await repository.get<
|
||||
Partial<ApmIndicesConfig & { isSpaceAware: boolean }>
|
||||
>(APM_INDEX_SETTINGS_SAVED_OBJECT_TYPE, APM_INDEX_SETTINGS_SAVED_OBJECT_ID);
|
||||
const apmIndices = await repository.get<Partial<APMIndices>>(
|
||||
APM_INDEX_SETTINGS_SAVED_OBJECT_TYPE,
|
||||
APM_INDEX_SETTINGS_SAVED_OBJECT_ID
|
||||
);
|
||||
if (apmIndices.attributes.isSpaceAware) {
|
||||
// This has already been migrated to become space-aware
|
||||
return null;
|
||||
|
@ -59,8 +60,8 @@ export async function migrateLegacyAPMIndicesToSpaceAware({
|
|||
fields: ['name'], // to avoid fetching *all* fields
|
||||
});
|
||||
|
||||
const savedObjectAttributes: APMIndices = {
|
||||
apmIndices: legacyAPMIndices.attributes,
|
||||
const savedObjectAttributes = {
|
||||
...legacyAPMIndices.attributes,
|
||||
isSpaceAware: true,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue