Splunk Search

Get top values with null empty fields

locguero
Engager

Hello. I am new to splunk and regex so please bear with me. I have the following log file format

iNRPMPLANTCD: AR| iNDATETYPE: lastShift| iNTESTSTARTDATE: | iNTESTENDDATE: | iNINTERVALNBR: 1| 

I defined my fields with the following regex

(?i) iNRPMPLANTCD: (?P<iNRPMPLANTCD>[^\|]+)
(?i) iNDATETYPE: (?P<iNDATETYPE>[^\|]+)
(?i) iNTESTSTARTDATE: (?P<iNTESTSTARTDATE>[^\|]+)
(?i) iNTESTENDDATE: (?P<iNTESTENDDATE>[^\|]+)
(?i) iNINTERVALNBR: (?P<iNINTERVALNBR>[^\|]+)
  • PNAME=XBarAssembler ActivityId !=null STATUS=DEBUG | top limit=50000 iNRPMPLANTCD,iNTESTPGMCD, iNDATETYPE, iNLASTXOPTNS, iNINTERVALNBR

When I try and do a top so see the usage patterns the records that have null/empty fields are not counted. I want to count these. I have tried to use the fillnull value="Null" and I have tried eval to replace the null value with a value... eval LastOptions = if(iNLASTXOPTNS=="","Null",iNLASTXOPTNS) but I can't seem to figure out what is being held in the field to replace it with a string so it will be counted. Any help is greatly appreciated

Tags (3)
1 Solution

somesoni2
Revered Legend

Try this

PNAME=XBarAssembler ActivityId !=null STATUS=DEBUG | eval iNRPMPLANTCD=coalesce(iNRPMPLANTCD,"NULL")| eval iNTESTPGMCD=coalesce(iNTESTPGMCD,"NULL")| eval iNDATETYPE=coalesce(iNDATETYPE,"NULL")| eval iNLASTXOPTNS=coalesce(iNLASTXOPTNS,"NULL")| eval iNINTERVALNBR=coalesce(iNINTERVALNBR,"NULL")| top limit=50000 iNRPMPLANTCD,iNTESTPGMCD, iNDATETYPE, iNLASTXOPTNS, iNINTERVALNBR

View solution in original post

somesoni2
Revered Legend

Try this

PNAME=XBarAssembler ActivityId !=null STATUS=DEBUG | eval iNRPMPLANTCD=coalesce(iNRPMPLANTCD,"NULL")| eval iNTESTPGMCD=coalesce(iNTESTPGMCD,"NULL")| eval iNDATETYPE=coalesce(iNDATETYPE,"NULL")| eval iNLASTXOPTNS=coalesce(iNLASTXOPTNS,"NULL")| eval iNINTERVALNBR=coalesce(iNINTERVALNBR,"NULL")| top limit=50000 iNRPMPLANTCD,iNTESTPGMCD, iNDATETYPE, iNLASTXOPTNS, iNINTERVALNBR

locguero
Engager

Man you are awesome! That is exactly what I needed. Works like a charm.

Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...