Splunk Search

Omit time range in query

dataisbeautiful
Path Finder

I am querying a change in a value each week over last 4 weeks. Ineed to know the value from the week before the search window to work out the change correctly.

index=ind sourcetype=src (type=instrument) earliest=-5w@w+1d latest=@w+1d
| bucket _time span=7d
| stats max(reading) as WeekMax by _time
| streamstats current=f last(WeekMax) as LastWeekMax
| eval WeekDelta = WeekMax - LastWeekMax
| eval WeekDelta = if(WeekDelta < 0, 0.000000, WeekDelta)
| table _time, WeekMax, WeekDelta

I don't want to show the time for the week before the query (-5th week). Any tips on how to change this query to only show results for last 4 weeks but still calculating the change correctly?

 

Thanks

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| where _time > relative_time(now(),"-4w@w+1d")

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| where _time > relative_time(now(),"-4w@w+1d")
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 ...