Lets say i get an array of results when firing a signals alert. Is there a way to iterate through all the results and include them in the message that’s being sent out from the alert?
Hi @ericl
You can use something like the below notation:
{{#data.mysearch.hits}}
{{.}}
{{/data.mysearch.hits}}
Hope this helps
I was able to do this and display the entire blob and display the entire result set in the message but i was unable to display specific elements that exist. Let’s say one of the fields in my data was appName and i wanted to iterate through every record and display all of the appNames that appeared in the result set is there a way to do this?
@ericl
Can you provide example of the data you get back from the search?
Using below data:
{
"watch": {
"id": "__inline_watch",
"tenant": "_main"
},
"data": {
"mysearch": {
"_shards": {
"total": 1,
"failed": 0,
"successful": 1,
"skipped": 0
},
"hits": {
"hits": [
{
"_type": "_doc",
"_source": {
"val1": [
"a",
"b",
"c"
]
},
"_id": "SBTJMHsBKUcUZn4ksA-5",
"_index": "test",
"_score": 0.05129329
}, ...
If you wanted to loop through entries in val1 (a,b,c), the syntax would look as follows:
{{#data.mysearch.hits.hits}}
{{#_source.val1}}
{{.}}
{{/_source.val1}}
{{/data.mysearch.hits.hits}}
Would that work in the body portion of an email message i’m sending from an alert?
I tested with Slack and it works as expected, haven’t tested with email yet, but would assume it will work the same.
This worked great thank you so much