Splunk Search

How to condense eval search query?

nicolass
Engager

Hello! Splunk newbie here - I was hoping to get some advice on how to condense this search query I have. Is there another command I can use that will make it so I don't need to have so many eval statements? What I'm trying to do with the data I have is remove any results that contain the words Okta, FIDO, Google, and Voice so I'm left with the users that have the MFA factors Password and SMS authentication. Thanks in advance!

 

 

source="test.csv" sourcetype="csv" 
| stats values("MFA Factor") as MFA, values("Last Enrolled_ISO8601") as "Last Enrolled", values( "Last Used_ISO8601") as "Last Used" by User, Login
| eval MFA= if(like(MFA,"Okta%"),null, MFA)
| eval MFA= if(like(MFA,"%FIDO%"),null, MFA)
| eval MFA= if(like(MFA,"Google%"),null, MFA)
| eval MFA= if(like(MFA,"Voice%"),null, MFA)
| where isnotnull(MFA)

 

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
source="test.csv" sourcetype="csv" 
| stats values("MFA Factor") as MFA, values("Last Enrolled_ISO8601") as "Last Enrolled", values( "Last Used_ISO8601") as "Last Used" by User, Login
| regex MFA!="Okta|FIDO|Google|Voice"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
source="test.csv" sourcetype="csv" 
| stats values("MFA Factor") as MFA, values("Last Enrolled_ISO8601") as "Last Enrolled", values( "Last Used_ISO8601") as "Last Used" by User, Login
| regex MFA!="Okta|FIDO|Google|Voice"

gcusello
SplunkTrust
SplunkTrust

Hi @nicolass,

you can use the OR option in the if confition of your eval command, something like this:

source="test.csv" sourcetype="csv" 
| stats values("MFA Factor") as MFA, values("Last Enrolled_ISO8601") as "Last Enrolled", values( "Last Used_ISO8601") as "Last Used" by User, Login
| eval MFA=if(like(MFA,"Okta%") OR like(MFA,"%FIDO%") OR like(MFA,"Google%") OR like(MFA,"Voice%"),null, MFA)
| where isnotnull(MFA)

 or use case instead if:

source="test.csv" sourcetype="csv" 
| stats values("MFA Factor") as MFA, values("Last Enrolled_ISO8601") as "Last Enrolled", values( "Last Used_ISO8601") as "Last Used" by User, Login
| eval MFA= case(like(MFA,"Okta%"),null, like(MFA,"%FIDO%"),null, like(MFA,"Google%"),null, like(MFA,"Voice%"),null)
| where isnotnull(MFA)

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

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

What You Read The Most: Splunk Lantern’s Most Popular Articles!

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