[ResponseOps] [Discuss] preprocessing context variables to produce calculated values #155331
Labels
discuss
Feature:Actions
Team:ResponseOps
Label for the ResponseOps team (formerly the Cases and Alerting teams)
One of the issues with the mustache template processing of alerting actions, is that users would like to process some of the variables in ways that are impossible / unwieldy in mustache. For example:
hostname::servicename
, which the user has set up as two values separated by colons (say, in a field in their database). And they would like to have these as separate strings.So here's a thought. Before we render the template, let's have another phase, I'll call "adding variables". We'll also add more data to each action - a list of variable/expression pairs, which define new mustache variables to create, and the expression to evaluate that will return their value.
Then, when actions are executed, before rendering the mustache templates, we'll calculate the values of the new variables the user has requested, given their expressions. These variables will be added to the existing mustache variables, under a top-level property named
user
.For example, to add a variable which is a formatted version of the date provided in the context variables, they would add something like this to their action "additional variables":
They could then refer to that value as
{{user.formattedDate}}
within their mustache template.Now, the big question: what is the "expression language". One option would be jexl. A more interesting option would be Painless.
The text was updated successfully, but these errors were encountered: