Hi All,
Have a sample set of data as below
orders type createdon dispatchedon deliveredon
C015 2 31/07/2019 18:09 31/07/2019 18:15 11/09/2019 16:28
C018 3 06/08/2019 11:46 11/09/2019 12:24 11/09/2019 12:26
C019 4 08/08/2019 13:59 08/08/2019 17:57 11/09/2019 17:58
C020 3 13/08/2019 12:20 13/08/2019 12:50 11/09/2019 16:27
i was working on calculation of time difference based on createdon time as on colum3..
my logstash config is as below
input
{
file
{
path => "F:/nana/*.csv"
start_position => "beginning"
codec => plain {charset => "ISO-8859-1" }
}
}
filter
{
csv
{
separator => ","
columns => ["orders","type","createdon","dispatchedon","deliveredon"]
skip_header => true
}
ruby
{
init => "require 'date'"
code => '
createddayhours = 0
t_created = event.get("createdon")
t_created = DateTime.parse("t_created")
created_hour= t_created.hour
created_min =t_created.min
createdday_lastworkinghour =(DateTime.parse("%F 18:00"))
createddayhours = (((createdday_lastworkinghour-t_created)/60)/60).to_f
if createddayhours > 0 and createddayhours < 10
createddayhours = createddayhours
elsif createddayhours < 0
createddayhours = 0
else
createddayhours = 0
end
event.set("createddayhours", createddayhours)
'
}
}
output {
stdout{}
elasticsearch
{
hosts => "http://localhost:port"
index => "sample"
}
}
there is a ruby exception coming up as below
[2019-09-23T12:51:25,309][ERROR][logstash.filters.ruby ] Ruby exception occurred: invalid date
[2019-09-23T12:51:25,309][ERROR][logstash.filters.ruby ] Ruby exception occurred: invalid date
[2019-09-23T12:51:25,309][ERROR][logstash.filters.ruby ] Ruby exception occurred: invalid date
can some one help me on this
Thanks