Iterat list on watcher elasticsearch

hi guys

i want to iterat list of indices to add them to e-mail alert and to send for every index one -e-mail alert.

action :

"send_email": {
"foreach" : "ctx.payload.list",
"email": {
"profile": "standard",
"priority": "high",
"to": [
"subject": "[Watcher Notification]",
"body": {
"text": "No data sent to index : {{ctx.payload.list}} last 24h"

the watcher send email for every index but in the body the variable : {{ctx.payload.list}} is empty
my question is how to retrieve every element separatly from the list.

thanks for help

when you are using foreach, then the payload will change to contain the element of the current list iteration. See the example here using ._id Running an action for each element in an array | Elasticsearch Guide [8.0] | Elastic

Thanks for the response,

i found a soultion : i delete the foreach and i iterate the list in the email body like that :

{{#ctx.payload.list}} {{key}} {{/ctx.payload.list}}

i hope that my response help someone.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.