如何在 SMTP 中设置无需身份验证的 logstash 1.4.2 电子邮件插件
How to setup logstash 1.4.2 email plugin without authentication in SMTP
我在 CentOS 6 中设置了 logstash 1.4,2 运行 elasticsearch。我想要一种简单的方法来在日志中出现典型错误时发送电子邮件,我正在从不同的日志文件中挑选日志。在 logstash 在线文档中,我找到了最新版本的示例,即 2.0。而且我不想要在我的情况下不起作用的 gmail 示例。
我还需要启用电子邮件插件还是直接将其添加到 logstash conf 文件中?
感谢您的帮助。
您好,我之前在 logstash-1.4.2 上工作,最近更新到 2.0,并且我已经实现了电子邮件插件。我将与本地 smtp 的电子邮件设置共享一个示例 conf 文件。
input {
file {
type => 'file'
path => '/home/tech/apache-tomcat-7.0.54/logs/em.log'
start_position => beginning
}
}
filter {
if [type] == "file" {
grok {
# The grok filter will use the below pattern and on successful match use
# any captured values as new fields in the event.
match => { 'message' => '([\w\.]*(ERROR|Exception))' }
}
}
}
#here is the output will be displayed in Kibana and on ERROR it will send notification
output {
elasticsearch { host => localhost }
if "ERROR" in [message] {
email {
options => [ "smtpIporHost", "YOUR-SMTP-IP",
"port", "25"
]
from => "<myemail@example.com>"
subject => "Logstash alert on Error "
to => "recipeint@example.com"
via => "smtp"
body => "Here is the event line that occured: %{message} %{@timestamp} %{host}"
htmlbody => "<h2 align='center'>%{host}</h2><br/><h3>Details</h3><br/><div align='center' style='color:red'>%{message}</div><div align='center'>%{@timestamp}</div><div align='center'>%{@version}</div>"
}
}
stdout { codec => rubydebug }
}
首先您需要检查是否安装了电子邮件插件
logstash-1.4.2/lib/logstash/outputs/email.rb
如果不存在,您可以通过 运行 此命令安装它。
./bin/plugin 安装贡献
如果你有插件设置,现在你可以测试脚本了。
./bin/logstash -f 我的-logstash.conf
它会向您显示一些警告,如果有错误,请阅读日志文件,并将其通过电子邮件发送。
每当此文件更改时,它都会读取。
如果您需要任何详细信息来测试此示例,请告诉我。
我在 CentOS 6 中设置了 logstash 1.4,2 运行 elasticsearch。我想要一种简单的方法来在日志中出现典型错误时发送电子邮件,我正在从不同的日志文件中挑选日志。在 logstash 在线文档中,我找到了最新版本的示例,即 2.0。而且我不想要在我的情况下不起作用的 gmail 示例。 我还需要启用电子邮件插件还是直接将其添加到 logstash conf 文件中?
感谢您的帮助。
您好,我之前在 logstash-1.4.2 上工作,最近更新到 2.0,并且我已经实现了电子邮件插件。我将与本地 smtp 的电子邮件设置共享一个示例 conf 文件。
input {
file {
type => 'file'
path => '/home/tech/apache-tomcat-7.0.54/logs/em.log'
start_position => beginning
}
}
filter {
if [type] == "file" {
grok {
# The grok filter will use the below pattern and on successful match use
# any captured values as new fields in the event.
match => { 'message' => '([\w\.]*(ERROR|Exception))' }
}
}
}
#here is the output will be displayed in Kibana and on ERROR it will send notification
output {
elasticsearch { host => localhost }
if "ERROR" in [message] {
email {
options => [ "smtpIporHost", "YOUR-SMTP-IP",
"port", "25"
]
from => "<myemail@example.com>"
subject => "Logstash alert on Error "
to => "recipeint@example.com"
via => "smtp"
body => "Here is the event line that occured: %{message} %{@timestamp} %{host}"
htmlbody => "<h2 align='center'>%{host}</h2><br/><h3>Details</h3><br/><div align='center' style='color:red'>%{message}</div><div align='center'>%{@timestamp}</div><div align='center'>%{@version}</div>"
}
}
stdout { codec => rubydebug }
}
首先您需要检查是否安装了电子邮件插件 logstash-1.4.2/lib/logstash/outputs/email.rb 如果不存在,您可以通过 运行 此命令安装它。 ./bin/plugin 安装贡献
如果你有插件设置,现在你可以测试脚本了。 ./bin/logstash -f 我的-logstash.conf
它会向您显示一些警告,如果有错误,请阅读日志文件,并将其通过电子邮件发送。 每当此文件更改时,它都会读取。
如果您需要任何详细信息来测试此示例,请告诉我。