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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...