Splunk Search

How to extract all unique values from a multivalue field in one event?

edrivera3
Builder

Hi

I want to extract field values that are distinct in one event. I managed to extract all the field values in the event, but I don't want those that repeat themselves.

...| rex field=_raw "El color de la casa es (?< color_casa > [a-z]{1,10})" max_match=0
1 Solution

acharlieh
Influencer

Looking at the functions for eval, I would guess that

    ... | rex field=_raw "El color de la casa es (?< color_casa > [a-z]{1,10})" max_match=0 | eval color_casa=mvdedup(color_casa)

should do the trick. If not that then:

    ... | rex field=_raw "El color de la casa es (?< color_casa > [a-z]{1,10})" max_match=0 | eval color_casa=mvdedup(mvsort(color_casa))

View solution in original post

ngatchasandra
Builder

Hi edrivera3,

Try with mvindex function, this will retrieve all values field like follow:

 ...| rex field=_raw "El color de la casa es (?< color_casa > [a-z]{1,10})" max_match=0 |eval color1=mvindex( color_casa,0) |eval color2=mvindex( color_casa,1) |eval color3=mvindex( color_casa,2) |... |table color1 color2 color3 ...
0 Karma

edrivera3
Builder

I have more than thirty values in each event and the amount of values is different for each event. Thanks anyway for your answer.

0 Karma

acharlieh
Influencer

Looking at the functions for eval, I would guess that

    ... | rex field=_raw "El color de la casa es (?< color_casa > [a-z]{1,10})" max_match=0 | eval color_casa=mvdedup(color_casa)

should do the trick. If not that then:

    ... | rex field=_raw "El color de la casa es (?< color_casa > [a-z]{1,10})" max_match=0 | eval color_casa=mvdedup(mvsort(color_casa))

edrivera3
Builder

Do you know how I could do the same but with the configuration file? (No inline)

0 Karma

acharlieh
Influencer

Assuming you're using field extraction to create the multivalued field, you may be able to use a calculated field to tweak it's value, but it's something you'd need to play with to know for certain.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...