diff --git a/x-pack/plugins/rule_registry/common/assets/lifecycle_policies/default_lifecycle_policy.ts b/x-pack/plugins/rule_registry/common/assets/lifecycle_policies/default_lifecycle_policy.ts index 24653dbf07d2d..449a425ad3aa6 100644 --- a/x-pack/plugins/rule_registry/common/assets/lifecycle_policies/default_lifecycle_policy.ts +++ b/x-pack/plugins/rule_registry/common/assets/lifecycle_policies/default_lifecycle_policy.ts @@ -7,6 +7,9 @@ export const defaultLifecyclePolicy = { policy: { + _meta: { + managed: true, + }, phases: { hot: { actions: { diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts index 97812d53c9f37..638a6461a4163 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts @@ -159,11 +159,26 @@ export class ResourceInstaller { private async updateAliasWriteIndexMapping({ index, alias }: ConcreteIndexInfo) { const { logger, getClusterClient } = this.options; const clusterClient = await getClusterClient(); - const simulatedIndexMapping = await clusterClient.indices.simulateIndexTemplate({ - name: index, - }); + + let simulatedIndexMapping: estypes.IndicesSimulateIndexTemplateResponse; + try { + simulatedIndexMapping = await clusterClient.indices.simulateIndexTemplate({ + name: index, + }); + } catch (err) { + logger.error( + `Ignored PUT mappings for alias ${alias}; error generating simulated mappings: ${err.message}` + ); + return; + } + const simulatedMapping = get(simulatedIndexMapping, ['body', 'template', 'mappings']); + if (simulatedMapping == null) { + logger.error(`Ignored PUT mappings for alias ${alias}; simulated mappings were empty`); + return; + } + try { await clusterClient.indices.putMapping({ index,