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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...