Splunk Search

How to get earliest and latest time for the last one hour and compare it with the same hour last week?

kumina
New Member

How to get earliest and latest time for the last one hour to compare with the same hour last week for which I don't know the earliest and latest time?

For last one hour, earliest=-1h@h latest=@h is working, but I don't know how to get the same hour last week for comparison purposes.

Kindly suggest

Tags (3)
0 Karma

mkarimi17
Path Finder

How about:

    | tstats count AS hourlyCount WHERE earliest=-7d@d latest=now index=* by index, _time span=1h | eval now_hour=strftime(now(),"%H") | eval time_hour=strftime(_time,"%H") | where time_hour=now_hour-1

It looks at the previous hour and matches it for the same hour in the past 7 days

0 Karma

DalJeanis
Legend

@mkarimi17 - perhaps you should try running it. It will give the same hour for each day, not just the two, and it will not compare last week's with this week's.

0 Karma

somesoni2
Revered Legend

Or in simple way,

earliest=-1h@h-1w latest=@h-1w

gyarici
Path Finder

Hi,

If you often compare such kind of results, I will recommend you to use "Timewrap application".

You can find it in here.

It is easy to use.

Here is also FAQ pages.FAQ

Hope it helps

Thanks

Gokhan

gfuente
Motivator

Hello

What about?

earliest=-169h@h latest=-168h@h

Regards

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...