Splunk Search

How to achieve complex filtering on MVFields?

ett
Engager

I am attempting to build a search that pulls back all logs that have a value in a multi-value field but do not have other values. With a few values I do not care if exist or not.

To break it down more.

The field "names" must have "bob".
The field "names" can have any or all "tom","dan","harry" but is not required to have them.
The field "names" cannot have any other value.
I do not have a full list of the names and they can change over time so it is not possible to make a list of the "names" I do not want.

I need other values from the logs just filtering by the "names" field as an example.

As a few examples:

"bob"= returned in the search
"bob","tom" = returned in the search
"tom","dan" = not returned in the search
"bob","sam" = not returned in the search
"bob","harry","fred" = not returned in search

I am having trouble figuring out what to use to exclude multi-value fields in this way.

Labels (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try (first 4 lines are to generate sample data, replace it with your search)

|  makeresults 
|  eval names=split("bob bob,tom tom,**bleep** bob,sam bob,harry,fred"," ") 
|  mvexpand names
| eval name=split(names,",")
| where isnotnull(mvfind(names,"bob")) AND isnull(mvfilter(NOT match(names,"(bob|tom|\*\*bleep\*\*|harry)$")))

 

View solution in original post

somesoni2
Revered Legend

Give this a try (first 4 lines are to generate sample data, replace it with your search)

|  makeresults 
|  eval names=split("bob bob,tom tom,**bleep** bob,sam bob,harry,fred"," ") 
|  mvexpand names
| eval name=split(names,",")
| where isnotnull(mvfind(names,"bob")) AND isnull(mvfilter(NOT match(names,"(bob|tom|\*\*bleep\*\*|harry)$")))

 

ett
Engager

That where line at the bottom got me where I needed to be.

Thank you for your quick response. 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...