Splunk Search

Remove the duplicate values from each row of "FINAL" filed.

abhayneilam
Contributor

I have a column called "FINAL" which contains :

FINAL


kolkata,mumbai,kolkata
delhi,mumbai
delhi,delhi
hydrabad
hydrabad

My output should be :

FINAL


kolkata,mumbai
delhi,mumbai
delhi
hydrabad
hydrabad

I just want to remove the duplicate value from each row of "FINAL" filed..

Please help !!

Thanks in Advance,
Abhay

[all caps title edited]

0 Karma

yannK
Splunk Employee
Splunk Employee

So If the FINAL field has multiple values on each event


event1 : FINAL="kolkata,mumbai"
event2 : FINAL="delhi,mumbai"
event3 : FINAL="delhi"
event4 : FINAL="hydrabad"
event5 : FINAL="hydrabad"

Then you should make sure that the fields contains multivalues, if not, make sure to extract them.

Here is a way to remoce the comma, then remove the duplicated per event, and recombine the multivalue event.

* | makemv delim="," FINAL
| stats values(FINAL) AS FINAL by _raw
| nomv FINAL
| table FINAL

0 Karma

Simon
Contributor

Have a look at the "dedup" search command (http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/dedup):

your search | fields FINAL | dedup FINAL 

//edit: Sorry, I didn't see that you wan't remove duplicate inside the field. Is it a multi-value field or just a simple string? Do you concatenate the FINAL field first? Maybe you could use dedup before concatenating.

0 Karma

abhayneilam
Contributor

This is a multi-value string not a simple string...Please help me achieve this !!

Thanks in Advance
Abhay

0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...