Splunk Search

How to compare year to date values against last year

DCUpro
Explorer

Hi all,

I'm looking to create a simple bar chart that compares the monthly data from this year against the monthly data of last year.

This search seems to do the job for me but unfortunately it also shows the data for all of the months in 2019.

... | timechart count span=1mon | timewrap 1y

 

Ideally I would like to only compare year to date data of 2020 with 2019. Has anyone any tips on how I might achieve this?

Thanks for the help.

Labels (1)
0 Karma
1 Solution

thambisetty
SplunkTrust
SplunkTrust

below is the example to show yesterdays 11-12 hours count and todays 11-12hours count. you can modify below query.

index=_internal earliest="09/14/2020:11:00:00" latest="09/14/2020:12:00:00" 
| eval when="yesterday_11-12h" 
| append 
    [ search index=_internal earliest="09/15/2020:11:00:00" latest="09/15/2020:12:00:00" 
    | eval when="today_11-12h"] 
| bin span=1h _time
| eval Time=strftime(_time,"%H:%M")
| chart count over Time by when
————————————
If this helps, give a like below.

View solution in original post

DCUpro
Explorer

Thanks All,

I was able to figure it out using @thambisetty answer.

0 Karma

isoutamo
SplunkTrust
SplunkTrust
Hi
Here is older conf presentation about this https://conf.splunk.com/files/2016/slides/time-after-time-comparing-time-ranges-in-splunk.pdf
With append and sub queries you must remember those limits: 60s and 500000 events!
r. Ismo

thambisetty
SplunkTrust
SplunkTrust

below is the example to show yesterdays 11-12 hours count and todays 11-12hours count. you can modify below query.

index=_internal earliest="09/14/2020:11:00:00" latest="09/14/2020:12:00:00" 
| eval when="yesterday_11-12h" 
| append 
    [ search index=_internal earliest="09/15/2020:11:00:00" latest="09/15/2020:12:00:00" 
    | eval when="today_11-12h"] 
| bin span=1h _time
| eval Time=strftime(_time,"%H:%M")
| chart count over Time by when
————————————
If this helps, give a like below.
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...