Skip to content

Commit

Permalink
[Response Ops][Alerting] Adding new value to warning reasons enum sch…
Browse files Browse the repository at this point in the history
…ema in rule saved object (elastic#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: elastic#189312

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 21, 2024
1 parent bc8cb00 commit a6c4120
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 24 deletions.
36 changes: 24 additions & 12 deletions oas_docs/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -804,7 +805,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -922,7 +924,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -1897,7 +1900,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -1988,7 +1992,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -2106,7 +2111,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -3064,7 +3070,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -3155,7 +3162,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -3273,7 +3281,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -4467,7 +4476,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -4558,7 +4568,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -4676,7 +4687,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down
36 changes: 24 additions & 12 deletions oas_docs/bundle.serverless.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -804,7 +805,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -922,7 +924,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -1897,7 +1900,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -1988,7 +1992,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -2106,7 +2111,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -3064,7 +3070,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -3155,7 +3162,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -3273,7 +3281,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -4467,7 +4476,8 @@
"enum": [
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"type": "string"
}
Expand Down Expand Up @@ -4558,7 +4568,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -4676,7 +4687,8 @@
"validate",
"maxExecutableActions",
"maxAlerts",
"maxQueuedActions"
"maxQueuedActions",
"ruleExecution"
],
"nullable": true,
"type": "string"
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-alerting-types/rule_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
17 changes: 17 additions & 0 deletions packages/kbn-config-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ function recordOf<K extends string, V>(
return new RecordOfType(keyType, valueType, options);
}

function oneOf<A, B, C, D, E, F, G, H, I, J, K, L>(
types: [
Type<A>,
Type<B>,
Type<C>,
Type<D>,
Type<E>,
Type<F>,
Type<G>,
Type<H>,
Type<I>,
Type<J>,
Type<K>,
Type<L>
],
options?: UnionTypeOptions<A | B | C | D | E | F | G | H | I | J | K | L>
): Type<A | B | C | D | E | F | G | H | I | J | K | L>;
function oneOf<A, B, C, D, E, F, G, H, I, J, K>(
types: [
Type<A>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ export const ruleExecutionStatusWarningReason = {
MAX_EXECUTABLE_ACTIONS: 'maxExecutableActions',
MAX_ALERTS: 'maxAlerts',
MAX_QUEUED_ACTIONS: 'maxQueuedActions',
EXECUTION: 'ruleExecution',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
Expand Down Expand Up @@ -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),
])
)
),
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/data/rule/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ export const ruleExecutionStatusWarningReasonAttributes = {
MAX_EXECUTABLE_ACTIONS: 'maxExecutableActions',
MAX_ALERTS: 'maxAlerts',
MAX_QUEUED_ACTIONS: 'maxQueuedActions',
EXECUTION: 'ruleExecution',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const executionStatusWarningReason = schema.oneOf([
schema.literal('maxExecutableActions'),
schema.literal('maxAlerts'),
schema.literal('maxQueuedActions'),
schema.literal('ruleExecution'),
]);

const executionStatusErrorReason = schema.oneOf([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit a6c4120

Please sign in to comment.