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
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...