Splunk Enterprise

Help with if "null" command

super_saiyan
Communicator

Hi splunkers,

I want to use "null"  command in below query. If the message is "null" then it should replace with the below message otherwise it should only display the already extracted message. 

 

| eval message= if(Actor="superman","super hero", if(Actor="emma watson","model"))

Thanks.

Labels (2)
0 Karma

somesoni2
Revered Legend

Give this a try

| eval message= coalesce(message,case(Actor="superman","super hero",Actor="emma watson","model", true(),"NA"))

super_saiyan
Communicator

Thanks for your quick response @somesoni2 
could you please also provide the spl using "isnull" ?

Really appreciate your support.

0 Karma

somesoni2
Revered Legend
| eval message= if(isnotnull(message),message,case(Actor="superman","super hero",Actor="emma watson","model", true(),"NA"))
0 Karma

inventsekar
Super Champion

Hi @super_saiyan ... please check this isnull():

|makeresults | eval Actor="emma watson" 
| eval message = if(isnull(message),if(Actor="superman","super hero", if(Actor="emma watson","model", "not emma")),message) | table message

 

if-cmd.png

 

super_saiyan
Communicator

I am getting error while using the below SPL Query

Could you please help me with that ?

super_saiyan_0-1659075047799.png

 

appreciate your help.

 

0 Karma

inventsekar
Super Champion

Hi @super_saiyan .. your "if" format was wrong.. pls check this..

|makeresults | eval Actor="emma watson" | eval message = if(isnull(message, null(),if(Actor="superman","super hero", if(Actor="emma watson","model", "not emma")) | table message

 

could you pls check this and update us with some more details:

>>> If the message is "null" then it should replace with the below message.

>>> otherwise it should only display the already extracted message. 

Get Updates on the Splunk Community!

Splunk Cloud | Empowering Splunk Administrators with Admin Config Service (ACS)

Greetings, Splunk Cloud Admins and Splunk enthusiasts! The Admin Configuration Service (ACS) team is excited ...

Tech Talk | One Log to Rule Them All

One log to rule them all: how you can centralize your troubleshooting with Splunk logs We know how important ...

Splunk Security Content for Threat Detection & Response, Q1 Roundup

Join Principal Threat Researcher, Michael Haag, as he walks through:An introduction to the Splunk Threat ...