Splunk Search

Help with CASE

efelder0
Communicator

How do I assign the value "Informational" to the field Severity when the AV Version contains NULL values byu using the Case:

Severity= Informational
AV Version = NULL

eval Severity =case (AV_Version = NULL, "Informational") --> this does not work

PLease advise.. thx

Tags (2)
0 Karma

efelder0
Communicator

Here is the actual search string:

    sourcetype="McAfee ePo - All" |
    sort DAT_Version__VirusScan_Enterprise_ |
    eval AV_Version=DAT_Version__VirusScan_Enterprise_ |
    eval Version_Diff=Current_DAT_Version- 
    DAT_Version__VirusScan_Enterprise_ |
    eval Severity =case(
    DAT_Version__VirusScan_Enterprise_ = 0, "Informational",        
    DAT_Version__VirusScan_Enterprise_ == "", "Informational",
    Version_Diff >= 0 AND Version_Diff <= 5, "Low",
    Version_Diff > 5 AND Version_Diff <= 10, "Medium",
    Version_Diff > 10, "High",
    DAT_Version__VirusScan_Enterprise_ = "N/A", "Informational") |
    table System_Name Last_Communication Current_DAT_Version AV_Version Severity Engine_Version__VirusScan_Enterprise_ 
0 Karma

Drainy
Champion

hmm, best effort at making it more readable

0 Karma

joshd
Builder

Can you edit your post, highlight the search string you have above and click the code button on the menu bar so that it pastes properly and does not apply automatic formatting.

0 Karma

efelder0
Communicator

That field being extracted is blank...

0 Karma

joshd
Builder

Sorry I dont quite understand... are you confirming the field is being extracted even if it's blank or NULL? If you do just a regular search for null values it returns events? for example: * | where isnull(AV_Version)

0 Karma

efelder0
Communicator

Neither of the above mentioned seems to be working..

DO you have example of the len() command?

0 Karma

joshd
Builder

And you are sure the AV_Version field is being extracted and appears in the events even if it's NULL or blank? For len you would just do ... | eval Severity=if(len(AV_Version)==0,"Informational",AV_Version)

0 Karma

efelder0
Communicator

SOrry, I am looking for blank values.

So, eval Severity=case (AV_Version == "", "Informational") should work??

0 Karma

joshd
Builder

That or you can use the if and isnull combination mentioned ... or you can go as far as to use len() to check the string length, if it's 0 then you know its empty 🙂

0 Karma

joshd
Builder

Are you looking for the word NULL in AV_Version or just blank values? If you want to use case then you're missing a couple things... this should work..

eval Severity=case(AV_Version == "NULL", "Informational", AV_Version == "", "Informational")

You can also look at using the isnull() and if() functions...

eval Severity=if(isnull(AV_Version),"Informational",AV_Version)
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!

Meet Splunk Observability Studio: AI-Assisted OpenTelemetry Instrumentation Without ...

Instrumentation is usually the last step or even an afterthought when building out a project. The feature ...

Federated Search for Cisco Security and Analytics Logging (SAL) is now GA on Splunk ...

Federated Search for Cisco  Security Analytics and Logging (SAL) is now generally available as part of the ...

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner   Join us for a demo-driven look at how ...