1. Download the plugin logstash-output-email v4.0.3
2. Unzip
tar -xvf v4.0.3
3. Modify the installation plugin script bin/logstash-plugin, add the header
export JAVA_HOME=/usr/local/jdk1.8.0_121 export PATH=$JAVA_HOME/bin:$PATH
4. Modify the installation plugin configuration file vim Gemfile, add at the end
gem "logstash-output-email", :path => "/usr/local/logstash-output-email-4.0.3"
5. Install the plugin
bin/logstash-plugin install logstash-output-email
6. Modify the logstash configuration file bin/logstash_gateway.conf, add in output
if [level] == 'ERROR' { email { address => "mail.zjport.gov.cn" username => "username" password => "password" from => "[email protected]" subject => "ERROR: Gateway error %{datetime}" to => "[email protected]" body => "%{message}" } }
7. When the error log is captured, logstash automatically sends an email