-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Alerting] Passing additional rule fields to rule executor #99819
Conversation
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
…ing/pass-all-rule-params
…ing/pass-all-rule-params
These fields all seem safe enough to me. I'm wondering though, if this is basically all the fields in our existing alert structure(s), and so if we should encapsulate these into an And thinking we should ping security / o11y / maps / etc to see if there are other fields they'd want, though I'd guess there's not much more we can provide. Seems like we can add a function test for this. It probably makes sense to add these as additional mustache variables, or at least some of them. I think maybe that's better done as a follow-on issue, although perhaps my point at the top about moving the new properties under a new |
@pmuellr I considered doing this but we are already passing some rule fields like
I have been working with security, but you're right, at this point the only fields we arent' passing in are |
++ to encapsulating the fields in an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for adding in the required fields
FYI @aaronjcaldwell |
…ing/pass-all-rule-params
@pmuellr encapsulated fields into a Updated the functional tests in this commit: 0a9637c |
…ing/pass-all-rule-params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM! Relying on the consumer teams on that we've provided all the needed rule data.
@elasticmachine merge upstream |
@ymao we write the following data from the rule instance to the alert:
The last three are currently not available in the executor, so they need to be manually passed in. If we can add those three as well, we can get all the data we need from the executor, rather than having access to the rule type as well. |
expect(call.rule.producer).toBe('alerts'); | ||
expect(call.rule.ruleTypeId).toBe('test'); | ||
expect(call.rule.ruleTypeName).toBe('My test alert'); | ||
expect(call.rule.actions).toMatchInlineSnapshot(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, interesting! I missed that on my first quick review of this.
Seems like I remember some conversations with @mikecote where we were a little concerned about rules knowing a lot about their context. Some of it just to keep rule executors from having to deal with too much info, but for actions specifically, could we be leaking any info? In theory action secrets are safe in this context, since they aren't passed in here, just the params. But it is possible that someone would embed some secrets in something like a webhook header. Which would then be visible to the alert executor. Update: The case of webhook headers I mentioned isn't valid - webhook headers are part of the connector config, not params, so wouldn't be passed in here. I suspect there is no issue with "leaking secrets".
I'm trying to think of good reason to actually pass the actions in, but failing to come up with one. Thinking maybe we should remove it based on the security aspect. Update: I don't think there's a security issue here (see update above). But still would like to have @mikecote take a peek.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR if we don't have to, it's easier to add later than to remove later. Rule params are designed for the executor, rule object is designed for the framework.
My main concern is passing the actions
enables rule types to change the execution behaviour based on what actions the user has configured. I've been pushing for rule executors to just query and flag things worth alerting on and to let the alerting framework handle the actions (notify every, mapping params, per instance, etc.). This principle facilitates future capabilities like rule simulation, alert summary, alert digest, notify after x amount of times, because of the limited context they know about the rule, forcing things to become params
instead of rule
properties where in the future we could call the rule executor without a rule to run a simulation or something.
I get there are workarounds to uncover the actions
but I prefer hearing use cases before providing such capability to ensure it doesn't harm future platform capabilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed this with @mikecote offline and we are ok with moving forward on this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I have a question about exposing the actions
that I'd like @mikecote to chime in on.
Per other comment I made in the PR, let's open an issue to remove the older top-level vars that are now in rule
(I assume this is straight-forward). I also commented on whether we'd want to expose some new mustache variables for these - not completely sure, but ... let's open an issue for that too; seems like it could be useful.
Issue for removing older top level variables: #100115 |
in regards to how the
|
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @ymao1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
…9819) * Passing additional rule fields to rule executor * Fixing types check * Api docs * Adding enabled and actions * Api docs * Encapsulating rule information into RuleConfig type * Functional tests * Functional tests * Adding producer, ruleTypeId and ruleTypeName * Api docs Co-authored-by: Kibana Machine <[email protected]>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…100462) * Passing additional rule fields to rule executor * Fixing types check * Api docs * Adding enabled and actions * Api docs * Encapsulating rule information into RuleConfig type * Functional tests * Functional tests * Adding producer, ruleTypeId and ruleTypeName * Api docs Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: ymao1 <[email protected]>
…9819) * Passing additional rule fields to rule executor * Fixing types check * Api docs * Adding enabled and actions * Api docs * Encapsulating rule information into RuleConfig type * Functional tests * Functional tests * Adding producer, ruleTypeId and ruleTypeName * Api docs Co-authored-by: Kibana Machine <[email protected]>
Resolves #95843
Summary
Passing additional rule information to the rule executor, encapsulated in a
rule
object:consumer
schedule
createdAt
updatedAt
throttle
notifyWhen
enabled
actions
Checklist