# Looping through Aggregations to trigger multiple emails

**URL:** <https://discuss.elastic.co/t/looping-through-aggregations-to-trigger-multiple-emails/149777>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 25, 2018, 7:23am UTC](https://discuss.elastic.co/t/looping-through-aggregations-to-trigger-multiple-emails/149777 "2018-09-25T07:23:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suman\_Reddy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suman_reddy1/32/27303_2.png) [@Suman\_Reddy1](https://discuss.elastic.co/u/Suman_Reddy1)\
**Post date:** [September 25, 2018, 7:23am UTC](https://discuss.elastic.co/t/looping-through-aggregations-to-trigger-multiple-emails/149777/1 "2018-09-25T07:23:16Z")

</div>

Hi All,

Can someone please advise if I can achieve below in some or other way in Kibana Watcher Notifications/Actions.

```
"actions": {
    {{#ctx.payload.aggregations.app_id.buckets}}
    "send_email": {
      "email": {
        "profile": "standard",
        "to": [
          "sumangodisela@suman.com", ],
        "subject": "[PCF DCE] APP Health Alerts",
        "body": {
          "text": " {{key}}"
        }
      }
    }
    {{/ctx.payload.aggregations.app_id.buckets}}
  }

```

Requirement is that for each aggregation it should trigger a mail notification.

Thanks,  
Suman G

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 25, 2018, 9:32pm UTC](https://discuss.elastic.co/t/looping-through-aggregations-to-trigger-multiple-emails/149777/2 "2018-09-25T21:32:22Z")

</div>

Hey,

only .a single email can be sent from an action currently. An alternative might be to sent the payload to logstash and send several emails from there, if that solves your use-case.

--Alex

---

<div class="post-metadata">

**Author:** ![Suman\_Reddy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suman_reddy1/32/27303_2.png) [@Suman\_Reddy1](https://discuss.elastic.co/u/Suman_Reddy1)\
**Post date:** [September 26, 2018, 6:25am UTC](https://discuss.elastic.co/t/looping-through-aggregations-to-trigger-multiple-emails/149777/3 "2018-09-26T06:25:36Z")

</div>

thanks Alex!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 24, 2018, 6:25am UTC](https://discuss.elastic.co/t/looping-through-aggregations-to-trigger-multiple-emails/149777/4 "2018-10-24T06:25:40Z")

</div>

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