Skip to content
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 UI] Add an option to being able to create a "sub-template" for a particular context variable. #78884

Open
YulNaumenko opened this issue Sep 29, 2020 · 3 comments
Labels
discuss estimate:needs-research Estimated as too large and requires research to break down into workable issues Feature:Alerting/RuleActions Issues related to the Actions attached to Rules on the Alerting Framework Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@YulNaumenko
Copy link
Contributor

YulNaumenko commented Sep 29, 2020

It would be useful to have a possibility to define a specific template for some complex action variables like an object:

{
  "name": "Chris",
  "value": 10000,
  "taxed_value": 10000 - (10000 * 0.4),
  "in_ca": true
}

which will be added to the message as a text:

Hello {{name}}
You have just won {{value}} dollars!
{{#in_ca}}
Well, {{taxed_value}} dollars, after taxes.
{{/in_ca}}
@YulNaumenko YulNaumenko added Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Sep 29, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@pmuellr
Copy link
Member

pmuellr commented Oct 2, 2020

When would this be used? And how does this differ from the UI side default message capability? Or are you thinking this belongs in the server?

@pmuellr
Copy link
Member

pmuellr commented Oct 6, 2020

I think this issue is aimed at being able to create a "sub-template" for a particular context variable, or even property or element of a context variable, if that variable is an object or array.

We could support this kinda thing via "partials", in the mustache sense; some doc here: https://github.com/janl/mustache.js/#partials

We could then expose the partials in the "variables list", and when clicked, then insert the reference to the partial; eg, from the mustache below (stolen from the link above), we might list user as a variable (or perhaps > user), and it would insert the string {{> user}} in the action param edit field. And of course we'd have user available as a partial, however that happens.

Maybe that's too complicated tho ... and how would users even know what the partials expanded to?

It would be easier to allow a variable to insert not just a name surrounded by {{}}, but an entire string with mustache template bits in it.

For example, this template and partial:

base.mustache:
<h2>Names</h2>
{{#names}}
  {{> user}}
{{/names}}

user.mustache:
<strong>{{name}}</strong>

Can be thought of as a single, expanded template:

<h2>Names</h2>
{{#names}}
  <strong>{{name}}</strong>
{{/names}}

@YulNaumenko YulNaumenko changed the title [Alerting UI] Add an option for alert types to be able to define own Mustache templates for parsing and rendering variables of a custom Object type [Alerting UI] Add an option to being able to create a "sub-template" for a particular context variable. Oct 6, 2020
@gmmorris gmmorris added the Feature:Alerting/RuleActions Issues related to the Actions attached to Rules on the Alerting Framework label Jul 1, 2021
@gmmorris gmmorris added the loe:needs-research This issue requires some research before it can be worked on or estimated label Jul 14, 2021
@gmmorris gmmorris added the estimate:needs-research Estimated as too large and requires research to break down into workable issues label Aug 18, 2021
@gmmorris gmmorris removed the loe:needs-research This issue requires some research before it can be worked on or estimated label Sep 2, 2021
@kobelb kobelb added the needs-team Issues missing a team label label Jan 31, 2022
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss estimate:needs-research Estimated as too large and requires research to break down into workable issues Feature:Alerting/RuleActions Issues related to the Actions attached to Rules on the Alerting Framework Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
No open projects
Development

No branches or pull requests

5 participants