Splunk Search

stats count which dont returns the same number of events between 2 different query

jip31
Motivator

hi

I use two request which normally have to count the same number of events

the first is :
| eventtype=Periph
| dedup host
| stats count

For these one I have 106 events

the second is :
For this one I have less events
I think it's due to the fact that when i execute the query some lines are empty or sometimes there is the build and not the OS and sometimes there is the OS and not the build (see attachment)

eventtype=Periph OR eventtype=OSBuild
| eval OS=if(key_path=="\registry\machine\software\wow6432node\x\master\WindowsVersion",data, null),
Build=if(key_path=="\registry\machine\software\microsoft\windows nt\currentversion\ReleaseId",data,null)
| stats values(OS) as OS values(Build) as Build by host
| stats dc(host) as host by OS, Bualt textild
| sort -OS, Build limit=5

So what I have to do in order to have the same stats count in the second query that in the first query please???

Tags (1)
0 Karma

lakshman239
Influencer

did you check using fillnull? [ assuming you are running on the same time window]

| eventtype=Periph
| fillnull value="N/A" host
| stats dc(host)

eventtype=Periph OR eventtype=OSBuild
| eval OS=if(key_path=="\registry\machine\software\wow6432node\x\master\WindowsVersion",data, null),
Build=if(key_path=="\registry\machine\software\microsoft\windows nt\currentversion\ReleaseId",data,null)
|fillnull value="N/A" OS, Build
| stats values(OS) as OS values(Build) as Build by host
| stats dc(host) as host_count by OS, Build | addcoltotals

0 Karma
Get Updates on the Splunk Community!

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

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...