What am I doing wrong here?
Input files eft_test.log and u_extest.log
eft_test.log
03-27-18 09:32:10,590 [2184] TRACE SFTP <> - [139C9318] msg: 2024502473 Sending SSH_MSG_KEX_31 (139 bytes, seq nr 1)
03-27-18 09:32:10,591 [2184] TRACE SFTP <> - [139C9318] msg: 2024502476 Received SSH_MSG_KEX_32 (134 bytes, seq nr 2)
03-27-18 09:32:10,592 [1452] TRACE Events.Server.Pittsburgh_Non-Prod <Parse FTP Command> - Dispatch file system event; event type: 20491; PPath: \\Pnpfs01\np-ftp\FTPData\Usr\trpd001\CMW\control\; VPath: /Usr/trpd001/CMW/control/
u_extest.log
2018-03-25 04:00:00 xx.xx.xxx.xxx - - [179863]user DISTST4FTP1_XD3W - 331 - - - 21
2018-03-25 04:00:00 xx.xx.xxx.xxx - - [179863]pass ****** - 530 - - - 21
2018-03-25 04:00:00 xx.xx.xxx.xxx - - [179864]user TRPD003FTP1_E4PK - 331 - - - 21
2018-03-25 04:00:00 xx.xx.xxx.xxx- EADMZ\TRPD003FTP1_E4PK [179864]pass ****** - 230 - - - 21
Filter:
input {
#stdin {}
file {
path => ["/Users/svyahalkar/elastic/logstash/incoming/eft*.log","/Users/svyahalkar/elastic/logstash/incoming/u_ex*.log"]
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
if [path] =~ "eft" {
mutate { replace => { type => "eft_log" } }
if [message] =~ /^\s*$/ {
drop { }
}
grok{
match => {"message" => "%{DATESTAMP:date}\,%{NUMBER:msgnum} \[%{NOTSPACE:session}\] %{LOGLEVEL:src} %{GREEDYDATA:msgdata}"}
#overwrite => ["message"]
}
} else if [path] =~ "u_ex" {
mutate { replace => { type => "ftp_log" } }
grok{
match => {"message" => "%{TIMESTAMP_ISO8601:date} %{IP:c-ip} %{NOTSPACE:c-port} %{NOTSPACE:cs-username} \[%{NUMBER:session}\]%{NOTSPACE:cs-method} %{NOTSPACE:cs-uri-stem} %{NOTSPACE:cs-uri-query} %{NUMBER:sc-status} %{NOTSPACE:sc-bytes} %{NOTSPACE:cs-bytes} %{NOTSPACE:s-name} %{NOTSPACE:sc-port}"}
}
ruby {
code => "
hash = event.to_has
has.each do |k,v|
if v== '-'
event.remove(k)
end
end
"
}
} else {
mutate { replace => { type => "random_logs" } }
}
}
I am getting following error
[2018-03-29T11:27:30,375][ERROR][logstash.filters.ruby ] Ruby exception occurred: undefined method `to_has' for #<LogStash::Event:0x5c4d547>
Did you mean? to_hash
to_s
[2018-03-29T11:27:30,396][ERROR][logstash.filters.ruby ] Ruby exception occurred: undefined method `to_has' for #<LogStash::Event:0x666aa4f9>
Did you mean? to_hash
to_s
{
"type" => "eft_log",
"src" => "TRACE",
"path" => "/Users/svyahalkar/elastic/logstash/incoming/eft_test.log",
"@version" => "1",
"date" => "03-27-18 09:32:10",
"msgdata" => "SFTP <> - [139C9318] msg: 2024502476 Received SSH_MSG_KEX_32 (134 bytes, seq nr 2)\r",
"msgnum" => "591",
"message" => "03-27-18 09:32:10,591 [2184] TRACE SFTP <> - [139C9318] msg: 2024502476 Received SSH_MSG_KEX_32 (134 bytes, seq nr 2)\r",
"@timestamp" => 2018-03-29T18:27:29.983Z,
"host" => "svyahalkar-mbp.local",
"session" => "2184"
}