Calculate number of days between two dates logstash [solved]

Hello,

I want to calculate number of days between two dates in logstash
I have :

date {
		match => ["Deb","dd/MM/YYYY"]
		target=> "Deb"
}
date {
	      match => ["toDay","dd/MM/YYYY"]
	      target=> "toDay"
}

and I did this Ruby filter but it doesn't work !!

ruby {
		init => "require 'time'"
		code => "event['duree'] = event['toDay'] - event['Deb'];"
}

Can you help me please :slight_smile:

Solved by doing this

ruby {
	code => "event.set('duree', (event.get('toDay') - event.get('Deb'))/3600/24)"
}

first I got the period on secondes so I convert it to days

good luck :slight_smile:

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.