# Comparing Two similar fields in two grok patterns

**URL:** https://discuss.elastic.co/t/comparing-two-similar-fields-in-two-grok-patterns/229062
**Category:** Logstash
**Created:** [April 21, 2020, 1:52pm UTC](https://discuss.elastic.co/t/comparing-two-similar-fields-in-two-grok-patterns/229062 "2020-04-21T13:52:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tushant\_gaur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tushant_gaur/32/45963_2.png) [@tushant\_gaur](https://discuss.elastic.co/u/tushant_gaur)
#### Post date: [April 21, 2020, 1:52pm UTC](https://discuss.elastic.co/t/comparing-two-similar-fields-in-two-grok-patterns/229062/1 "2020-04-21T13:52:22Z")

</div>

HI ,

I have two grok patterns that has one common field , and there is timestamp field associated with these grok patterns .  
Am able to make a mapping of common field wih their respective timestamps.  
But not able to do like  
if [common filed in grok 1] == [common filed in grok 2]  
{ruby { code =\> "event.set('[response]', (event.get('[time stamp in grok2]').to\_f_1000)-(event.get('[timestamp in grok 1]').to\_f_1000))" }  
}  
Kindly help plzz.

---

<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: [May 19, 2020, 1:52pm UTC](https://discuss.elastic.co/t/comparing-two-similar-fields-in-two-grok-patterns/229062/2 "2020-05-19T13:52:24Z")

</div>

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