Splunk Search

use latest as part of where clause

jasonmadesometh
Explorer

Right now I have a search set up that compares the previous hours events to the same hour 1 week ago:

foo | timechart count span=1h
| where strftime(_time, "%A %H")==strftime(relative_time(now(),"-1h"),"%A %H")

However I would like to add it to a dashboard and instead of having everything relative to "now" I would like it to be based on the time picker. How can I change the second strftime to allow me to do this? Currently I have to set the time picker to the previous 7 days to get this to work on the report, though I'm not married to that implementation.
I have tried the below search, however it doesn't return any events:

foo| timechart count span=1h
| where strftime(_time, "%A %H")==strftime(latest,"%A %H")

I tried using addinfo, but to no avail:

foo
| addinfo 
| eval high=strftime(relative_time(info_max_time, "-1h"), "%A %H")
| timechart count span=1h
| where strftime(_time, "%A %H")==high
0 Karma
1 Solution

to4kawa
Ultra Champion

jasonmadesometh
Explorer

foo
| addinfo
| timechart count span=1h
| timewrap w
| where strftime(_time, "%A %H")==strftime(relative_time(info_max_time,"-1h"),"%A %H")

returns no results as well

0 Karma

to4kawa
Ultra Champion
foo
| timechart count span=1h
| timewrap w
| addinfo
| where relative_time(_time, "@h")==relative_time(info_max_time,"-1h@h")

Query order is wrong.
If you have wrong result, try and check line by line.

adonio
Ultra Champion
0 Karma

jasonmadesometh
Explorer

Yeah, timewrap worked perfectly for the graph, though I'm trying to generate a scorecard for a dashboard. My timewrap command looks like this:
foo
| timechart count span=5m
| timewrap w
| where strftime(_time, "%A")=="Monday"

And what I would like to do is replace that monday string with something I can base off the time picker's latest property

0 Karma
Get Updates on the Splunk Community!

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 ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...