Splunk Search

Timechart and Timewrap

scottmkirkland
Explorer

I am on Splunk 8.2.12.

I am trying to get a distinct count of incidents that have happened in each month, year to date. I'd like to compare that to the year prior. 

I feel like this should be pretty easy, but my results aren't showing the current year in comparison to the previous year.

This shows the current year data (2024)

(earliest=-1@y@y AND latest=now())
| eval date_month=strftime(_time, "%mon")
| eval date_year = strftime(_time, "%Y")
| timechart span=1mon dc(RMI_MastIncNumb) as "# of Incidents"

When I add | timewrap 1year series=exact time_format=%Y it ends up just showing me 2023

scottmkirkland_0-1731545180061.png

 

Labels (1)
0 Karma

scottmkirkland
Explorer

Thank you @bowesmana .

With the Time Selector set to Year to date, and not using the earliest command | timechart span=1mon count Results in 2024 as expected.

Then using the following, I end up with a timeline of 2024, but the data claiming it's 2023. But is for sure 2024 data, labeled as 2023.

| timechart span=1mon count
| timewrap 1y series=exact time_format=%Y

scottmkirkland_0-1731605640119.png

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

The reason why it's naming the series 2023 is that the current month is now November 2024, so it's wrapping by 12 months, so the first series is Dec 2023->Nov-2024 - even though you are only searching for data in the current year, the timewrap command will work out the series name based on your timewrap span of 1y

If you made the search with earliest=@y latest=+y@y, which is searching from 2024-01-01 to 2024-12-31 it will label the series correctly as 2024.

So, it's just a function of timewrap. You can see this more clearly if you set your time_format to include the month, i.e. time_format=%Y-%m - then you will get

bowesmana_0-1731624965075.png

and if you change your series=exact to relative, you will see it's 'latest_year', which means a 12 month period.

Hope this helps

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Your earliest= statement is wrong, it should be earliest=-1y@y

You have an extra @ sign (-1@y@y)

0 Karma
Get Updates on the Splunk Community!

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...