diff --git a/docs/settings/alert-action-settings.asciidoc b/docs/settings/alert-action-settings.asciidoc index 51fa0b71f9601..3d15c3cc5e368 100644 --- a/docs/settings/alert-action-settings.asciidoc +++ b/docs/settings/alert-action-settings.asciidoc @@ -198,24 +198,26 @@ For example, `20m`, `24h`, `7d`. Default: `1m`. `xpack.alerting.rules.minimumScheduleInterval.enforce`:: Specifies the behavior when a new or changed rule has a schedule interval less than the value defined in `xpack.alerting.rules.minimumScheduleInterval.value`. If `false`, rules with schedules less than the interval will be created but warnings will be logged. If `true`, rules with schedules less than the interval cannot be created. Default: `false`. -`xpack.alerting.rules.execution.actions.max`:: +`xpack.alerting.rules.run.actions.max`:: Specifies the maximum number of actions that a rule can trigger each time detection checks run. -`xpack.alerting.rules.execution.timeout`:: +`xpack.alerting.rules.run.timeout`:: Specifies the default timeout for tasks associated with all types of rules. The time is formatted as: + `[ms,s,m,h,d,w,M,Y]` + For example, `20m`, `24h`, `7d`, `1w`. Default: `5m`. -`xpack.alerting.rules.execution.ruleTypeOverrides`:: -Overrides the configs under `xpack.alerting.rules.execution` for the rule type with the given ID. List the rule identifier and its settings in an array of objects. +`xpack.alerting.rules.run.ruleTypeOverrides`:: +Overrides the configs under `xpack.alerting.rules.run` for the rule type with the given ID. List the rule identifier and its settings in an array of objects. + +-- For example: ``` -xpack.alerting.rules.execution: +xpack.alerting.rules.run: timeout: '5m' ruleTypeOverrides: - id: '.index-threshold' timeout: '15m' -``` \ No newline at end of file +``` +-- \ No newline at end of file diff --git a/docs/user/alerting/troubleshooting/alerting-common-issues.asciidoc b/docs/user/alerting/troubleshooting/alerting-common-issues.asciidoc index 4bd06284d8d6c..7ab34dacacd98 100644 --- a/docs/user/alerting/troubleshooting/alerting-common-issues.asciidoc +++ b/docs/user/alerting/troubleshooting/alerting-common-issues.asciidoc @@ -85,7 +85,7 @@ and in the <>: [role="screenshot"] image::images/rule-details-timeout-error.png[Rule details page with timeout error] -If you want your rules to run longer, update the `xpack.alerting.rules.execution.timeout` configuration in your <>. You can also target a specific rule type by using `xpack.alerting.rules.execution.ruleTypeOverrides`. +If you want your rules to run longer, update the `xpack.alerting.rules.run.timeout` configuration in your <>. You can also target a specific rule type by using `xpack.alerting.rules.run.ruleTypeOverrides`. Rules that consistently run longer than their <> may produce unexpected results. If the average run duration, visible on the <>, is greater than the check interval, consider increasing the check interval. diff --git a/x-pack/plugins/alerting/server/config.test.ts b/x-pack/plugins/alerting/server/config.test.ts index b08145219c24b..f3298fe16a694 100644 --- a/x-pack/plugins/alerting/server/config.test.ts +++ b/x-pack/plugins/alerting/server/config.test.ts @@ -22,15 +22,15 @@ describe('config validation', () => { }, "maxEphemeralActionsPerAlert": 10, "rules": Object { - "execution": Object { - "actions": Object { - "max": 100000, - }, - }, "minimumScheduleInterval": Object { "enforce": false, "value": "1m", }, + "run": Object { + "actions": Object { + "max": 100000, + }, + }, }, } `); diff --git a/x-pack/plugins/alerting/server/config.ts b/x-pack/plugins/alerting/server/config.ts index c727c137aa9a2..8819a6c1e6211 100644 --- a/x-pack/plugins/alerting/server/config.ts +++ b/x-pack/plugins/alerting/server/config.ts @@ -21,7 +21,7 @@ const rulesSchema = schema.object({ }), enforce: schema.boolean({ defaultValue: false }), // if enforce is false, only warnings will be shown }), - execution: schema.object({ + run: schema.object({ timeout: schema.maybe(schema.string({ validate: validateDurationSchema })), actions: schema.object({ max: schema.number({ defaultValue: 100000 }), diff --git a/x-pack/plugins/alerting/server/index.ts b/x-pack/plugins/alerting/server/index.ts index b44df6c3d1c86..dafcf463b00c7 100644 --- a/x-pack/plugins/alerting/server/index.ts +++ b/x-pack/plugins/alerting/server/index.ts @@ -60,12 +60,8 @@ export const config: PluginConfigDescriptor = { 'xpack.alerting.invalidateApiKeysTask.removalDelay', { level: 'warning' } ), - renameFromRoot( - 'xpack.alerting.defaultRuleTaskTimeout', - 'xpack.alerting.rules.execution.timeout', - { - level: 'warning', - } - ), + renameFromRoot('xpack.alerting.defaultRuleTaskTimeout', 'xpack.alerting.rules.run.timeout', { + level: 'warning', + }), ], }; diff --git a/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.test.ts b/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.test.ts index 6a41d5068682d..9336c380c1742 100644 --- a/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.test.ts +++ b/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.test.ts @@ -14,7 +14,7 @@ const config = { value: '2m', enforce: false, }, - execution: { + run: { timeout: '1m', actions: { max: 1000 }, }, @@ -22,8 +22,8 @@ const config = { const configWithRuleType = { ...config, - execution: { - ...config.execution, + run: { + ...config.run, ruleTypeOverrides: [ { id: ruleTypeId, @@ -35,7 +35,7 @@ const configWithRuleType = { const configWithoutTimeout = { ...config, - execution: { + run: { actions: { max: 1000 }, }, }; diff --git a/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.ts b/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.ts index abb6c6e971711..e6721d65e309f 100644 --- a/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.ts +++ b/x-pack/plugins/alerting/server/lib/get_rule_task_timeout.ts @@ -18,7 +18,7 @@ export const getRuleTaskTimeout = ({ ruleTaskTimeout?: string; ruleTypeId: string; }): string => { - const ruleTypeConfig = config.execution.ruleTypeOverrides?.find( + const ruleTypeConfig = config.run.ruleTypeOverrides?.find( (ruleType) => ruleTypeId === ruleType.id ); @@ -27,9 +27,6 @@ export const getRuleTaskTimeout = ({ // if not, ruleTaskTimeout is applied that is passed from the rule type registering plugin // if none of above is set, DEFAULT_EXECUTION_TIMEOUT is applied return ( - ruleTypeConfig?.timeout || - config.execution.timeout || - ruleTaskTimeout || - DEFAULT_EXECUTION_TIMEOUT + ruleTypeConfig?.timeout || config.run.timeout || ruleTaskTimeout || DEFAULT_EXECUTION_TIMEOUT ); }; diff --git a/x-pack/plugins/alerting/server/lib/get_rules_config.test.ts b/x-pack/plugins/alerting/server/lib/get_rules_config.test.ts index e8956bd065038..e6477945eebda 100644 --- a/x-pack/plugins/alerting/server/lib/get_rules_config.test.ts +++ b/x-pack/plugins/alerting/server/lib/get_rules_config.test.ts @@ -14,7 +14,7 @@ const config = { value: '2m', enforce: false, }, - execution: { + run: { timeout: '1m', actions: { max: 1000 }, }, @@ -22,8 +22,8 @@ const config = { const configWithRuleType = { ...config, - execution: { - ...config.execution, + run: { + ...config.run, ruleTypeOverrides: [ { id: ruleTypeId, @@ -36,7 +36,7 @@ const configWithRuleType = { describe('get rules config', () => { test('returns the rule type specific config and keeps the default values that are not overwritten', () => { expect(getExecutionConfigForRuleType({ config: configWithRuleType, ruleTypeId })).toEqual({ - execution: { + run: { id: ruleTypeId, timeout: '1m', actions: { max: 20 }, @@ -46,7 +46,7 @@ describe('get rules config', () => { test('returns the default config when there is no rule type specific config', () => { expect(getExecutionConfigForRuleType({ config, ruleTypeId })).toEqual({ - execution: config.execution, + run: config.run, }); }); }); diff --git a/x-pack/plugins/alerting/server/lib/get_rules_config.ts b/x-pack/plugins/alerting/server/lib/get_rules_config.ts index 12f75254a5656..14d3bdc36285f 100644 --- a/x-pack/plugins/alerting/server/lib/get_rules_config.ts +++ b/x-pack/plugins/alerting/server/lib/get_rules_config.ts @@ -15,13 +15,13 @@ export const getExecutionConfigForRuleType = ({ config: RulesConfig; ruleTypeId: string; }): RuleTypeConfig => { - const ruleTypeExecutionConfig = config.execution.ruleTypeOverrides?.find( + const ruleTypeExecutionConfig = config.run.ruleTypeOverrides?.find( (ruleType) => ruleType.id === ruleTypeId ); return { - execution: { - ...omit(config.execution, 'ruleTypeOverrides'), + run: { + ...omit(config.run, 'ruleTypeOverrides'), ...ruleTypeExecutionConfig, }, }; diff --git a/x-pack/plugins/alerting/server/plugin.test.ts b/x-pack/plugins/alerting/server/plugin.test.ts index 450c177d72473..b45fbbf6a5e27 100644 --- a/x-pack/plugins/alerting/server/plugin.test.ts +++ b/x-pack/plugins/alerting/server/plugin.test.ts @@ -33,7 +33,7 @@ const generateAlertingConfig = (): AlertingConfig => ({ cancelAlertsOnRuleTimeout: true, rules: { minimumScheduleInterval: { value: '1m', enforce: false }, - execution: { + run: { actions: { max: 1000, }, @@ -50,7 +50,7 @@ const sampleRuleType: RuleType = { defaultActionGroupId: 'default', producer: 'test', config: { - execution: { + run: { actions: { max: 1000, }, @@ -126,7 +126,7 @@ describe('Alerting Plugin', () => { ...generateAlertingConfig(), rules: { minimumScheduleInterval: { value: '1m', enforce: false }, - execution: { + run: { actions: { max: 123, }, @@ -141,7 +141,7 @@ describe('Alerting Plugin', () => { setupContract.registerType(ruleType); expect(ruleType.config).toEqual({ - execution: { + run: { actions: { max: 123 }, }, }); @@ -152,7 +152,7 @@ describe('Alerting Plugin', () => { ...generateAlertingConfig(), rules: { minimumScheduleInterval: { value: '1m', enforce: false }, - execution: { + run: { actions: { max: 123 }, ruleTypeOverrides: [{ id: sampleRuleType.id, timeout: '1d' }], }, @@ -166,7 +166,7 @@ describe('Alerting Plugin', () => { setupContract.registerType(ruleType); expect(ruleType.config).toEqual({ - execution: { + run: { id: sampleRuleType.id, actions: { max: 123, diff --git a/x-pack/plugins/alerting/server/rule_type_registry.test.ts b/x-pack/plugins/alerting/server/rule_type_registry.test.ts index f4102a2bc6227..ec4c64d88727a 100644 --- a/x-pack/plugins/alerting/server/rule_type_registry.test.ts +++ b/x-pack/plugins/alerting/server/rule_type_registry.test.ts @@ -61,7 +61,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -87,7 +87,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -125,7 +125,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -154,7 +154,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -186,7 +186,7 @@ describe('Create Lifecycle', () => { producer: 'alerts', defaultScheduleInterval: 'foobar', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -279,7 +279,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -313,7 +313,7 @@ describe('Create Lifecycle', () => { minimumLicenseRequired: 'basic', isExportable: true, config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -351,7 +351,7 @@ describe('Create Lifecycle', () => { minimumLicenseRequired: 'basic', isExportable: true, config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -393,7 +393,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -424,7 +424,7 @@ describe('Create Lifecycle', () => { producer: 'alerts', ruleTaskTimeout: '20m', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -461,7 +461,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -489,7 +489,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -510,7 +510,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -537,7 +537,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -561,7 +561,7 @@ describe('Create Lifecycle', () => { "state": Array [], }, "config": Object { - "execution": Object { + "run": Object { "actions": Object { "max": 1000, }, @@ -616,7 +616,7 @@ describe('Create Lifecycle', () => { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -715,7 +715,7 @@ describe('Create Lifecycle', () => { minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -753,7 +753,7 @@ function ruleTypeWithVariables( async executor() {}, producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, diff --git a/x-pack/plugins/alerting/server/rules_client/tests/create.test.ts b/x-pack/plugins/alerting/server/rules_client/tests/create.test.ts index 8a9cd1d4acc7f..6fef97c1699c5 100644 --- a/x-pack/plugins/alerting/server/rules_client/tests/create.test.ts +++ b/x-pack/plugins/alerting/server/rules_client/tests/create.test.ts @@ -1167,7 +1167,7 @@ describe('create()', () => { injectReferences: injectReferencesFn, }, config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -1340,7 +1340,7 @@ describe('create()', () => { injectReferences: injectReferencesFn, }, config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -2099,7 +2099,7 @@ describe('create()', () => { async executor() {}, producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -2629,7 +2629,7 @@ describe('create()', () => { injectReferences: jest.fn(), }, config: { - execution: { + run: { actions: { max: 1000 }, }, }, diff --git a/x-pack/plugins/alerting/server/rules_client/tests/lib.ts b/x-pack/plugins/alerting/server/rules_client/tests/lib.ts index 489dbb27b9e18..c432dc73df8bb 100644 --- a/x-pack/plugins/alerting/server/rules_client/tests/lib.ts +++ b/x-pack/plugins/alerting/server/rules_client/tests/lib.ts @@ -92,7 +92,7 @@ export function getBeforeSetup( async executor() {}, producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, diff --git a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts index 8b97bf9266e9a..8c93ae63bde49 100644 --- a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts @@ -54,7 +54,7 @@ const ruleType: NormalizedRuleType< executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -481,7 +481,7 @@ describe('Create Execution Handler', () => { ruleType: { ...ruleType, config: { - execution: { + run: { actions: { max: 2 }, }, }, diff --git a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts index 56e1a25cb0655..d37d592c68618 100644 --- a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts +++ b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts @@ -120,7 +120,7 @@ export function createExecutionHandler< let ephemeralActionsToSchedule = maxEphemeralActionsPerRule; for (const action of actions) { - if (alertExecutionStore.numberOfTriggeredActions >= ruleType.config!.execution.actions.max) { + if (alertExecutionStore.numberOfTriggeredActions >= ruleType.config!.run.actions.max) { alertExecutionStore.triggeredActionsStatus = ActionsCompletion.PARTIAL; break; } diff --git a/x-pack/plugins/alerting/server/task_runner/fixtures.ts b/x-pack/plugins/alerting/server/task_runner/fixtures.ts index 1c8e1776a523f..653a56646b528 100644 --- a/x-pack/plugins/alerting/server/task_runner/fixtures.ts +++ b/x-pack/plugins/alerting/server/task_runner/fixtures.ts @@ -109,7 +109,7 @@ export const ruleType: jest.Mocked = { executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts index 3eed02bb10e31..3cbc4f1cca544 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts @@ -2642,7 +2642,7 @@ describe('Task Runner', () => { const ruleTypeWithConfig = { ...ruleType, config: { - execution: { + run: { actions: { max: 3 }, }, }, @@ -2715,7 +2715,7 @@ describe('Task Runner', () => { const runnerResult = await taskRunner.run(); expect(actionsClient.enqueueExecution).toHaveBeenCalledTimes( - ruleTypeWithConfig.config.execution.actions.max + ruleTypeWithConfig.config.run.actions.max ); expect( @@ -2815,7 +2815,7 @@ describe('Task Runner', () => { action: EVENT_LOG_ACTIONS.execute, outcome: 'success', status: 'warning', - numberOfTriggeredActions: ruleTypeWithConfig.config.execution.actions.max, + numberOfTriggeredActions: ruleTypeWithConfig.config.run.actions.max, numberOfScheduledActions: mockActions.length, reason: AlertExecutionStatusWarningReasons.MAX_EXECUTABLE_ACTIONS, task: true, diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner_cancel.test.ts b/x-pack/plugins/alerting/server/task_runner/task_runner_cancel.test.ts index 39d2aa8418394..cb504630fb12d 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner_cancel.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner_cancel.test.ts @@ -57,7 +57,7 @@ const ruleType: jest.Mocked = { cancelAlertsOnRuleTimeout: true, ruleTaskTimeout: '5m', config: { - execution: { + run: { actions: { max: 1000 }, }, },