From a6c4120b35eb80581242ea8c375c31c1909f0fbe Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Wed, 21 Aug 2024 10:17:29 -0400 Subject: [PATCH] [Response Ops][Alerting] Adding new value to warning reasons enum schema in rule saved object (#190743) ## Summary We want to allow rule executors to report warnings back to the framework and have them show up in the stack management UI. We currently have a mechanism for this that is used by detection rules but they handle how to show the warning in their custom UI so the warning does not appear in the stack management UI. This PR adds a new value to the allow list of "warning reasons". This should not warrant a schema version bump because it is a new value for an existing enum but we need to do an intermediate release so the new schema is recognized before we start setting it anywhere. This PR is just for schema changes. PR that uses these schema changes can be found here: https://github.com/elastic/kibana/pull/189312 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine --- oas_docs/bundle.json | 36 ++++++++++++------- oas_docs/bundle.serverless.json | 36 ++++++++++++------- packages/kbn-alerting-types/rule_types.ts | 1 + packages/kbn-config-schema/index.ts | 17 +++++++++ .../common/routes/rule/common/constants/v1.ts | 1 + .../common/routes/rule/response/schemas/v1.ts | 2 ++ .../server/application/rule/constants.ts | 1 + .../application/rule/schemas/rule_schemas.ts | 2 ++ .../alerting/server/data/rule/constants.ts | 1 + .../saved_objects/schemas/raw_rule/v1.ts | 1 + .../sections/rules_list/translations.ts | 8 +++++ 11 files changed, 82 insertions(+), 24 deletions(-) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index fbf194c8491a2c..1f5b3e095ea7ac 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -713,7 +713,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -804,7 +805,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -922,7 +924,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -1897,7 +1900,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -1988,7 +1992,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -2106,7 +2111,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -3064,7 +3070,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -3155,7 +3162,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -3273,7 +3281,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -4467,7 +4476,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -4558,7 +4568,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -4676,7 +4687,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index fbf194c8491a2c..1f5b3e095ea7ac 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -713,7 +713,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -804,7 +805,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -922,7 +924,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -1897,7 +1900,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -1988,7 +1992,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -2106,7 +2111,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -3064,7 +3070,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -3155,7 +3162,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -3273,7 +3281,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -4467,7 +4476,8 @@ "enum": [ "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "type": "string" } @@ -4558,7 +4568,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" @@ -4676,7 +4687,8 @@ "validate", "maxExecutableActions", "maxAlerts", - "maxQueuedActions" + "maxQueuedActions", + "ruleExecution" ], "nullable": true, "type": "string" diff --git a/packages/kbn-alerting-types/rule_types.ts b/packages/kbn-alerting-types/rule_types.ts index cb72d3bfd4c5ea..5387144ed63453 100644 --- a/packages/kbn-alerting-types/rule_types.ts +++ b/packages/kbn-alerting-types/rule_types.ts @@ -102,6 +102,7 @@ export enum RuleExecutionStatusWarningReasons { MAX_EXECUTABLE_ACTIONS = 'maxExecutableActions', MAX_ALERTS = 'maxAlerts', MAX_QUEUED_ACTIONS = 'maxQueuedActions', + EXECUTION = 'ruleExecution', } export type RuleExecutionStatuses = (typeof RuleExecutionStatusValues)[number]; diff --git a/packages/kbn-config-schema/index.ts b/packages/kbn-config-schema/index.ts index e0adf545f454fc..32fd90cf4713c6 100644 --- a/packages/kbn-config-schema/index.ts +++ b/packages/kbn-config-schema/index.ts @@ -146,6 +146,23 @@ function recordOf( return new RecordOfType(keyType, valueType, options); } +function oneOf( + types: [ + Type, + Type, + Type, + Type, + Type, + Type, + Type, + Type, + Type, + Type, + Type, + Type + ], + options?: UnionTypeOptions +): Type; function oneOf( types: [ Type, diff --git a/x-pack/plugins/alerting/common/routes/rule/common/constants/v1.ts b/x-pack/plugins/alerting/common/routes/rule/common/constants/v1.ts index 745b0937922cbd..f0d41ebf72f3f7 100644 --- a/x-pack/plugins/alerting/common/routes/rule/common/constants/v1.ts +++ b/x-pack/plugins/alerting/common/routes/rule/common/constants/v1.ts @@ -41,6 +41,7 @@ export const ruleExecutionStatusWarningReason = { MAX_EXECUTABLE_ACTIONS: 'maxExecutableActions', MAX_ALERTS: 'maxAlerts', MAX_QUEUED_ACTIONS: 'maxQueuedActions', + EXECUTION: 'ruleExecution', } as const; export type RuleNotifyWhen = (typeof ruleNotifyWhen)[keyof typeof ruleNotifyWhen]; diff --git a/x-pack/plugins/alerting/common/routes/rule/response/schemas/v1.ts b/x-pack/plugins/alerting/common/routes/rule/response/schemas/v1.ts index c513a0c53c693f..e8c91d649b8c2f 100644 --- a/x-pack/plugins/alerting/common/routes/rule/response/schemas/v1.ts +++ b/x-pack/plugins/alerting/common/routes/rule/response/schemas/v1.ts @@ -208,6 +208,7 @@ export const ruleExecutionStatusSchema = schema.object({ schema.literal(ruleExecutionStatusWarningReasonV1.MAX_EXECUTABLE_ACTIONS), schema.literal(ruleExecutionStatusWarningReasonV1.MAX_ALERTS), schema.literal(ruleExecutionStatusWarningReasonV1.MAX_QUEUED_ACTIONS), + schema.literal(ruleExecutionStatusWarningReasonV1.EXECUTION), ], { meta: { @@ -260,6 +261,7 @@ export const ruleLastRunSchema = schema.object({ schema.literal(ruleExecutionStatusWarningReasonV1.MAX_EXECUTABLE_ACTIONS), schema.literal(ruleExecutionStatusWarningReasonV1.MAX_ALERTS), schema.literal(ruleExecutionStatusWarningReasonV1.MAX_QUEUED_ACTIONS), + schema.literal(ruleExecutionStatusWarningReasonV1.EXECUTION), ], { meta: { diff --git a/x-pack/plugins/alerting/server/application/rule/constants.ts b/x-pack/plugins/alerting/server/application/rule/constants.ts index bc75d91375ecbf..ea7504a4d3a8ac 100644 --- a/x-pack/plugins/alerting/server/application/rule/constants.ts +++ b/x-pack/plugins/alerting/server/application/rule/constants.ts @@ -41,4 +41,5 @@ export const ruleExecutionStatusWarningReason = { MAX_EXECUTABLE_ACTIONS: 'maxExecutableActions', MAX_ALERTS: 'maxAlerts', MAX_QUEUED_ACTIONS: 'maxQueuedActions', + EXECUTION: 'ruleExecution', } as const; diff --git a/x-pack/plugins/alerting/server/application/rule/schemas/rule_schemas.ts b/x-pack/plugins/alerting/server/application/rule/schemas/rule_schemas.ts index cd3b4652449767..416fdc4d11c0d0 100644 --- a/x-pack/plugins/alerting/server/application/rule/schemas/rule_schemas.ts +++ b/x-pack/plugins/alerting/server/application/rule/schemas/rule_schemas.ts @@ -56,6 +56,7 @@ export const ruleExecutionStatusSchema = schema.object({ schema.literal(ruleExecutionStatusWarningReason.MAX_EXECUTABLE_ACTIONS), schema.literal(ruleExecutionStatusWarningReason.MAX_ALERTS), schema.literal(ruleExecutionStatusWarningReason.MAX_QUEUED_ACTIONS), + schema.literal(ruleExecutionStatusWarningReason.EXECUTION), ]), message: schema.string(), }) @@ -83,6 +84,7 @@ export const ruleLastRunSchema = schema.object({ schema.literal(ruleExecutionStatusWarningReason.MAX_EXECUTABLE_ACTIONS), schema.literal(ruleExecutionStatusWarningReason.MAX_ALERTS), schema.literal(ruleExecutionStatusWarningReason.MAX_QUEUED_ACTIONS), + schema.literal(ruleExecutionStatusWarningReason.EXECUTION), ]) ) ), diff --git a/x-pack/plugins/alerting/server/data/rule/constants.ts b/x-pack/plugins/alerting/server/data/rule/constants.ts index 267864bdfd9e8c..d3580ffbb242b3 100644 --- a/x-pack/plugins/alerting/server/data/rule/constants.ts +++ b/x-pack/plugins/alerting/server/data/rule/constants.ts @@ -41,4 +41,5 @@ export const ruleExecutionStatusWarningReasonAttributes = { MAX_EXECUTABLE_ACTIONS: 'maxExecutableActions', MAX_ALERTS: 'maxAlerts', MAX_QUEUED_ACTIONS: 'maxQueuedActions', + EXECUTION: 'ruleExecution', } as const; diff --git a/x-pack/plugins/alerting/server/saved_objects/schemas/raw_rule/v1.ts b/x-pack/plugins/alerting/server/saved_objects/schemas/raw_rule/v1.ts index caa5f47a959f14..cc4d9311f82942 100644 --- a/x-pack/plugins/alerting/server/saved_objects/schemas/raw_rule/v1.ts +++ b/x-pack/plugins/alerting/server/saved_objects/schemas/raw_rule/v1.ts @@ -11,6 +11,7 @@ const executionStatusWarningReason = schema.oneOf([ schema.literal('maxExecutableActions'), schema.literal('maxAlerts'), schema.literal('maxQueuedActions'), + schema.literal('ruleExecution'), ]); const executionStatusErrorReason = schema.oneOf([ diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/translations.ts b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/translations.ts index 98daed5951399b..37857dac9b8296 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/translations.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/translations.ts @@ -175,6 +175,13 @@ export const ALERT_WARNING_UNKNOWN_REASON = i18n.translate( } ); +export const ALERT_WARNING_EXECUTION_REASON = i18n.translate( + 'xpack.triggersActionsUI.sections.rulesList.ruleWarningReasonExecution', + { + defaultMessage: 'Rule execution warning', + } +); + export const rulesErrorReasonTranslationsMapping = { read: ALERT_ERROR_READING_REASON, decrypt: ALERT_ERROR_DECRYPTING_REASON, @@ -191,6 +198,7 @@ export const rulesWarningReasonTranslationsMapping = { maxAlerts: ALERT_WARNING_MAX_ALERTS_REASON, maxQueuedActions: ALERT_WARNING_MAX_QUEUED_ACTIONS_REASON, unknown: ALERT_WARNING_UNKNOWN_REASON, + ruleExecution: ALERT_WARNING_EXECUTION_REASON, }; export const SELECT_ALL_ARIA_LABEL = i18n.translate(