# How to remove duplicate values in logstash

**URL:** <https://discuss.elastic.co/t/how-to-remove-duplicate-values-in-logstash/193769>\
**Category:** Logstash\
**Created:** [August 5, 2019, 10:37am UTC](https://discuss.elastic.co/t/how-to-remove-duplicate-values-in-logstash/193769 "2019-08-05T10:37:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sajal](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sajal](https://discuss.elastic.co/u/Sajal)\
**Post date:** [August 5, 2019, 10:37am UTC](https://discuss.elastic.co/t/how-to-remove-duplicate-values-in-logstash/193769/1 "2019-08-05T10:37:59Z")

</div>

Hi .

Unable to remove duplicate values from logstash .  
"src" =\> [  
[0] "10.207.73.1",  
[1] "10.207.73.1"  
],  
"agentName" =\> [  
[0] "sl73tdsdb1q01 ",  
[1] "sl73tdsdb1q01 "  
],  
"StoredProc" =\> [  
[0] "False",  
[1] "False"  
],  
"LEEF:1.0|Imperva|SecureSphere|12.4.0.80\_0|DeviceType" =\> "ImpervaDAMaudit|ImpervaVersion=12.4.0.80\_0|Policy=VISA",  
"srvGroup" =\> [  
[0] "VBV",  
[1] "VBV"  
],  
"2.0|ApplicationName" =\> "Default",  
"beat" =\> {  
"version" =\> "6.6.1",  
"name" =\> "[sl73splnkapp085.visa.com](http://sl73splnkapp085.visa.com)",  
"hostname" =\> "[sl73splnkapp085.visa.com](http://sl73splnkapp085.visa.com)"  
},  
"Objecttype" =\> [  
[0] "{Event.struct.operations.objectType}", [1] "{Event.struct.operations.objectType}"  
],  
"SrvName" =\> [  
[0] "Oracle Database 3DS 2.0",  
[1] "Oracle Database 3DS 2.0"  
],

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [August 6, 2019, 3:45pm UTC](https://discuss.elastic.co/t/how-to-remove-duplicate-values-in-logstash/193769/2 "2019-08-06T15:45:24Z")

</div>

I think that should to the trick:

```
ruby {
  code => "
    event.set('src', event.get('src').uniq)
    event.set('agentName', event.get('agentName').uniq)
    [.. etc. …]
  "
}

```

For all fields of the event it should be something like this, I guess:

`event.to_hash.each { |k, v | event.set(k, v.uniq) if v.is_a?Array }`

---

<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:** [September 3, 2019, 3:45pm UTC](https://discuss.elastic.co/t/how-to-remove-duplicate-values-in-logstash/193769/3 "2019-09-03T15:45:27Z")

</div>

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