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

[ResponseOps] [Discuss] preprocessing context variables to produce calculated values #155331

Open
pmuellr opened this issue Apr 19, 2023 · 1 comment
Labels
discuss Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@pmuellr
Copy link
Member

pmuellr commented Apr 19, 2023

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:

  • extracting text from a string with a regexp - a mustache variable might be 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.
  • anything more complicated than we already support in (presumably eventually merged) PR [ResponseOps] adds mustache lambdas and array.asJSON #150572

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":

formattedDate: "{{some expression to format a date}}"

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.

@pmuellr pmuellr added discuss Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Apr 19, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@pmuellr pmuellr moved this from Awaiting Triage to Todo in AppEx: ResponseOps - Execution & Connectors Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Feature:Actions Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
No open projects
Development

No branches or pull requests

2 participants