diff --git a/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx b/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx index 28b4c7b2a3d736..cf59af003a7880 100644 --- a/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx @@ -57,7 +57,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({ uptime: { enabled: false }, observability: { enabled: false }, }, - thresholdRule: { enabled: false }, }, aiAssistant: { enabled: false, diff --git a/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx b/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx index 3114c084be289e..a1023f33f43139 100644 --- a/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx +++ b/x-pack/plugins/observability/public/pages/overview/overview.stories.tsx @@ -85,7 +85,6 @@ const withCore = makeDecorator({ uptime: { enabled: false }, observability: { enabled: false }, }, - thresholdRule: { enabled: false }, }, }; diff --git a/x-pack/plugins/observability/public/pages/rules/rules.test.tsx b/x-pack/plugins/observability/public/pages/rules/rules.test.tsx index 3b36403c4e18fa..6f18d308780ad4 100644 --- a/x-pack/plugins/observability/public/pages/rules/rules.test.tsx +++ b/x-pack/plugins/observability/public/pages/rules/rules.test.tsx @@ -44,7 +44,6 @@ jest.spyOn(pluginContext, 'usePluginContext').mockImplementation(() => ({ uptime: { enabled: false }, observability: { enabled: false }, }, - thresholdRule: { enabled: false }, }, }, observabilityRuleTypeRegistry: createObservabilityRuleTypeRegistryMock(), diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index b6c17e0c3f914b..57ef081903869f 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -104,7 +104,7 @@ export interface ConfigSchema { enabled: boolean; }; }; - thresholdRule: { + thresholdRule?: { enabled: boolean; }; }; diff --git a/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts b/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts index a1faec27f6c837..643d5ffd4f337d 100644 --- a/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts +++ b/x-pack/plugins/observability/public/rules/register_observability_rule_types.ts @@ -115,52 +115,49 @@ export const registerObservabilityRuleTypes = async ( priority: 100, }); - if (config.unsafe.thresholdRule.enabled) { - observabilityRuleTypeRegistry.register({ - id: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, - description: i18n.translate( - 'xpack.observability.customThreshold.rule.alertFlyout.alertDescription', - { - defaultMessage: - 'Alert when any Observability data type reaches or exceeds a given value.', - } - ), - iconClass: 'bell', - documentationUrl(docLinks) { - return `${docLinks.links.observability.customThreshold}`; - }, - ruleParamsExpression: lazy( - () => import('../components/custom_threshold/custom_threshold_rule_expression') - ), - validate: validateCustomThreshold, - defaultActionMessage: thresholdDefaultActionMessage, - defaultRecoveryMessage: thresholdDefaultRecoveryMessage, - requiresAppContext: false, - format: ({ fields }) => { - const searchConfiguration = fields[ALERT_RULE_PARAMETERS]?.searchConfiguration as - | SerializedSearchSourceFields - | undefined; - const criteria = fields[ALERT_RULE_PARAMETERS]?.criteria as MetricExpression[]; - const metrics: CustomThresholdExpressionMetric[] = - criteria.length === 1 ? criteria[0].metrics : []; - - const dataViewId = getDataViewId(searchConfiguration); - return { - reason: fields[ALERT_REASON] ?? '-', - link: getViewInAppUrl( - metrics, - fields[ALERT_START], - logExplorerLocator, - (searchConfiguration?.query as { query: string }).query, - dataViewId - ), - hasBasePath: true, - }; - }, - alertDetailsAppSection: lazy( - () => import('../components/custom_threshold/components/alert_details_app_section') - ), - priority: 5, - }); - } + observabilityRuleTypeRegistry.register({ + id: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, + description: i18n.translate( + 'xpack.observability.customThreshold.rule.alertFlyout.alertDescription', + { + defaultMessage: 'Alert when any Observability data type reaches or exceeds a given value.', + } + ), + iconClass: 'bell', + documentationUrl(docLinks) { + return `${docLinks.links.observability.customThreshold}`; + }, + ruleParamsExpression: lazy( + () => import('../components/custom_threshold/custom_threshold_rule_expression') + ), + validate: validateCustomThreshold, + defaultActionMessage: thresholdDefaultActionMessage, + defaultRecoveryMessage: thresholdDefaultRecoveryMessage, + requiresAppContext: false, + format: ({ fields }) => { + const searchConfiguration = fields[ALERT_RULE_PARAMETERS]?.searchConfiguration as + | SerializedSearchSourceFields + | undefined; + const criteria = fields[ALERT_RULE_PARAMETERS]?.criteria as MetricExpression[]; + const metrics: CustomThresholdExpressionMetric[] = + criteria.length === 1 ? criteria[0].metrics : []; + + const dataViewId = getDataViewId(searchConfiguration); + return { + reason: fields[ALERT_REASON] ?? '-', + link: getViewInAppUrl( + metrics, + fields[ALERT_START], + logExplorerLocator, + (searchConfiguration?.query as { query: string }).query, + dataViewId + ), + hasBasePath: true, + }; + }, + alertDetailsAppSection: lazy( + () => import('../components/custom_threshold/components/alert_details_app_section') + ), + priority: 5, + }); }; diff --git a/x-pack/plugins/observability/public/utils/kibana_react.storybook_decorator.tsx b/x-pack/plugins/observability/public/utils/kibana_react.storybook_decorator.tsx index 8b8f65e244ddf4..2051da5f430363 100644 --- a/x-pack/plugins/observability/public/utils/kibana_react.storybook_decorator.tsx +++ b/x-pack/plugins/observability/public/utils/kibana_react.storybook_decorator.tsx @@ -32,7 +32,6 @@ export function KibanaReactStorybookDecorator(Story: ComponentType) { uptime: { enabled: false }, observability: { enabled: false }, }, - thresholdRule: { enabled: false }, }, }; diff --git a/x-pack/plugins/observability/public/utils/test_helper.tsx b/x-pack/plugins/observability/public/utils/test_helper.tsx index 12fa672552db99..9428f887ed93c0 100644 --- a/x-pack/plugins/observability/public/utils/test_helper.tsx +++ b/x-pack/plugins/observability/public/utils/test_helper.tsx @@ -36,7 +36,6 @@ const defaultConfig: ConfigSchema = { uptime: { enabled: false }, observability: { enabled: false }, }, - thresholdRule: { enabled: false }, }, }; diff --git a/x-pack/plugins/observability/server/index.ts b/x-pack/plugins/observability/server/index.ts index da4797f42c43f5..46e294f6032277 100644 --- a/x-pack/plugins/observability/server/index.ts +++ b/x-pack/plugins/observability/server/index.ts @@ -47,8 +47,8 @@ const configSchema = schema.object({ }), thresholdRule: schema.object({ enabled: offeringBasedSchema({ - serverless: schema.boolean({ defaultValue: true }), - traditional: schema.boolean({ defaultValue: true }), + serverless: schema.boolean({ defaultValue: false }), + traditional: schema.boolean({ defaultValue: false }), }), }), }), @@ -70,7 +70,10 @@ export const config: PluginConfigDescriptor = { }, }, schema: configSchema, - deprecations: ({ unused }) => [unused('unsafe.alertDetails.logs.enabled', { level: 'warning' })], + deprecations: ({ unused }) => [ + unused('unsafe.thresholdRule.enabled', { level: 'warning' }), + unused('unsafe.alertDetails.logs.enabled', { level: 'warning' }), + ], }; export type ObservabilityConfig = TypeOf; diff --git a/x-pack/plugins/observability/server/lib/rules/register_rule_types.ts b/x-pack/plugins/observability/server/lib/rules/register_rule_types.ts index c90ee35f86552d..f705cf64164596 100644 --- a/x-pack/plugins/observability/server/lib/rules/register_rule_types.ts +++ b/x-pack/plugins/observability/server/lib/rules/register_rule_types.ts @@ -58,35 +58,32 @@ export function registerRuleTypes( sloBurnRateRuleType(createLifecycleRuleExecutorSLO, basePath, locators.alertsLocator) ); - // Threshold RULE - if (config.unsafe.thresholdRule.enabled) { - const ruleDataClientThreshold = ruleDataService.initializeIndex({ - feature: observabilityFeatureId, - registrationContext: THRESHOLD_RULE_REGISTRATION_CONTEXT, - dataset: Dataset.alerts, - componentTemplateRefs: [], - componentTemplates: [ - { - name: 'mappings', - mappings: mappingFromFieldMap({ ...legacyExperimentalFieldMap }, 'strict'), - }, - ], - }); + const ruleDataClientThreshold = ruleDataService.initializeIndex({ + feature: observabilityFeatureId, + registrationContext: THRESHOLD_RULE_REGISTRATION_CONTEXT, + dataset: Dataset.alerts, + componentTemplateRefs: [], + componentTemplates: [ + { + name: 'mappings', + mappings: mappingFromFieldMap({ ...legacyExperimentalFieldMap }, 'strict'), + }, + ], + }); - const createLifecycleRuleExecutorThreshold = createLifecycleExecutor( - logger.get('rules'), - ruleDataClientThreshold - ); + const createLifecycleRuleExecutorThreshold = createLifecycleExecutor( + logger.get('rules'), + ruleDataClientThreshold + ); - alertingPlugin.registerType( - thresholdRuleType( - createLifecycleRuleExecutorThreshold, - basePath, - config, - logger, - ruleDataClientThreshold, - locators - ) - ); - } + alertingPlugin.registerType( + thresholdRuleType( + createLifecycleRuleExecutorThreshold, + basePath, + config, + logger, + ruleDataClientThreshold, + locators + ) + ); } diff --git a/x-pack/test/alerting_api_integration/common/config.ts b/x-pack/test/alerting_api_integration/common/config.ts index 7fdd7668135a49..4a5c6659114955 100644 --- a/x-pack/test/alerting_api_integration/common/config.ts +++ b/x-pack/test/alerting_api_integration/common/config.ts @@ -195,7 +195,6 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) '--xpack.alerting.healthCheck.interval="1s"', '--xpack.alerting.rules.minimumScheduleInterval.value="1s"', '--xpack.alerting.rules.run.alerts.max=20', - '--xpack.observability.unsafe.thresholdRule.enabled=true', `--xpack.alerting.rules.run.actions.connectorTypeOverrides=${JSON.stringify([ { id: 'test.capped', max: '1' }, ])}`, diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/config.feature_flags.ts b/x-pack/test_serverless/api_integration/test_suites/observability/config.feature_flags.ts index 06fb7e5682ea3f..09340543ad7a8d 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/config.feature_flags.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/config.feature_flags.ts @@ -20,10 +20,7 @@ export default createTestConfig({ suiteTags: { exclude: ['skipSvlOblt'] }, services, // add feature flags - kbnServerArgs: [ - '--xpack.observability.unsafe.thresholdRule.enabled=true', - '--xpack.infra.enabled=true', - ], + kbnServerArgs: ['--xpack.infra.enabled=true'], // load tests in the index file testFiles: [require.resolve('./index.feature_flags.ts')], diff --git a/x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts b/x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts index 157593d38100b6..2fd50316f8679a 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/config.feature_flags.ts @@ -21,7 +21,6 @@ export default createTestConfig({ kbnServerArgs: [ '--xpack.infra.enabled=true', '--xpack.infra.featureFlags.customThresholdAlertsEnabled=true', - '--xpack.observability.unsafe.thresholdRule.enabled=true', ], // load tests in the index file testFiles: [require.resolve('./index.feature_flags.ts')],