-
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] add a toString()
to context variables whose values are objects
#82044
Comments
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
This may be a DUP of issue #75601, haven't looked closely |
Hello, I am new to contributing but would like to help. Would this problem be reasonable to start with? Any information on where I should start looking (files this logic is located) would be appreciated. Thanks in advance! |
it might be reasonable! I'll let you decide. The relevant code, is here: kibana/x-pack/plugins/alerts/server/task_runner/transform_action_params.ts Lines 39 to 62 in 3651748
I think the trick is going to be to walk the The way you'd test this is to create an alert, add an action like a server log, trying using a variable like I'm not sure why we have that |
As noted in #82044 (comment), this is a DUP of #75601 . And I have an implementation of this in not-yet-merged-ATM PR #83919, since I was already mucking around in that code, and this was easy enough to add. |
has anyone been able to surface something like user.email in Alerts? |
For context variables provided by an alert, to be used in action parameters, usually the values of the variables are strings or other primitive values. However, they can be objects as well. The metrics alert makes use of this for it's grouping (I believe).
When a customer uses these object-valued variables directly as a mustache "variable", mustache will render these values as the following, which isn't very useful.
It's possible to add a
toString()
method to these object values, which would then get invoked when the object is used as a "variable". So one could be added that returned egJSON.stringify(this)
. It's unlikely to be the form a customer would want to use directly, but it is better than what currently happens, and should provide the info to the customer to refine the variable references while fine-tuning alert actions.Alert executors can do this themselves, and I've proposed that before, but I'm wondering if we should just do this automagically in alerting. We could also add one on the top-level context, so you could use
{{context}}
to see the full context - again, mainly for diagnostic purposes, seems like it could be useful.I suppose we'd "walk" the context provided by the alert, probably deep clone it (since we'll be modifying it), and then for every "object" in the graph, add the relevant
toString()
method to the object, if there's not already atoString
property.The text was updated successfully, but these errors were encountered: