Skip to content

[alerts] provide mustache functions for ease-of-use in transforming mustache variables #84217

@pmuellr

Description

@pmuellr

One feature of mustache that we are not currently taking advantage of is "functions", also sometimes referred to as lambdas.

It's not clear how much value we can add with these, but seems like worthy of investigation.

One of the use cases I have in mind is date formatting. We now provide a {{date}} variable in the mustache variables applied to action parameters, in ISO format. How might you provide a function which can format that date with a traditional date formatter? The challenge is, the arguments have to be in the "body" of the function invocation.

Here's an example of how this might work:

{#date-format}}{{date}} MM/DD/YY{{/date-format}}

The date-format function would be provided by us, and it's "arguments" would be <iso-date> MM/DD/YY. So the function would parse the arguments expecting a date as the first part, and the format as the second.

So many issues tho.

Presumably dates coming out of ES that are not under our control could be in any date format, so it's not clear how we'd parse; maybe we need a better separator like <iso-date> --- MM/DD/YY.

Ideally we could support various sorts of "string functions", and so dealing with some kind of separator story that allows strings to be transformed and additional arguments seems really hard/yucky. I think maybe we'd need to go with something #<iso-date>#MM-DD-YY# where the arg delimiter is passed as the first char, kinda thing.

We'd likely need a specialized "test" environment for this - the current action tester (beside the action editor) doesn't do any mustache templating, and shouldn't, because it doesn't have access to alert data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:AlertingFeature:Alerting/RuleActionsIssues related to the Actions attached to Rules on the Alerting FrameworkR&DResearch and development ticket (not meant to produce code, but to make a decision)Team:ResponseOpsPlatform ResponseOps team (formerly the Cases and Alerting teams) t//discussestimate:mediumMedium Estimated Level of Effort

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions