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!

Monitoring Postgres with OpenTelemetry

Behind every business-critical application, you’ll find databases. These behind-the-scenes stores power ...

Mastering Synthetic Browser Testing: Pro Tips to Keep Your Web App Running Smoothly

To start, if you're new to synthetic monitoring, I recommend exploring this synthetic monitoring overview. In ...

Splunk Edge Processor | Popular Use Cases to Get Started with Edge Processor

Splunk Edge Processor offers more efficient, flexible data transformation – helping you reduce noise, control ...