Skip to content

Commit

Permalink
Separate index pattern creation from asset import and use overwrite: …
Browse files Browse the repository at this point in the history
…false
  • Loading branch information
kpollich committed Oct 30, 2023
1 parent 788d302 commit 92b9e11
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,22 @@ export async function installKibanaAssets(options: {
return [];
}

// As we use `import` to create our saved objects, we have to install
// their references (the index patterns) at the same time
// to prevent a reference error
// Create index patterns separately with `overwrite: false` to prevent blowing away users' runtime fields
const indexPatternSavedObjects = getIndexPatternSavedObjects() as ArchiveAsset[];
await retryImportOnConflictError(() =>
savedObjectsImporter.import({
overwrite: false,
readStream: createListStream(indexPatternSavedObjects),
createNewCopies: false,
refresh: false,
managed: true,
})
);

const installedAssets = await installKibanaSavedObjects({
logger,
savedObjectsImporter,
kibanaAssets: [...indexPatternSavedObjects, ...assetsToInstall],
kibanaAssets: assetsToInstall,
});

return installedAssets;
Expand Down

0 comments on commit 92b9e11

Please sign in to comment.