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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...