Splunk Search

How do I compare for todays and yesterdays stats/ report?

mikeyty07
Communicator

How do i compare for todays let say 9a-10a with yesterdays 9a-10a stats side by side? Is it possible on 1 qeury?

index=foo <query> | stats avg(responsetime) today and tomorrow count by uri
 

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mikeyty07,

try somerthing like this:

index=foo <query> earliest=-2d@d date_hour=9
| eval day=if(now()-_time<86400,"Today","Yesterday")
| stats avg(eval(if(day="Today",responsetime,""))) AS today avg(eval(day="Yesterday",responsetime,""))) AS yesterday BY uri

If you haven't date_hour, you have to extract it

index=foo <query> earliest=-2d@d 
| eval date_hour=strftime(_time,"%H")
| where date_hour=9
| eval day=if(now()-_time<86400,"Today","Yesterday")
| stats avg(eval(if(day="Today",responsetime,""))) AS today avg(eval(day="Yesterday",responsetime,""))) AS yesterday BY uri

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...