# How to send all the alerts in one mail using logstash

**URL:** <https://discuss.elastic.co/t/how-to-send-all-the-alerts-in-one-mail-using-logstash/187589>\
**Category:** Logstash\
**Created:** [June 26, 2019, 2:05pm UTC](https://discuss.elastic.co/t/how-to-send-all-the-alerts-in-one-mail-using-logstash/187589 "2019-06-26T14:05:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)\
**Post date:** [June 26, 2019, 2:05pm UTC](https://discuss.elastic.co/t/how-to-send-all-the-alerts-in-one-mail-using-logstash/187589/1 "2019-06-26T14:05:49Z")

</div>

HI ,

I will get around 100 alerts in a day and all those come in different emails .  
So , is there any way i can get all the alerts only in one mail on a particular time everyday using logstash.

Please help me solve it.

This is how far i came :

logstash.conf

> input {  
> file {  
> path =\> "/home/Desktop/a.log"  
> start\_position =\> "beginning"  
> }  
> }
> 
> output {  
> elasticsearch { hosts =\> ["localhost:9200"] }  
> stdout { codec =\> rubydebug }
> 
> if "Error" in [message] {  
> email {  
> from =\> "#######@gmail.com"  
> subject =\> "Ignore (test run)"  
> body =\> "log-message: %{message} \nLog file: %{path}"  
> to =\> "#######@gmail.com"  
> codec =\> "plain"  
> contenttype =\> "text/plain; charset=UTF-8"  
> address =\> "[smtp.gmail.com](http://smtp.gmail.com)"  
> port =\> "587"  
> authentication =\> "plain"  
> username =\> "##########@gmail.com"  
> password =\> "############"  
> use\_tls =\> true  
> debug =\> true  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![andres-perez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andres-perez/32/136461_2.png) [@andres-perez](https://discuss.elastic.co/u/andres-perez)\
**Post date:** [July 8, 2019, 8:18am UTC](https://discuss.elastic.co/t/how-to-send-all-the-alerts-in-one-mail-using-logstash/187589/2 "2019-07-08T08:18:59Z")

</div>

Logstash by itself doesn't seem the best tool for this use case: it is usually meant for stateless processing.

With [X-pack alerting](https://www.elastic.co/guide/en/elastic-stack-overview/current/xpack-alerting.html) feature, you could:

- Set up an [elasticsearch query](https://www.elastic.co/guide/en/elastic-stack-overview/current/input-search.html) (e.g. how many errors in the last 24 hours or any other aggregation or list)
- [Schedule a trigger](https://www.elastic.co/guide/en/elastic-stack-overview/current/trigger-schedule.html#schedule-daily) for that search, for example a given time everyday or a complete cron-like configuration.
- [Send a mail](https://www.elastic.co/guide/en/elastic-stack-overview/current/actions-email.html) with the results and customize its contents with a template.

---

<div class="post-metadata">

**Author:** ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)\
**Post date:** [August 1, 2019, 12:22pm UTC](https://discuss.elastic.co/t/how-to-send-all-the-alerts-in-one-mail-using-logstash/187589/3 "2019-08-01T12:22:36Z")

</div>

Thanks @andres-perez for the reply.  
But x-pack alerting isn't free in ELK.

is there any other alternative or is there any way i can configure via logstash configuration.

---

<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:** [August 29, 2019, 12:22pm UTC](https://discuss.elastic.co/t/how-to-send-all-the-alerts-in-one-mail-using-logstash/187589/4 "2019-08-29T12:22:43Z")

</div>

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