Hi,
I'd like to have my email action to retrieve the email body stored as a mustache script. Currently the email get sent with "mem-watch-warning" as a text instead of the html content stored in _scripts/mem-watch-warning.
Thanks for your help!
"actions": {
"send_mem_warning": {
"transform": {
"script": {
"lang": "painless",
"source": "def latest = ctx.payload.aggregations.minutes.buckets[-1]; return latest.nodes.buckets.stream().filter(item -> item.memory.value >= ctx.metadata.threshold).collect(Collectors.toList());"
}
},
"email": {
"profile": "standard",
"from": "watcher@your-company.com",
"to": [
"dude@your-company.com"
],
"subject": "Watcher Notification - HIGH MEMORY USAGE",
"body": {
"html": {
"id": "mem-watch-warning"
}
}
}
}
}
POST _scripts/mem-watch-warning
{
"script": {
"lang": "mustache",
"source": "
Nodes with HIGH MEMORY
Usage (above 60%):- {{#ctx.payload._value}}
- "{{key}}" - Memory Usage is at {{memory.value}} {{/ctx.payload._value}}
}
}