First try with emailing logs, I found this bit of information but im having issues working out how this would work for me.
if "FOUND" in [message] {
email {
from => "logstash_alert@company.local"
subject => "logstash alert"
to => "myemail@company.local"
via => "smtp"
body => "Here is the event line that occured: %{message}"
}
}
My problem is that "found" is around quite a lot, I only want the email if the word "FOUND" is in a specific logfile / tag
[root@develk01 conf.d]# cat 30-elasticsearch-output.conf
output {
elasticsearch {
hosts => ["localhost:9200"]
sniffing => true
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
if [filename] == "clamd.log" and "FOUND" in [message] {
email {
from => "logstash_alert@xxx"
subject => "logstash alert"
to => "xxx@xxx"
via => "smtp"
body => "Here is the event line that occured: %{message}"
domain => 'smtp.xxx'
port => 25
}
}
}
[root@develk01 conf.d]
I then forced a run to create the log which showed up in Kibana, but no email. I also didnt see anything in the logstash logs, any idea what I have done wrong?
Logs from the server running the scan:
Starting ClamAV Scan at Mon 20 Aug 14:40:12 IST 2018
Mon Aug 20 14:45:35 2018 -> SelfCheck: Database status OK.
/home/adm-guerinw@xxx/test.virus: Eicar-Test-Signature FOUND
Brilliant, I think this is a better error to have now!
[2018-08-20T15:14:51,727][ERROR][logstash.outputs.email ] Something happen while delivering an email {:exception=>#<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 25>}
Thanks Magnus, this is now working and I received an email last night, my config:
if "clamav" in [tags] and "FOUND" in [message] {
email {
from => "logstash_alert@xxx.com"
subject => "logstash alert"
to => "xxx@xxx.com"
via => "smtp"
body => "Here is the event line that occured: %{message}"
address => "smtp.xxx.com"
port => 25
}
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.