Splunk Search

How to edit my search to determine if a field has a null or blank value?

dan_pudwell
Explorer

I'm trying to determine whether a field has a value but my search isn't giving me expected results, I've tried this:

search ... | eval agentOrClient = if(detail.agentRefNo == "", "client", "agent") | table agentOrClient

This always returns agent even though the field is blank
I have also tried isnull and that gives the same result

Tags (5)
0 Karma
1 Solution

javiergn
Super Champion

To test for NULL or blank use the following instead:

search ... 
| eval agentOrClient = if('detail.agentRefNo' == "" OR isNull('detail.agentRefNo'), "client", "agent") 
| table agentOrClient

Also because of the dot in your field name it is a good practise to use single quotes when referring to the field name from within an eval statement.

View solution in original post

javiergn
Super Champion

To test for NULL or blank use the following instead:

search ... 
| eval agentOrClient = if('detail.agentRefNo' == "" OR isNull('detail.agentRefNo'), "client", "agent") 
| table agentOrClient

Also because of the dot in your field name it is a good practise to use single quotes when referring to the field name from within an eval statement.

dan_pudwell
Explorer

perfect, thanks!

0 Karma

javiergn
Super Champion

No worries. Please don't forget to mark this as answered if you like the response so that others can benefit from it in future.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...