Splunk Search

eval isnull

subtrakt
Contributor

Hi!

Anyone know why i'm still getting NULL in my timechart?

The lookup "existing" has two columns "ticket|host_message". host_message column matches the eval expression host+CISCO_MESSAGE below... I **can get the host+message+ticket number to show up in the timechart with the following query - however if the results do not match host_message in the lookup, hostTICKET comes back null.** I want null to simply be host_message without the ticket because it does not exist on the lookup.

index=net | rex "(?i)^([^:]*:){8}(?<CISCO_LOG>.*)$" | eval host_message=host+CISCO_LOG | lookup existing host_message |  eval hostTICKET=if(isnull(hostTICKET),host_message+" "+TICKET,host_message) | timechart count by hostTICKET
Tags (3)

_brettfitz
Observer

The above eval statement does not correctly convert 0 to 0.0.0.0 and null values. Try this:

Note: replace ip with the field name you would like to convert.

 

| eval o1=floor(ip/16777216) | eval o2=floor((ip-o1*16777216)/65536) | eval o3=floor((ip-(o1*16777216+o2*65536))/256)| eval o4=ip-(o1*16777216+o2*65536+o3*256) | eval ipv4=tostring(o1)+"."+tostring(o2)+"."+tostring(o3)+"."+tostring(o4) | eval ipv4=if(ipv4="Null.Null.Null.Null","",ipv4)

 

 

0 Karma

Ayn
Legend

You're using the wrong operator for performing string concatenations. It should be ".", not "+". So, your eval statement should read

eval hostTicket=if(isnull(hostTICKET),host_message." ".TICKET,host_message

somesoni2
Revered Legend

Where is the field "hostTICKET" present? Its not coming from lookup right? Is it there in the logs?

0 Karma

lukejadamec
Super Champion

No. NULL is being filled in by the lookup statement, so when it gets to the eval the values is NULL, which is not null.

0 Karma

subtrakt
Contributor

It is still coming back as NULL for messages that are not defined in the lookup. the field after "isnull" in parentheses is supposed to be the field that could come back as null correct?

0 Karma
Get Updates on the Splunk Community!

New Year. New Skills. New Course Releases from Splunk Education

A new year often inspires reflection—and reinvention. Whether your goals include strengthening your security ...

Splunk and TLS: It doesn't have to be too hard

Overview Creating a TLS cert for Splunk usage is pretty much standard openssl.  To make life better, use an ...

Faster Insights with AI, Streamlined Cloud-Native Operations, and More New Lantern ...

Splunk Lantern is a Splunk customer success center that provides practical guidance from Splunk experts on key ...