From a4b0098ee8ef00da70880999bf6b04b535e68931 Mon Sep 17 00:00:00 2001 From: Ersin Erdal Date: Wed, 13 Apr 2022 20:09:49 +0200 Subject: [PATCH] Rename the term "execution" in config to "run" --- docs/settings/alert-action-settings.asciidoc | 8 ++--- .../alerting-common-issues.asciidoc | 2 +- x-pack/plugins/alerting/server/config.test.ts | 10 +++--- x-pack/plugins/alerting/server/config.ts | 2 +- x-pack/plugins/alerting/server/index.ts | 10 ++---- .../server/lib/get_rule_task_timeout.test.ts | 8 ++--- .../server/lib/get_rules_config.test.ts | 10 +++--- x-pack/plugins/alerting/server/plugin.test.ts | 12 +++---- .../server/rule_type_registry.test.ts | 36 +++++++++---------- .../server/rules_client/tests/create.test.ts | 8 ++--- .../alerting/server/rules_client/tests/lib.ts | 2 +- .../create_execution_handler.test.ts | 4 +-- .../task_runner/create_execution_handler.ts | 2 +- .../alerting/server/task_runner/fixtures.ts | 2 +- .../server/task_runner/task_runner.test.ts | 6 ++-- .../task_runner/task_runner_cancel.test.ts | 2 +- 16 files changed, 60 insertions(+), 64 deletions(-) diff --git a/docs/settings/alert-action-settings.asciidoc b/docs/settings/alert-action-settings.asciidoc index 51fa0b71f9601..53a9eccd36805 100644 --- a/docs/settings/alert-action-settings.asciidoc +++ b/docs/settings/alert-action-settings.asciidoc @@ -198,22 +198,22 @@ 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`:: +`xpack.alerting.rules.run.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. + For example: ``` -xpack.alerting.rules.execution: +xpack.alerting.rules.run: timeout: '5m' ruleTypeOverrides: - id: '.index-threshold' diff --git a/docs/user/alerting/troubleshooting/alerting-common-issues.asciidoc b/docs/user/alerting/troubleshooting/alerting-common-issues.asciidoc index 4bd06284d8d6c..01b461752c5ff 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.execution.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 f73fb7f964b25..bba7d76bc401c 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_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/plugin.test.ts b/x-pack/plugins/alerting/server/plugin.test.ts index 8eb73aa25954b..8446f07914d0d 100644 --- a/x-pack/plugins/alerting/server/plugin.test.ts +++ b/x-pack/plugins/alerting/server/plugin.test.ts @@ -34,7 +34,7 @@ const generateAlertingConfig = (): AlertingConfig => ({ cancelAlertsOnRuleTimeout: true, rules: { minimumScheduleInterval: { value: '1m', enforce: false }, - execution: { + run: { actions: { max: 1000, }, @@ -51,7 +51,7 @@ const sampleRuleType: RuleType = { defaultActionGroupId: 'default', producer: 'test', config: { - execution: { + run: { actions: { max: 1000, }, @@ -127,7 +127,7 @@ describe('Alerting Plugin', () => { ...generateAlertingConfig(), rules: { minimumScheduleInterval: { value: '1m', enforce: false }, - execution: { + run: { actions: { max: 123, }, @@ -142,7 +142,7 @@ describe('Alerting Plugin', () => { setupContract.registerType(ruleType); expect(ruleType.config).toEqual({ - execution: { + run: { actions: { max: 123 }, }, }); @@ -153,7 +153,7 @@ describe('Alerting Plugin', () => { ...generateAlertingConfig(), rules: { minimumScheduleInterval: { value: '1m', enforce: false }, - execution: { + run: { actions: { max: 123 }, ruleTypeOverrides: [{ id: sampleRuleType.id, timeout: '1d' }], }, @@ -167,7 +167,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 af0220ccba987..69d0f0bf91d62 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 @@ -49,7 +49,7 @@ const ruleType: NormalizedRuleType< executor: jest.fn(), producer: 'alerts', config: { - execution: { + run: { actions: { max: 1000 }, }, }, @@ -476,7 +476,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 7752817f17c85..fa6b81bc88b07 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 @@ -115,7 +115,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 613f3ed9e1645..68d69f238ced1 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 21109b60e012d..30f6a9c56303d 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 @@ -2645,7 +2645,7 @@ describe('Task Runner', () => { const ruleTypeWithConfig = { ...ruleType, config: { - execution: { + run: { actions: { max: 3 }, }, }, @@ -2718,7 +2718,7 @@ describe('Task Runner', () => { const runnerResult = await taskRunner.run(); expect(actionsClient.enqueueExecution).toHaveBeenCalledTimes( - ruleTypeWithConfig.config.execution.actions.max + ruleTypeWithConfig.config.run.actions.max ); expect( @@ -2818,7 +2818,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: RuleExecutionStatusWarningReasons.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 1e24ac986f015..74963f952e4c6 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 @@ -58,7 +58,7 @@ const ruleType: jest.Mocked = { cancelAlertsOnRuleTimeout: true, ruleTaskTimeout: '5m', config: { - execution: { + run: { actions: { max: 1000 }, }, },