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!

Index This | What’s a riddle wrapped in an enigma?

September 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

BORE at .conf25

Boss Of Regular Expression (BORE) was an interactive session run again this year at .conf25 by the brilliant ...

OpenTelemetry for Legacy Apps? Yes, You Can!

This article is a follow-up to my previous article posted on the OpenTelemetry Blog, "Your Critical Legacy App ...