How to config logstash email output plugin to send email alert.

Ensure postfix or sendmail is configured on the logstash server, refer to another post here which config postfix with gmail smtp to send email

Create a new logstash conf file in /etc/logstash/conf.d and add below content

input {
   syslog {
        type => syslog
        port => 5514
      }
    }

output {
   email {
        to => "[email protected]"
        subject => "Test from logstash email output"
        body => "The message from logstash input: %{message}"
      }
    }

Next restart logstash

$ service logstash restart

Finally test with telnet in another terminal on the same vm

$ telnet localhost 5514
$ => then after connected, enter some message and press enter

In a few seconds the actual “[email protected]” should receive an email sent by logstash with the subject and body matching what’s configured above.

BACK TO TOP
Post tagged with: devops, logstash