-
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
[Actions UI] Enable adding non quoted alert type variables in JSON body of action type #78877
Comments
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
I had a slightly crazy thought on doing the JSON validation for these:
During the template replacement, we'd want to avoid replacing the section/partial/etc directives, just replace the simple variables. This seems like it might work to me, devil is in the details ... |
I've been investigating what would be needed to support this. On the UI side I found that it is pretty straight forward to allow an AlertType to hint to the framework what format a The problem is on the server side.
This won't work for us anymore.
We cannot parse this as actual JSON, so storing the esIndex's I believe we can address the requirement in the issue, but it's becoming a bit of a larger change than I originally thoughts, so thought I'd check in before continuing. |
I agree we may need to consider making the es index
We'd then change the UI to always send the string version. We could try to enhance the params validator when it gets a string to do the "replace mustache vars with literals", but that might be hard - what parser would we use? Alternatively, we can do the validation at execution time. At execution time, we'll still have the string, but the mustache variables will have been replaced with their values, so we can do a simple JSON.parse() of it to create the object to send to ES, and raise JSON validation errors at that point. Not great, but probably good enough. |
We'd need typing on context variables as well, I think, to do this kind of replacement, or at least to do "type checking" of context variables as mustache variables. And then consider we have to support sections like the following, assuming
|
We should keep in mind this list of other mustache / action parameter issues: #79786 I just starting noodling around on this one: #79371 - it's going to get pretty hairy, as I think we're going to need to make (or perhaps "allow") action types to do per-parameter rendering of the mustache templates. But I think in terms of changing |
And note we still have to figure out how to handle these things in the UI. Are we just going to turn off the JSON parsing / checking? Once we have "in alert" action testing, I think actions are going to have to provide some "default context variables" to use for these tests. If we have that, then we could do the mustache replacement with those, and then do the JSON verification of that. Any resulting syntax errors might be confusing to look at, with default data provided, but guessing it won't be horribly confusing. |
Also, what does watcher do? |
Yup, thats what I've done...
Yeah, it's means all new esIndex will be string while old ones will be objects, but we can handle that.
Yeah, we have no way of knowing the potential vars there, that's the problem :/
Exactly, that's been the direction I've been investigating... it works even if not the best,.. as you said - probably good enough. |
It's annoying... we can validate the JSON by replacing the tokens, but the UI will complain because it wants a valid JSON. |
I've looked at the "Simulate" section and they have the exact same limitation we currently have. For example:
As we have a want a full UI experience we son't want to fall back to JSON input like this... |
That That support was added to watcher in PR elastic/elasticsearch#18856 , along with a similar |
During the Alerting team sync we decided to put this back in the backlog for the following reasons:
|
Moving from |
Closing due to lack of activity. |
When user are adding a document for Index Action type, she should be able to has a valid JSON:
which after mustache transformation will be:
or for a Webhook:
Currently it is not possible because validation require to add a quotas around the variable.
The text was updated successfully, but these errors were encountered: