Hi all
New to the forum ,ive been trying to get time difference between two fields in a csv using ruby plugin but i am new to logstash and using ruby can somebody please assist with the syntax of the ruby filter
(running logstash 6.1.1)
My .conf file filter is as follows:
filter {
if [projectid] == "Sample" {
csv {
columns => ["DOMAIN","NAME","ORDERNUM","CATEGORY","SUBCATEGORY","CURRENT_PRIORITY","STATE","CREATED","RESOLVED","CLOSED","VALUE","COMPLETED_HOUR"]
convert => {
"COMPLETED_HOUR" => "integer"
}
}
Drop Header Rows
if "DOMAIN" in [DOMAIN] {
drop {}
}
Date format
date {
match => [ "CREATED", "dd/MM/yyyy HH:mm", "ISO8601"]
target => "CREATED"
}
date {
match => [ "RESOLVED", "dd/MM/yyyy HH:mm", "ISO8601"]
target => "RESOLVED"
}
date {
match => [ "CLOSED", "dd/MM/yyyy HH:mm", "ISO8601"]
target => "CLOSED"
}
Ruby filter
ruby {
init => "require 'time'"
code => "
diff = event['CREATED'] - event['RESOLVED']
event['timediff'] = diff;
"
add_tag => [ "calculated_time_difference" ]
}
}
}
I tried the ruby filter above but i am getting the error (see below) :
[ERROR] 2018-03-01 15:46:57.531 [Ruby-0-Thread-11@[main]>worker2: /usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:392] ruby - Ruby exception occurred: Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field')). Please consult the Logstash 5.0 breaking changes documentation for more details.
Any help will be much appreciated ,TIA