-
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] extend Alert Type with names/descriptions of action variables #59756
Conversation
I didn't realize we already had a property set up for the action variables! kibana/x-pack/plugins/triggers_actions_ui/public/types.ts Lines 74 to 80 in 8bc051a
So, that will need to be changed, and I haven't looked, but I suspect there is already some code that will display them, so I'll fix that up too. We'll need to figure out if we want to display a tooltip for the localized description of them, or display them in some other way. |
There are also a number of "always provided" action variables, by the alerting framework itself, like |
commit #728e8f69eb7e22a3b0875a2b81d20e1abadb3ec4 now displays the variables in the UI context menu |
356604c
to
d6c8457
Compare
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, I have a suggestion regarding empty variables list to be optional as on the server. I think it should be nice do not show it in this case.
export interface AlertType { | ||
id: string; | ||
name: string; | ||
actionGroups: ActionGroup[]; | ||
actionVariables: string[]; | ||
actionVariables: AlertTypeActionVariables; |
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.
I think it makes sense to have it as optional and do not show the empty dropdown list in the case it is undefined
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.
messageVariables which use actionVariables in UI is already optional for the ActionParamsProps as well, but some UI fixes still should be done to not display it. Maybe make sense to have a separate issue for this
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.
The action variables list will never be empty by the time the context menu displays, as there are 5-6 "always available" variables that come from the alert library; eg, alertName
.
I've also reshaped these since you reviewed, as the shape was radically different than actionGroups
(which is an array of id / name object), so I changed the actionVariables to match. This also means we won't have prototype pollution issues (even if not our fault), as we won't be using unknown properties on objects.
resolves elastic#58529 This PR extends alertType with an `actionVariables` property, which should be an object with optionial properties `context` and `state`. These properties should be typed as optional `Record<string, string>` values. The keys are the names of the relevant action variables, and the values are the localized descriptions of the variables.
ec74b52
to
42d9b19
Compare
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
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.
Changes LGTM! Had one question in hopes of removing the double places to maintain the default list of action variables but you have more context than I do.
I will also open an enhancement issue to use the user friendly description attributes defined within the alert action param templating.
Edit: As discussed, we'll wait and see before thinking too far ahead.
// this list should be the same as in: | ||
// x-pack/plugins/alerting/server/task_runner/transform_action_params.ts |
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.
I recall previously the mention of having two files to maintain. I wonder if there's a way we could move this function into a common
folder and do something like _.pick({}, ...)
within x-pack/plugins/alerting/server/task_runner/transform_action_params.ts
based on the accumulation of name
properties.
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 ... the common folder ... yes, that might well work.
For whatever reason I was thinking that we'd need a new server API to retrieve these.
I'll open a new issue to resolve this.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
…les (elastic#59756) resolves elastic#58529 This PR extends alertType with an `actionVariables` property, which describes the properties of the context object passed when scheduling actions, and the current state. These property descriptions are used by the web ui for the alert create and edit forms, to allow the properties to be added to action parameters as mustache template variables.
…les (#59756) (#60082) resolves #58529 This PR extends alertType with an `actionVariables` property, which describes the properties of the context object passed when scheduling actions, and the current state. These property descriptions are used by the web ui for the alert create and edit forms, to allow the properties to be added to action parameters as mustache template variables.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* master: [Alerting] extend Alert Type with names/descriptions of action variables (elastic#59756) [Ingest] Fix data source creation and double system data source (elastic#60069) Add button to view full service map (elastic#59394) unskip tests for code coverage (elastic#59725) [Ingest] Add Fleet & EPM features (elastic#59376) [Logs UI] Show navigation bar while loading source configurati… (elastic#59997) [Endpoint] ERT-82 Alerts search bar (elastic#59702) Aggregate queue types being used by Beats (elastic#59850) skip flaky suite (elastic#59541) Convert Timeline to TypeScript (elastic#59966) Make context.core required argument to context providers (elastic#59996)
resolves #58529
This PR extends alertType with an
actionVariables
property, whichshould be an object with optionial properties
context
andstate
.These properties should be typed as optional
Record<string, string>
values. The keys are the names of the relevant action variables,
and the values are the localized descriptions of the variables.
This new property is optional, for the moment.
Checklist
Delete any items that are not applicable to this PR.
TODO
For maintainers