<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: use latest as part of where clause in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479199#M134324</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;foo
| timechart count span=1h
| timewrap w
| addinfo
| where relative_time(_time, "@h")==relative_time(info_max_time,"-1h@h")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Query order is wrong.&lt;BR /&gt;
If you have wrong result, try and check line by line.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2020 20:23:15 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-04-22T20:23:15Z</dc:date>
    <item>
      <title>use latest as part of where clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479194#M134319</link>
      <description>&lt;P&gt;Right now I have a search set up that compares the previous hours events to the same hour 1 week ago:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo | timechart count span=1h
| where strftime(_time, "%A %H")==strftime(relative_time(now(),"-1h"),"%A %H")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;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. &lt;BR /&gt;
I have tried the below search, however it doesn't return any events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo| timechart count span=1h
| where strftime(_time, "%A %H")==strftime(latest,"%A %H")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using addinfo, but to no avail:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo
| addinfo 
| eval high=strftime(relative_time(info_max_time, "-1h"), "%A %H")
| timechart count span=1h
| where strftime(_time, "%A %H")==high
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:58:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479194#M134319</guid>
      <dc:creator>jasonmadesometh</dc:creator>
      <dc:date>2020-04-22T12:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: use latest as part of where clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479195#M134320</link>
      <description>&lt;P&gt;did you look into the &lt;CODE&gt;timewrap&lt;/CODE&gt; command?&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Timewrap"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Timewrap&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 13:04:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479195#M134320</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2020-04-22T13:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: use latest as part of where clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479196#M134321</link>
      <description>&lt;P&gt;try &lt;CODE&gt;addinfo&lt;/CODE&gt; 's &lt;CODE&gt;info_max_time&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addinfo"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addinfo&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 13:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479196#M134321</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-22T13:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: use latest as part of where clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479197#M134322</link>
      <description>&lt;P&gt;foo&lt;BR /&gt;
| addinfo&lt;BR /&gt;
| timechart count span=1h &lt;BR /&gt;
| timewrap w&lt;BR /&gt;
| where strftime(_time, "%A %H")==strftime(relative_time(info_max_time,"-1h"),"%A %H")&lt;/P&gt;

&lt;P&gt;returns no results as well&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:04:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479197#M134322</guid>
      <dc:creator>jasonmadesometh</dc:creator>
      <dc:date>2020-09-30T05:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: use latest as part of where clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479198#M134323</link>
      <description>&lt;P&gt;Yeah, timewrap worked perfectly for the graph, though I'm trying to generate a scorecard for a dashboard. My timewrap command looks like this:&lt;BR /&gt;
    foo&lt;BR /&gt;
    | timechart count span=5m &lt;BR /&gt;
    | timewrap w&lt;BR /&gt;
    | where strftime(_time, "%A")=="Monday"&lt;/P&gt;

&lt;P&gt;And what I would like to do is replace that monday string with something I can base off the time picker's latest property&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 13:15:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479198#M134323</guid>
      <dc:creator>jasonmadesometh</dc:creator>
      <dc:date>2020-04-22T13:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: use latest as part of where clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479199#M134324</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;foo
| timechart count span=1h
| timewrap w
| addinfo
| where relative_time(_time, "@h")==relative_time(info_max_time,"-1h@h")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Query order is wrong.&lt;BR /&gt;
If you have wrong result, try and check line by line.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 20:23:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-latest-as-part-of-where-clause/m-p/479199#M134324</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-22T20:23:15Z</dc:date>
    </item>
  </channel>
</rss>

