I calculate the difference between two dates with this code.
ruby{
code => "event.set('Duration', (event.get('Release_date') - event.get('Date_of_entry')))"
}
the output that i have : field duration with type number like this: 18000
how can i get the difference in time HH:mm:ss ??
please any ideas??
Sorry, Maybe this question will be stupid but really i don't know how to use or add this code to my logstash file config and i must calculate the duration between two events (type date) ??can you help me please?
time_difference = current_time - old_time
def seconds_fraction_to_time(time_difference)
days = hours = mins = 0
mins = (seconds / 60).to_i
seconds = (seconds % 60 ).to_i
hours = (mins / 60).to_i
mins = (mins % 60).to_i
days = (hours / 24).to_i
hours = (hours % 24).to_i
return [days,hours,mins,seconds]
end
then you can print it out what ever way you wish,
if(days > 0)
return "#{days} Days #{hours} Hours"
else
return "#{hours} Hours #{mins} Minutes"
end
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.