From 4d7e0783ff17ddc34cca57f135bc45ad7efe2037 Mon Sep 17 00:00:00 2001 From: Ying Date: Mon, 6 Feb 2023 09:21:55 -0500 Subject: [PATCH 1/5] Update ILM policy to be consistent between framework & rule registry --- .../server/alerts_service/alerts_service.ts | 17 +++++++---- .../default_lifecycle_policy.ts | 4 +-- x-pack/plugins/alerting/server/index.ts | 4 +++ x-pack/plugins/alerting/server/plugin.ts | 2 ++ x-pack/plugins/rule_registry/common/assets.ts | 1 - .../default_lifecycle_policy.ts | 24 ---------------- x-pack/plugins/rule_registry/server/plugin.ts | 7 ++++- .../resource_installer.test.ts | 2 -- .../resource_installer.ts | 28 +++++++++++-------- .../rule_data_plugin_service.ts | 2 ++ 10 files changed, 44 insertions(+), 47 deletions(-) delete mode 100644 x-pack/plugins/rule_registry/common/assets/lifecycle_policies/default_lifecycle_policy.ts diff --git a/x-pack/plugins/alerting/server/alerts_service/alerts_service.ts b/x-pack/plugins/alerting/server/alerts_service/alerts_service.ts index 0742be50c4fa4..08643caf862f5 100644 --- a/x-pack/plugins/alerting/server/alerts_service/alerts_service.ts +++ b/x-pack/plugins/alerting/server/alerts_service/alerts_service.ts @@ -15,7 +15,10 @@ import { Logger, ElasticsearchClient } from '@kbn/core/server'; import { firstValueFrom, Observable } from 'rxjs'; import { FieldMap } from '../../common/alert_schema/field_maps/types'; import { alertFieldMap } from '../../common/alert_schema'; -import { ILM_POLICY_NAME, DEFAULT_ILM_POLICY } from './default_lifecycle_policy'; +import { + DEFAULT_ALERTS_ILM_POLICY_NAME, + DEFAULT_ALERTS_ILM_POLICY, +} from './default_lifecycle_policy'; import { getComponentTemplate, getComponentTemplateName, @@ -178,19 +181,21 @@ export class AlertsService implements IAlertsService { * Creates ILM policy if it doesn't already exist, updates it if it does */ private async createOrUpdateIlmPolicy(esClient: ElasticsearchClient) { - this.options.logger.info(`Installing ILM policy ${ILM_POLICY_NAME}`); + this.options.logger.info(`Installing ILM policy ${DEFAULT_ALERTS_ILM_POLICY_NAME}`); try { await retryTransientEsErrors( () => esClient.ilm.putLifecycle({ - name: ILM_POLICY_NAME, - body: DEFAULT_ILM_POLICY, + name: DEFAULT_ALERTS_ILM_POLICY_NAME, + body: DEFAULT_ALERTS_ILM_POLICY, }), { logger: this.options.logger } ); } catch (err) { - this.options.logger.error(`Error installing ILM policy ${ILM_POLICY_NAME} - ${err.message}`); + this.options.logger.error( + `Error installing ILM policy ${DEFAULT_ALERTS_ILM_POLICY_NAME} - ${err.message}` + ); throw err; } } @@ -236,7 +241,7 @@ export class AlertsService implements IAlertsService { auto_expand_replicas: '0-1', hidden: true, 'index.lifecycle': { - name: ILM_POLICY_NAME, + name: DEFAULT_ALERTS_ILM_POLICY_NAME, rollover_alias: indexPatterns.alias, }, 'index.mapping.total_fields.limit': TOTAL_FIELDS_LIMIT, diff --git a/x-pack/plugins/alerting/server/alerts_service/default_lifecycle_policy.ts b/x-pack/plugins/alerting/server/alerts_service/default_lifecycle_policy.ts index f5d11c6214ee6..5e8c40cf6f6a8 100644 --- a/x-pack/plugins/alerting/server/alerts_service/default_lifecycle_policy.ts +++ b/x-pack/plugins/alerting/server/alerts_service/default_lifecycle_policy.ts @@ -14,8 +14,8 @@ * This should be used by all alerts-as-data indices */ -export const ILM_POLICY_NAME = 'alerts-default-ilm-policy'; -export const DEFAULT_ILM_POLICY = { +export const DEFAULT_ALERTS_ILM_POLICY_NAME = '.alerts-ilm-policy'; +export const DEFAULT_ALERTS_ILM_POLICY = { policy: { _meta: { managed: true, diff --git a/x-pack/plugins/alerting/server/index.ts b/x-pack/plugins/alerting/server/index.ts index 8d42aa47091f2..a13b06596f557 100644 --- a/x-pack/plugins/alerting/server/index.ts +++ b/x-pack/plugins/alerting/server/index.ts @@ -53,6 +53,10 @@ export { WriteOperations, AlertingAuthorizationEntity, } from './authorization'; +export { + DEFAULT_ALERTS_ILM_POLICY, + DEFAULT_ALERTS_ILM_POLICY_NAME, +} from './alerts_service/default_lifecycle_policy'; export const plugin = (initContext: PluginInitializerContext) => new AlertingPlugin(initContext); diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index 6070b5cee56fb..414d4f4e01b91 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -126,6 +126,7 @@ export interface PluginSetupContract { ): void; getSecurityHealth: () => Promise; getConfig: () => AlertingRulesConfig; + getFrameworkAlertsEnabled: () => boolean; } export interface PluginStartContract { @@ -385,6 +386,7 @@ export class AlertingPlugin { isUsingSecurity: this.licenseState ? !!this.licenseState.getIsSecurityEnabled() : false, }; }, + getFrameworkAlertsEnabled: () => this.config.enableFrameworkAlerts, }; } diff --git a/x-pack/plugins/rule_registry/common/assets.ts b/x-pack/plugins/rule_registry/common/assets.ts index 1a5b14c605ea5..a1df09df18a8f 100644 --- a/x-pack/plugins/rule_registry/common/assets.ts +++ b/x-pack/plugins/rule_registry/common/assets.ts @@ -7,4 +7,3 @@ export const TECHNICAL_COMPONENT_TEMPLATE_NAME = `technical-mappings`; export const ECS_COMPONENT_TEMPLATE_NAME = `ecs-mappings`; -export const DEFAULT_ILM_POLICY_ID = 'ilm-policy'; 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 deleted file mode 100644 index 449a425ad3aa6..0000000000000 --- a/x-pack/plugins/rule_registry/common/assets/lifecycle_policies/default_lifecycle_policy.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export const defaultLifecyclePolicy = { - policy: { - _meta: { - managed: true, - }, - phases: { - hot: { - actions: { - rollover: { - max_age: '30d', - max_primary_shard_size: '50gb', - }, - }, - }, - }, - }, -}; diff --git a/x-pack/plugins/rule_registry/server/plugin.ts b/x-pack/plugins/rule_registry/server/plugin.ts index 68b2df1224065..8b5c754e5b908 100644 --- a/x-pack/plugins/rule_registry/server/plugin.ts +++ b/x-pack/plugins/rule_registry/server/plugin.ts @@ -16,7 +16,10 @@ import type { IContextProvider, } from '@kbn/core/server'; -import type { PluginStartContract as AlertingStart } from '@kbn/alerting-plugin/server'; +import type { + PluginSetupContract as AlertingSetup, + PluginStartContract as AlertingStart, +} from '@kbn/alerting-plugin/server'; import type { SecurityPluginSetup } from '@kbn/security-plugin/server'; import type { SpacesPluginStart } from '@kbn/spaces-plugin/server'; import type { @@ -36,6 +39,7 @@ import { ruleRegistrySearchStrategyProvider, RULE_SEARCH_STRATEGY_NAME } from '. export interface RuleRegistryPluginSetupDependencies { security?: SecurityPluginSetup; data: DataPluginSetup; + alerting: AlertingSetup; } export interface RuleRegistryPluginStartDependencies { @@ -106,6 +110,7 @@ export class RuleRegistryPlugin const deps = await startDependencies; return deps.core.elasticsearch.client.asInternalUser; }, + areFrameworkAlertsEnabled: plugins.alerting.getFrameworkAlertsEnabled(), pluginStop$: this.pluginStop$, }); diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts index d73b1898671bb..0649716a70690 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts @@ -14,7 +14,6 @@ import { Dataset } from './index_options'; import { IndexInfo } from './index_info'; import { elasticsearchServiceMock, ElasticsearchClientMock } from '@kbn/core/server/mocks'; import { - DEFAULT_ILM_POLICY_ID, ECS_COMPONENT_TEMPLATE_NAME, TECHNICAL_COMPONENT_TEMPLATE_NAME, } from '../../common/assets'; @@ -83,7 +82,6 @@ describe('resourceInstaller', () => { const getClusterClient = jest.fn(() => Promise.resolve(mockClusterClient)); const getResourceNameMock = jest .fn() - .mockReturnValueOnce(DEFAULT_ILM_POLICY_ID) .mockReturnValueOnce(TECHNICAL_COMPONENT_TEMPLATE_NAME) .mockReturnValueOnce(ECS_COMPONENT_TEMPLATE_NAME); const installer = new ResourceInstaller({ 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 30b867d114446..76956db6a0cdb 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 @@ -13,13 +13,15 @@ import type { ElasticsearchClient, Logger } from '@kbn/core/server'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { - DEFAULT_ILM_POLICY_ID, + DEFAULT_ALERTS_ILM_POLICY, + DEFAULT_ALERTS_ILM_POLICY_NAME, +} from '@kbn/alerting-plugin/server'; +import { ECS_COMPONENT_TEMPLATE_NAME, TECHNICAL_COMPONENT_TEMPLATE_NAME, } from '../../common/assets'; import { technicalComponentTemplate } from '../../common/assets/component_templates/technical_component_template'; import { ecsComponentTemplate } from '../../common/assets/component_templates/ecs_component_template'; -import { defaultLifecyclePolicy } from '../../common/assets/lifecycle_policies/default_lifecycle_policy'; import type { IndexInfo } from './index_info'; @@ -31,6 +33,7 @@ interface ConstructorOptions { logger: Logger; isWriteEnabled: boolean; disabledRegistrationContexts: string[]; + areFrameworkAlertsEnabled: boolean; pluginStop$: Observable; } @@ -95,16 +98,21 @@ export class ResourceInstaller { */ public async installCommonResources(): Promise { await this.installWithTimeout('common resources shared between all indices', async () => { - const { getResourceName, logger } = this.options; + const { getResourceName, logger, areFrameworkAlertsEnabled } = this.options; try { // We can install them in parallel await Promise.all([ - this.createOrUpdateLifecyclePolicy({ - name: getResourceName(DEFAULT_ILM_POLICY_ID), - body: defaultLifecyclePolicy, - }), - + // Install ILM policy only if framework alerts are not enabled + // If framework alerts are enabled, the alerting framework will install this ILM policy + ...(areFrameworkAlertsEnabled + ? [] + : [ + this.createOrUpdateLifecyclePolicy({ + name: DEFAULT_ALERTS_ILM_POLICY_NAME, + body: DEFAULT_ALERTS_ILM_POLICY, + }), + ]), this.createOrUpdateComponentTemplate({ name: getResourceName(TECHNICAL_COMPONENT_TEMPLATE_NAME), body: technicalComponentTemplate, @@ -326,9 +334,7 @@ export class ResourceInstaller { const ownComponentNames = componentTemplates.map((template) => indexInfo.getComponentTemplateName(template.name) ); - const ilmPolicyName = ilmPolicy - ? indexInfo.getIlmPolicyName() - : getResourceName(DEFAULT_ILM_POLICY_ID); + const ilmPolicyName = ilmPolicy ? indexInfo.getIlmPolicyName() : DEFAULT_ALERTS_ILM_POLICY; const indexMetadata: estypes.Metadata = { ...indexTemplate._meta, diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.ts index 459e4bacf9a66..b3f54a1d3794d 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.ts @@ -91,6 +91,7 @@ interface ConstructorOptions { isWriteEnabled: boolean; isWriterCacheEnabled: boolean; disabledRegistrationContexts: string[]; + areFrameworkAlertsEnabled: boolean; pluginStop$: Observable; } @@ -112,6 +113,7 @@ export class RuleDataService implements IRuleDataService { logger: options.logger, disabledRegistrationContexts: options.disabledRegistrationContexts, isWriteEnabled: options.isWriteEnabled, + areFrameworkAlertsEnabled: options.areFrameworkAlertsEnabled, pluginStop$: options.pluginStop$, }); From 16020b290a01850b78cd9afbf32d0877eeddaca8 Mon Sep 17 00:00:00 2001 From: Ying Date: Mon, 6 Feb 2023 09:43:46 -0500 Subject: [PATCH 2/5] Fixing unit tests --- .../alerts_service/alerts_service.test.ts | 8 ++-- x-pack/plugins/alerting/server/mocks.ts | 1 + x-pack/plugins/alerting/server/plugin.test.ts | 6 ++- .../resource_installer.test.ts | 37 +++++++++++++++++++ .../rule_data_plugin_service.test.ts | 4 ++ 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/alerting/server/alerts_service/alerts_service.test.ts b/x-pack/plugins/alerting/server/alerts_service/alerts_service.test.ts index ba3623526591f..82716f935c6b3 100644 --- a/x-pack/plugins/alerting/server/alerts_service/alerts_service.test.ts +++ b/x-pack/plugins/alerting/server/alerts_service/alerts_service.test.ts @@ -72,7 +72,7 @@ const IlmPutBody = { }, }, }, - name: 'alerts-default-ilm-policy', + name: '.alerts-ilm-policy', }; const getIndexTemplatePutBody = (context?: string) => ({ @@ -88,7 +88,7 @@ const getIndexTemplatePutBody = (context?: string) => ({ auto_expand_replicas: '0-1', hidden: true, 'index.lifecycle': { - name: 'alerts-default-ilm-policy', + name: '.alerts-ilm-policy', rollover_alias: `.alerts-${context ? context : 'test'}-default`, }, 'index.mapping.total_fields.limit': 2500, @@ -165,7 +165,7 @@ describe('Alerts Service', () => { expect(alertsService.isInitialized()).toEqual(false); expect(logger.error).toHaveBeenCalledWith( - `Error installing ILM policy alerts-default-ilm-policy - fail` + `Error installing ILM policy .alerts-ilm-policy - fail` ); expect(clusterClient.ilm.putLifecycle).toHaveBeenCalled(); @@ -342,7 +342,7 @@ describe('Alerts Service', () => { auto_expand_replicas: '0-1', hidden: true, 'index.lifecycle': { - name: 'alerts-default-ilm-policy', + name: '.alerts-ilm-policy', rollover_alias: `.alerts-empty-default`, }, 'index.mapping.total_fields.limit': 2500, diff --git a/x-pack/plugins/alerting/server/mocks.ts b/x-pack/plugins/alerting/server/mocks.ts index d997b709c0960..787ab3e9c856f 100644 --- a/x-pack/plugins/alerting/server/mocks.ts +++ b/x-pack/plugins/alerting/server/mocks.ts @@ -30,6 +30,7 @@ const createSetupMock = () => { registerType: jest.fn(), getSecurityHealth: jest.fn(), getConfig: jest.fn(), + getFrameworkAlertsEnabled: jest.fn(), }; return mock; }; diff --git a/x-pack/plugins/alerting/server/plugin.test.ts b/x-pack/plugins/alerting/server/plugin.test.ts index 4e48c0db01ae6..f0dd5ce64315f 100644 --- a/x-pack/plugins/alerting/server/plugin.test.ts +++ b/x-pack/plugins/alerting/server/plugin.test.ts @@ -132,10 +132,12 @@ describe('Alerting Plugin', () => { plugin = new AlertingPlugin(context); // need await to test number of calls of setupMocks.status.set, because it is under async function which awaiting core.getStartServices() - await plugin.setup(setupMocks, mockPlugins); + const setupContract = await plugin.setup(setupMocks, mockPlugins); expect(AlertsService).toHaveBeenCalled(); expect(mockAlertService.initialize).toHaveBeenCalled(); + + expect(setupContract.getFrameworkAlertsEnabled()).toEqual(true); }); it(`exposes configured minimumScheduleInterval()`, async () => { @@ -150,6 +152,8 @@ describe('Alerting Plugin', () => { isUsingSecurity: false, minimumScheduleInterval: { value: '1m', enforce: false }, }); + + expect(setupContract.getFrameworkAlertsEnabled()).toEqual(false); }); describe('registerType()', () => { diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts index 0649716a70690..b63fb2aae83d0 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.test.ts @@ -40,6 +40,7 @@ describe('resourceInstaller', () => { disabledRegistrationContexts: [], getResourceName: jest.fn(), getClusterClient, + areFrameworkAlertsEnabled: false, pluginStop$, }); installer.installCommonResources(); @@ -56,6 +57,7 @@ describe('resourceInstaller', () => { disabledRegistrationContexts: [], getResourceName: jest.fn(), getClusterClient, + areFrameworkAlertsEnabled: false, pluginStop$, }); const indexOptions = { @@ -90,6 +92,7 @@ describe('resourceInstaller', () => { disabledRegistrationContexts: [], getResourceName: getResourceNameMock, getClusterClient, + areFrameworkAlertsEnabled: false, pluginStop$, }); @@ -106,6 +109,38 @@ describe('resourceInstaller', () => { expect.objectContaining({ name: ECS_COMPONENT_TEMPLATE_NAME }) ); }); + + it('should install common resources when framework alerts are enabled', async () => { + const mockClusterClient = elasticsearchServiceMock.createElasticsearchClient(); + const getClusterClient = jest.fn(() => Promise.resolve(mockClusterClient)); + const getResourceNameMock = jest + .fn() + .mockReturnValueOnce(TECHNICAL_COMPONENT_TEMPLATE_NAME) + .mockReturnValueOnce(ECS_COMPONENT_TEMPLATE_NAME); + const installer = new ResourceInstaller({ + logger: loggerMock.create(), + isWriteEnabled: true, + disabledRegistrationContexts: [], + getResourceName: getResourceNameMock, + getClusterClient, + areFrameworkAlertsEnabled: true, + pluginStop$, + }); + + await installer.installCommonResources(); + + // ILM policy should be handled by framework + expect(mockClusterClient.ilm.putLifecycle).not.toHaveBeenCalled(); + expect(mockClusterClient.cluster.putComponentTemplate).toHaveBeenCalledTimes(2); + expect(mockClusterClient.cluster.putComponentTemplate).toHaveBeenNthCalledWith( + 1, + expect.objectContaining({ name: TECHNICAL_COMPONENT_TEMPLATE_NAME }) + ); + expect(mockClusterClient.cluster.putComponentTemplate).toHaveBeenNthCalledWith( + 2, + expect.objectContaining({ name: ECS_COMPONENT_TEMPLATE_NAME }) + ); + }); it('should install index level resources', async () => { const mockClusterClient = elasticsearchServiceMock.createElasticsearchClient(); const getClusterClient = jest.fn(() => Promise.resolve(mockClusterClient)); @@ -115,6 +150,7 @@ describe('resourceInstaller', () => { disabledRegistrationContexts: [], getResourceName: jest.fn(), getClusterClient, + areFrameworkAlertsEnabled: false, pluginStop$, }); @@ -186,6 +222,7 @@ describe('resourceInstaller', () => { disabledRegistrationContexts: [], getResourceName: jest.fn(), getClusterClient: async () => mockClusterClient, + areFrameworkAlertsEnabled: false, pluginStop$, }; const indexOptions = { diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.test.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.test.ts index 997137877bc9b..1022ea038bc3e 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.test.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.test.ts @@ -43,6 +43,7 @@ describe('ruleDataPluginService', () => { isWriteEnabled: true, disabledRegistrationContexts: ['observability.logs'], isWriterCacheEnabled: true, + areFrameworkAlertsEnabled: false, pluginStop$, }); expect(ruleDataService.isRegistrationContextDisabled('observability.logs')).toBe(true); @@ -59,6 +60,7 @@ describe('ruleDataPluginService', () => { isWriteEnabled: true, disabledRegistrationContexts: ['observability.logs'], isWriterCacheEnabled: true, + areFrameworkAlertsEnabled: false, pluginStop$, }); expect(ruleDataService.isRegistrationContextDisabled('observability.apm')).toBe(false); @@ -77,6 +79,7 @@ describe('ruleDataPluginService', () => { isWriteEnabled: true, disabledRegistrationContexts: ['observability.logs'], isWriterCacheEnabled: true, + areFrameworkAlertsEnabled: false, pluginStop$, }); @@ -96,6 +99,7 @@ describe('ruleDataPluginService', () => { isWriteEnabled: true, disabledRegistrationContexts: ['observability.logs'], isWriterCacheEnabled: true, + areFrameworkAlertsEnabled: false, pluginStop$, }); const indexOptions = { From d627b5e5a19aeaf0be1d046636fd4dd460c94fe7 Mon Sep 17 00:00:00 2001 From: Ying Date: Mon, 6 Feb 2023 10:41:59 -0500 Subject: [PATCH 3/5] Fixing types --- .../spaces_only/tests/trial/get_summarized_alerts.ts | 1 + .../rule_registry/spaces_only/tests/trial/lifecycle_executor.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/x-pack/test/rule_registry/spaces_only/tests/trial/get_summarized_alerts.ts b/x-pack/test/rule_registry/spaces_only/tests/trial/get_summarized_alerts.ts index b62d744503fc6..02765aa8c2a77 100644 --- a/x-pack/test/rule_registry/spaces_only/tests/trial/get_summarized_alerts.ts +++ b/x-pack/test/rule_registry/spaces_only/tests/trial/get_summarized_alerts.ts @@ -80,6 +80,7 @@ export default function createGetSummarizedAlertsTest({ getService }: FtrProvide isWriteEnabled: true, isWriterCacheEnabled: false, disabledRegistrationContexts: [] as string[], + areFrameworkAlertsEnabled: false, pluginStop$, }); diff --git a/x-pack/test/rule_registry/spaces_only/tests/trial/lifecycle_executor.ts b/x-pack/test/rule_registry/spaces_only/tests/trial/lifecycle_executor.ts index 2fbba4478e925..dc5752417bfb4 100644 --- a/x-pack/test/rule_registry/spaces_only/tests/trial/lifecycle_executor.ts +++ b/x-pack/test/rule_registry/spaces_only/tests/trial/lifecycle_executor.ts @@ -74,6 +74,7 @@ export default function createLifecycleExecutorApiTest({ getService }: FtrProvid isWriteEnabled: true, isWriterCacheEnabled: false, disabledRegistrationContexts: [] as string[], + areFrameworkAlertsEnabled: false, pluginStop$, }); From 0a33de02801cb0022d4fa2e018e11f1d2b0e563f Mon Sep 17 00:00:00 2001 From: Ying Date: Mon, 6 Feb 2023 11:37:47 -0500 Subject: [PATCH 4/5] Fixing typo --- .../server/rule_data_plugin_service/resource_installer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 76956db6a0cdb..6af288e57a4a0 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 @@ -334,7 +334,7 @@ export class ResourceInstaller { const ownComponentNames = componentTemplates.map((template) => indexInfo.getComponentTemplateName(template.name) ); - const ilmPolicyName = ilmPolicy ? indexInfo.getIlmPolicyName() : DEFAULT_ALERTS_ILM_POLICY; + const ilmPolicyName = ilmPolicy ? indexInfo.getIlmPolicyName() : DEFAULT_ALERTS_ILM_POLICY_NAME; const indexMetadata: estypes.Metadata = { ...indexTemplate._meta, From d21538d636ea43ef4eabc80b550f0a43df9c4fdf Mon Sep 17 00:00:00 2001 From: Ying Date: Mon, 6 Feb 2023 12:06:25 -0500 Subject: [PATCH 5/5] Fixing functional test --- .../spaces_only/tests/alerting/group4/alerts_as_data.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data.ts index 49ec03fc6d8d8..3ac2fdb93add8 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data.ts @@ -17,7 +17,7 @@ export default function createAlertsAsDataTest({ getService }: FtrProviderContex describe('alerts as data', () => { it('should install common alerts as data resources on startup', async () => { - const ilmPolicyName = 'alerts-default-ilm-policy'; + const ilmPolicyName = '.alerts-ilm-policy'; const componentTemplateName = 'alerts-common-component-template'; const commonIlmPolicy = await es.ilm.getLifecycle({ @@ -123,7 +123,7 @@ export default function createAlertsAsDataTest({ getService }: FtrProviderContex expect(contextIndexTemplate.index_template.template!.settings).to.eql({ index: { lifecycle: { - name: 'alerts-default-ilm-policy', + name: '.alerts-ilm-policy', rollover_alias: '.alerts-test.always-firing-default', }, mapping: { @@ -155,7 +155,7 @@ export default function createAlertsAsDataTest({ getService }: FtrProviderContex }); expect(contextIndex[indexName].settings?.index?.lifecycle).to.eql({ - name: 'alerts-default-ilm-policy', + name: '.alerts-ilm-policy', rollover_alias: '.alerts-test.always-firing-default', });