filter {
if [type] == "sftp_authlog" {
grok {
pattern => "%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sshd[%{BASE10NUM}]: Failed password for (invalid user |)%{USERNAME:username} from %{IP:src_ip} port %{BASE10NUM:port} ssh2"
email { #type => "sftp_authlog"
match => [ "fail","%{@message}" ]
match => { "message" => "fail" }
match =>["messageAndSourceMatch", "@message,fail"]
to => "gaurav.gurani@xyz.com"
from => "logstash@xyz.com"
options => [ "smtpIporHost", "x.x.x.x","port", "xx" ] #from => "logstash@hcentive.com"
subject => "Found '%{matchName}' Alert on %{@source_host}" #to => "gaurav.gurani@hcentive.com"
body => "Here is the event line that occured: %{@message}"
htmlbody => "
%{matchName}
Full Event
%{@message}
"
}
}
sftp_authlog- this is catching logs from remote host(with logstash-forwarder) and i am applying filter in logstash server.i am not able to receive the mails from above config .but when i am commenting the match inside email block then mail is coming but that was blank mail
Requirement :- i want to receive from logstash when certain login failure attempted
Could you edit your post to make it more readable? It's hard to understand exactly what your configuration looks like. Select the text and click the "Preformatted text" button in the toolbar or press Ctrl+K.
What version of Logstash is this? You're using a couple of constructs that aren't supported in reasonably recent versions.
Okay. That might've worked for older releases of Logstash (I only know 1.4 and 1.5) but for 1.4 there's a lot of craziness in there that just doesn't work. What's it supposed to do? Are you trying to send the email conditionally? On what condition?
grok {
match => [
"message",
"%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sshd\[%{BASE10NUM}\]: Failed password for (invalid user |)%{USERNAME:username} from %{IP:src_ip} port %{BASE10NUM:port} ssh2"
]
}
Other comments:
References to the fields @message and @source_host are incorrect. Those are legacy field names that aren't used in Logstash 1.4. Use message and host instead.
I apply that condition which you mentioned like following, but I received alot alert in email even match single word or multiple alphabet, like au* or fai, I just want to logstash just alert on specific word ! "authentication" , your help would be appreciated .
output {
if "authentication failure" in [message] {
email {
...
}
}
}
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.