Splunk Search

Compare stats of current day with previous day

aqudoos
Explorer

Hi all!
I am currently getting stats of current day as followed
Port Count
25 25
443 75
53 990

I wanted a table like this

Port Count(Previous Day) Count(Current Day)
25 25 30
443 75 40
53 990 50

My query is like this

Index=* | stats count by port

Please confirm is it possible
Please help!

0 Karma

somesoni2
Revered Legend

Try like this

index=*  earliest=-1d@d latest=now 
| eval Period=if(_time>=relative_time(now(),"@d"), "Today","Yesterday")
| chart count by port Period
0 Karma

maraman_splunk
Splunk Employee
Splunk Employee

Try :
index=* | bin _time span=1d | stats count by port,_time | timewrap 1d
with a timerange of 2 days

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @aqudoos,

Can you please try the following search?

index=* earliest=-d@d 
| stats count as current_day by port 
| append 
    [ search index=*  earliest=-2d@d latest=-1d@d 
    | stats count as previous_day by port] 
| stats values(current_day) as current_day values(previous_day) as previous_day by port

Thanks

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...