Getting Data In

How do we specify same day last week

xvxt006
Contributor

Hi,

i want to compare the traffic from today to the traffic from the same day a week back.

in the time range i have -7d@h in the from filed and left empty in the to field. Also my query is like this ....| stats count by date_hour

I don't think i am getting right stats. When i verified the same search query using custom time frame (for the same day last week) i am getting different counts. Any suggestions?

Tags (1)
1 Solution

carasso
Splunk Employee
Splunk Employee

Comparing week-over-week results used to a pain in Splunk, with complex date calculations. No more. Now there is a better way.

I wrote a convenient search command called "timewrap" that does it all, for arbitrary time periods.

... | timechart count span=1h | timewrap w 

That's it!

If you want to limit it to a specific day of the week, add:

... | where strftime(_time, "%A") == "Wednesday"

http://apps.splunk.com/app/1645/

View solution in original post

MayankChandra
Engager

@kristian_kolb Suppose we want splunk to evaluate yesterday's day on its own and we dont mention specific day of the week like "Wednesday"  and then use yesterday's day of week to compare data with same day of week for last 2 weeks, how we can achieve that?

0 Karma

carasso
Splunk Employee
Splunk Employee

Comparing week-over-week results used to a pain in Splunk, with complex date calculations. No more. Now there is a better way.

I wrote a convenient search command called "timewrap" that does it all, for arbitrary time periods.

... | timechart count span=1h | timewrap w 

That's it!

If you want to limit it to a specific day of the week, add:

... | where strftime(_time, "%A") == "Wednesday"

http://apps.splunk.com/app/1645/

xvxt006
Contributor

Thank you Kristian for your help. This is very useful.

0 Karma

kristian_kolb
Ultra Champion

well, date_hour can be wrong! Especially if you're pulling logs from more than one TZ.

_time gets the value adjusted for TZ - what you see to the left of each event.
date_hour is the hour from within the event itself.

With _time you can make searches like "what happened in the last 15 mins, across all timezones"
With date_* you can with a single search that asks questions like "who was logging on after 8.00, in their respective TZ". (Dont forget to use a wide enough timespan in the search though).

Other than that, have you looked at the DeploymentMonitor app. It contains searches that compare statistics for 'now' and 'same day/hour last week'. You could possibly gain some insights from looking at them.

Also, there is a blog post on the subject;

http://blogs.splunk.com/2012/02/19/compare-two-time-ranges-in-one-report/

Hope this helps,

Kristian

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...