Splunk Search

Remove multiple values from a multi-value field

landen99
Motivator

I would like to remove multiple values from a multi-value field.

Example:

field_multivalue = pink,fluffy,unicorns

Remove pink and fluffy so that:

field_multivalue = unicorns

I am thinking maybe:

| stats values(field1) AS field_multivalue by field2 | mvfilter

OR

| stats values(field1) AS field_multivalue by field2  | mvexpand field_multivalue | search field_multivalue!="pink" field_multivalue!="fluffy" | mvcombine field_multivalue 

How would you recommend doing this? The list of values to filter out is over a dozen.

0 Karma
1 Solution

somesoni2
Revered Legend

I would use mvfilter, specially in the cases where patterns to be filtered is small and entities in mv field is high. Like this

| gentimes start=-1 | eval field1="pink,fluffy,unicorns" | table field1 | makemv field1 delim="," | eval field1_filtered=mvfilter(NOT match(field1,"pink") AND NOT match(field1,"fluffy"))

View solution in original post

somesoni2
Revered Legend

I would use mvfilter, specially in the cases where patterns to be filtered is small and entities in mv field is high. Like this

| gentimes start=-1 | eval field1="pink,fluffy,unicorns" | table field1 | makemv field1 delim="," | eval field1_filtered=mvfilter(NOT match(field1,"pink") AND NOT match(field1,"fluffy"))
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

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 ...