# Logstash - Comparing two fields

**URL:** https://discuss.elastic.co/t/logstash-comparing-two-fields/82113
**Category:** Logstash
**Created:** [April 12, 2017, 8:06am UTC](https://discuss.elastic.co/t/logstash-comparing-two-fields/82113 "2017-04-12T08:06:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Raj\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raj_kumar/32/25420_2.png) [@Raj\_Kumar](https://discuss.elastic.co/u/Raj_Kumar)
#### Post date: [April 12, 2017, 8:06am UTC](https://discuss.elastic.co/t/logstash-comparing-two-fields/82113/1 "2017-04-12T08:06:31Z")

</div>

Hi All,

I was trying to compare two fields of our windows events by creating a mutate filter ,but i couldn't get any results in elasticsearch, i checked the configuration ,it seems to be Ok.Could anyone help me on this

filter {  
if "4,724" in [event\_id] {  
if [event\_data][SubjectUserName] != [event\_data][TargetUserName] {  
mutate {  
add\_field =\> {  
"match" =\> false  
}  
}  
}  
}  
}

filter {  
if "4,724" in [event\_id] {  
if [event\_data][SubjectUserName] == [event\_data][TargetUserName] {  
mutate {  
add\_field =\> {  
"match" =\> true  
}  
}  
}  
}  
}

Any help would be really helpful 🙂

Thanks In Advance,  
Raj

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [April 12, 2017, 8:23am UTC](https://discuss.elastic.co/t/logstash-comparing-two-fields/82113/2 "2017-04-12T08:23:42Z")

</div>

The

```
if "4,724" in [event_id] {

```

condition is most likely wrong. You should use

```
if [event_id] == 4724 {

```

or

```
if [event_id] == "4724" {

```

instead (depending on the data type of the `event_id` field).

---

<div class="post-metadata">

### Author: ![Raj\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raj_kumar/32/25420_2.png) [@Raj\_Kumar](https://discuss.elastic.co/u/Raj_Kumar)
#### Post date: [April 12, 2017, 8:24am UTC](https://discuss.elastic.co/t/logstash-comparing-two-fields/82113/3 "2017-04-12T08:24:53Z")

</div>

Thank you very much for your quick response 🙂

---

<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 10, 2017, 8:34am UTC](https://discuss.elastic.co/t/logstash-comparing-two-fields/82113/4 "2017-05-10T08:34:27Z")

</div>

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