[Alerting] Alerting v2: Refactor rule executor to use a pipeline pattern#250161
Merged
cnasikas merged 10 commits intoelastic:alerting_v2from Jan 28, 2026
Merged
[Alerting] Alerting v2: Refactor rule executor to use a pipeline pattern#250161cnasikas merged 10 commits intoelastic:alerting_v2from
cnasikas merged 10 commits intoelastic:alerting_v2from
Conversation
2ebbe33 to
a3cc724
Compare
Contributor
|
Pinging @elastic/response-ops (Team:ResponseOps) |
darnautov
reviewed
Jan 26, 2026
Comment on lines
+123
to
+147
| bind(WaitForResourcesStep).toSelf().inSingletonScope(); | ||
| bind(FetchRuleStep).toSelf().inRequestScope(); | ||
| bind(ValidateRuleStep).toSelf().inSingletonScope(); | ||
| bind(BuildQueryStep).toSelf().inSingletonScope(); | ||
| bind(ExecuteQueryStep).toSelf().inRequestScope(); | ||
| bind(BuildAlertsStep).toSelf().inSingletonScope(); | ||
| bind(StoreAlertsStep).toSelf().inSingletonScope(); | ||
|
|
||
| /** | ||
| * Bind steps array (order defines execution order) | ||
| * Steps can be wrapped with decorators for per-step behavior | ||
| * For example: new AuditLoggingDecorator(get(ValidateRuleStep), auditService) | ||
| */ | ||
|
|
||
| bind(RuleExecutionStepsToken) | ||
| .toDynamicValue(({ get }) => [ | ||
| get(WaitForResourcesStep), | ||
| get(FetchRuleStep), | ||
| get(ValidateRuleStep), | ||
| get(BuildQueryStep), | ||
| get(ExecuteQueryStep), | ||
| get(BuildAlertsStep), | ||
| get(StoreAlertsStep), | ||
| ]) | ||
| .inRequestScope(); |
Contributor
There was a problem hiding this comment.
Would it be possible to refactor to use ServiceIdentifier similar to Route, to get easier setup?
bind(ExecutorStep).toConstantValue(WaitForResourcesStep)
darnautov
reviewed
Jan 26, 2026
...ins/shared/alerting_v2/server/lib/rule_executor/middleware/error_handling_middleware.test.ts
Outdated
Show resolved
Hide resolved
| * Use decorators when you need per-step control without adding conditionals | ||
| * to middleware. | ||
| */ | ||
| export abstract class RuleStepDecorator implements RuleExecutionStep { |
Member
Author
There was a problem hiding this comment.
Not yet. It is an abstract class that can be used to create decorators. I can remove it and implement it when we need a decorator. What do you prefer?
...platform/plugins/shared/alerting_v2/server/lib/rule_executor/steps/build_alerts_step.test.ts
Outdated
Show resolved
Hide resolved
...platform/plugins/shared/alerting_v2/server/lib/rule_executor/steps/build_alerts_step.test.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/alerting_v2/server/lib/rule_executor/steps/build_alerts_step.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/alerting_v2/server/lib/rule_executor/execution_pipeline.ts
Show resolved
Hide resolved
x-pack/platform/plugins/shared/alerting_v2/server/lib/test_utils.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/alerting_v2/server/lib/test_utils.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/alerting_v2/server/lib/test_utils.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/alerting_v2/server/setup/bind_services.ts
Outdated
Show resolved
Hide resolved
Contributor
💔 Build Failed
Failed CI StepsHistory
cc @cnasikas |
This was referenced Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the rule executor to use a pipeline pattern. This will help us work in parallel, isolate piece of code, easier testing, and avoid touching the core logic of the executor in the future. More details in the README.md file.
Fixes: https://github.com/elastic/rna-program/issues/75
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.