Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the term "execution" in config to "run" #130172

Merged
merged 6 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
+
`<count>[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'
```
```
--
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ and in the <<rule-details,details page>>:
[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 <<alert-settings>>. 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 <<alert-settings>>. You can also target a specific rule type by using `xpack.alerting.rules.run.ruleTypeOverrides`.

Rules that consistently run longer than their <<create-edit-rules, check interval>> may produce unexpected results. If the average run duration, visible on the <<rule-details,details page>>, is greater than the check interval, consider increasing the check interval.

Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/alerting/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
}
`);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
10 changes: 3 additions & 7 deletions x-pack/plugins/alerting/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ export const config: PluginConfigDescriptor<AlertsConfigType> = {
'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',
}),
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const config = {
value: '2m',
enforce: false,
},
execution: {
run: {
timeout: '1m',
actions: { max: 1000 },
},
} as RulesConfig;

const configWithRuleType = {
...config,
execution: {
...config.execution,
run: {
...config.run,
ruleTypeOverrides: [
{
id: ruleTypeId,
Expand All @@ -35,7 +35,7 @@ const configWithRuleType = {

const configWithoutTimeout = {
...config,
execution: {
run: {
actions: { max: 1000 },
},
};
Expand Down
7 changes: 2 additions & 5 deletions x-pack/plugins/alerting/server/lib/get_rule_task_timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand All @@ -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
);
};
10 changes: 5 additions & 5 deletions x-pack/plugins/alerting/server/lib/get_rules_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const config = {
value: '2m',
enforce: false,
},
execution: {
run: {
timeout: '1m',
actions: { max: 1000 },
},
} as RulesConfig;

const configWithRuleType = {
...config,
execution: {
...config.execution,
run: {
...config.run,
ruleTypeOverrides: [
{
id: ruleTypeId,
Expand All @@ -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 },
Expand All @@ -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,
});
});
});
6 changes: 3 additions & 3 deletions x-pack/plugins/alerting/server/lib/get_rules_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/alerting/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const generateAlertingConfig = (): AlertingConfig => ({
cancelAlertsOnRuleTimeout: true,
rules: {
minimumScheduleInterval: { value: '1m', enforce: false },
execution: {
run: {
actions: {
max: 1000,
},
Expand All @@ -51,7 +51,7 @@ const sampleRuleType: RuleType<never, never, never, never, never, 'default'> = {
defaultActionGroupId: 'default',
producer: 'test',
config: {
execution: {
run: {
actions: {
max: 1000,
},
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('Alerting Plugin', () => {
...generateAlertingConfig(),
rules: {
minimumScheduleInterval: { value: '1m', enforce: false },
execution: {
run: {
actions: {
max: 123,
},
Expand All @@ -142,7 +142,7 @@ describe('Alerting Plugin', () => {
setupContract.registerType(ruleType);

expect(ruleType.config).toEqual({
execution: {
run: {
actions: { max: 123 },
},
});
Expand All @@ -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' }],
},
Expand All @@ -167,7 +167,7 @@ describe('Alerting Plugin', () => {
setupContract.registerType(ruleType);

expect(ruleType.config).toEqual({
execution: {
run: {
id: sampleRuleType.id,
actions: {
max: 123,
Expand Down
Loading