Splunk Search

Fill Null not working as expected

willadams
Contributor

I have a CSV that I am monitoring.  The CSV has lots of fields and my extraction works appropriately.  What I have noticed is that depending on the item in the CSV the field either has a value or not.  I have noticed that this appears to be common with fields all prefixed with the same term.  An example of the data set

 

comp_domain

comp_cputype

comp_department

last_logon_date

Enabled

Name

 

If I run the following SPL then for all the fields EXCEPT comp_*, SPLUNK will populate it with my value

 

index=foo 
| fillnull value="Nothing"

 

 

So using the above fields

 

fieldvalue
comp_domain 
comp_cputype 
comp_department 
last_logon_dateNothing
EnabledNothing
NameNothing

 

If I run an eval to look for null for one of the value (e.g. comp_domain) I get the same result

 

index=foo
| eval job=if(isnull(comp_domain),"Nothing here",comp_domain)

 

 

fieldvalue
comp_domain 

 

The same will happen for any field with "comp_" prefixed but works fine for fields that don't have a prefix.  

Labels (1)
Tags (2)
0 Karma

yeahnah
Motivator

Hi @willadams 

Go back to the source csv file, I suspect that it must have a whitespace value or something so Splunk does not consider it a true null value, as the eval test proves in your example.

Here's a run anywhere example of what I mean...

 

| makeresults 
| eval test=1, blank=" " , empty=""
| foreach blank empty [ eval <<FIELD>>_size=len(<<FIELD>>) ]
| foreach blank empty [ eval <<FIELD>>=if(isnull('<<FIELD>>'), "NULL", "NOT NULL") ]
| eval empty=null()
| appendpipe [
     eval test=2
   | foreach blank empty [ eval <<FIELD>>_size=len(<<FIELD>>) ]
   | foreach blank empty [ eval <<FIELD>>=if(isnull('<<FIELD>>'), "NULL", "NOT NULL") ]
]

 

Results

 
  _time blank blank_size empty empty_size test
12020-09-01 17:24:52NOT NULL1 01
22020-09-01 17:24:52NOT NULL8NULL 2


Hope this helps.

0 Karma
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!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...