Splunk Search

event count comparison with today vs yesterday vs last week vs prior week

john_q
Explorer

Hi,
I have two strings like "opend" and "exited" in the events. So i need to count how many opened and exited today and that should be comparing today with yesterday vs last week vs prior week in the the form of line chart. legends should be like -Today-opened, -Today-exited,Yesterday-opened,Yesterday-exited and last week and prior week as well. Can you please help me.

Tags (1)
0 Karma

sandeepmakkena
Contributor
| multisearch 
     [ search index=****  "opend" earliest=-2w@w1 latest=-w@w1
     | eval what="prior week-opened"] 
     [search index=****  "exited" earliest=-2w@w1 latest=-w@w1
     | eval what="prior week-exited" ]
 [ search index=****  "opend" earliest=-w@w1 latest=@w1
     | eval what="prior week-opened"] 
     [search index=****  "exited" earliest=-w@w1 latest=@w1
     | eval what="last week-exited" ]
 [ search index=****  "opend" earliest=-1d@d latest=@d
     | eval what="last Yesterday-opened"] 
     [search index=****  "exited" earliest=-1d@d latest=@d
     | eval what="prior Yesterday-exited" ]
 [ search index=****  "opend" earliest=@d latest=+d@d
     | eval what="-Today-opened"] 
     [search index=****  "exited" earliest=@d latest=+d@d
     | eval what="-Today-exited" ]
 | chart count by date_hour what

check this.
0 Karma

pramit46
Contributor

Have you tried timewrap command?

john_q
Explorer

comparing the count using line chart time span=h??

0 Karma

yannK
Splunk Employee
Splunk Employee
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...