# Compare Logstash Old Event Against New One and Make Math Operation

**URL:** https://discuss.elastic.co/t/compare-logstash-old-event-against-new-one-and-make-math-operation/256457
**Category:** Logstash
**Created:** [November 24, 2020, 7:48am UTC](https://discuss.elastic.co/t/compare-logstash-old-event-against-new-one-and-make-math-operation/256457 "2020-11-24T07:48:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)
#### Post date: [November 24, 2020, 7:48am UTC](https://discuss.elastic.co/t/compare-logstash-old-event-against-new-one-and-make-math-operation/256457/1 "2020-11-24T07:48:26Z")

</div>

Hello everyone,  
I want to compare the time object in each row with the next date object and get the difference between them and print them on the screen. I tried Aggregate plugin, Elapsed plugin, but could not reach the solution I wanted. Can you give an example filter that I can provide with Ruby script?  
Log :  
00:04:00 Enter user2  
14:12:44 Enter user1  
15:13:44 Enter user2  
16:18:44 Enter user1  
17:58:44 Enter user2  
19:58:44 Restart  
00:01:27 Enter user1  
13:22:44 Exit user1

Question :  
Assume that  
variable1 = 14:12:44  
variable2 = 15:13:44  
variable3 = 00:01:27  
if (variable2 \> variable1 )  
print 15:13:44 - 14:12:44  
else if (variable2 \> variable3)  
print dateVariable++

Could you give me a filter example that solves this ?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 22, 2020, 7:48am UTC](https://discuss.elastic.co/t/compare-logstash-old-event-against-new-one-and-make-math-operation/256457/2 "2020-12-22T07:48:31Z")

</div>

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