# Scheduling mail from logstash

**URL:** <https://discuss.elastic.co/t/scheduling-mail-from-logstash/373919>\
**Category:** Logstash\
**Tags:** elastic-stack-alerting, docker\
**Created:** [January 31, 2025, 4:44am UTC](https://discuss.elastic.co/t/scheduling-mail-from-logstash/373919 "2025-01-31T04:44:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hitesh\_Bhanderi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hitesh_bhanderi/32/138265_2.png) [@Hitesh\_Bhanderi](https://discuss.elastic.co/u/Hitesh_Bhanderi)\
**Post date:** [January 31, 2025, 4:44am UTC](https://discuss.elastic.co/t/scheduling-mail-from-logstash/373919/1 "2025-01-31T04:44:39Z")

</div>

Hi this might be silly but I want to know that can i schedule mail from logstash using email-plugin as i want to schedule mail which contains error message from the logs .i had successfully implemented to mail error logs.but it sends mail for each error message .so is there any way ?. if yes how to implement it. As I'm not able to find any reference on internet. So if any one finds it or has solution ,please forward me. and here is my implementation:

```auto
input {
    tcp {
        port => 5044
        codec => json
    }
}

output {
    elasticsearch {
        hosts => ["http://elasticsearch:9200"]
        index => "%{[Properties][TrackWizzEnvironment]}-%{[Properties][ServiceName]}-%{+YYYY.MM.dd}" # Dynamic index based on fields
    }
    stdout { codec => rubydebug } # For debugging

    if [Level] == "Error" {
        email {
            to => "xyz@domain.com"
            from => "abc1234@domain.com"
            subject => "🚨 Error Logs Detected!"
            body => "We detected an error log in the last 15 minutes:%{MessageTemplate}"
            address => "136.243.205.196"
            port => 587
            authentication => "plain"
            username => "xyz@domain.com"
            password => "xfgfxg@#th^$xcgv651"
            use_tls => true
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 31, 2025, 1:53pm UTC](https://discuss.elastic.co/t/scheduling-mail-from-logstash/373919/2 "2025-01-31T13:53:28Z")

</div>

You might be able to use a metrics filter with flush\_interval set to a large number, then use a conditional in the output section to route the metrics to an email output. If you really need the errors in the email then route the metric events through an elasticsearch filter to look them up.

---

<div class="post-metadata">

**Author:** ![Hitesh\_Bhanderi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hitesh_bhanderi/32/138265_2.png) [@Hitesh\_Bhanderi](https://discuss.elastic.co/u/Hitesh_Bhanderi)\
**Post date:** [February 3, 2025, 9:16am UTC](https://discuss.elastic.co/t/scheduling-mail-from-logstash/373919/3 "2025-02-03T09:16:41Z")

</div>

thanks For reply @Badger . But i found alternative for this purpose i.e by using elastAlert2 . but As soon as i get time i will try this solution
