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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...