<?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: Relative Time based on last event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354816#M174626</link>
    <description>&lt;P&gt;@woodcock - need to reverse the last condition.  Where each event's Last Policy Request &amp;gt;= compare_time.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2017 01:12:11 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-06-26T01:12:11Z</dc:date>
    <item>
      <title>Relative Time based on last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354813#M174623</link>
      <description>&lt;P&gt;I want to be able to compare 48 hours from my last event date, thought this would work but I keep getting 0 as my result whenever I run it... Should be closer to 1500 results&lt;/P&gt;

&lt;P&gt;Here is my query&lt;BR /&gt;
   &lt;CODE&gt;|inputlookup report.csv&lt;BR /&gt;
    | rename "location.u_number" as Store_Number &lt;BR /&gt;
    | rename u_wifi_mac_address as Mac_Address &lt;BR /&gt;
    | search u_last_policyrequest_time=* &lt;BR /&gt;
    | search "install_status" = "In Use"&lt;BR /&gt;
    | fields u_last_policyrequest_time Store_Number&lt;BR /&gt;
    | eval Last_Policy_Request = strptime(u_last_policyrequest_time, "%Y-%m-%d %H:%M") &lt;BR /&gt;
    | where Last_Policy_Request &amp;lt; relative_time(max(Last_Policy_Request),"-48h") &lt;BR /&gt;
    | stats count by Store_Number&lt;BR /&gt;
    | stats count&lt;BR /&gt;
    | appendpipe [ stats count | where count==0]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 19:23:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354813#M174623</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2017-06-15T19:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Relative Time based on last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354814#M174624</link>
      <description>&lt;P&gt;Here's your problem, I believe...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where Last_Policy_Request &amp;lt; relative_time(max(Last_Policy_Request),"-48h") |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;max()&lt;/CODE&gt; is an aggregate function, so it needs to be attached to a verb like &lt;CODE&gt;stats&lt;/CODE&gt; or &lt;CODE&gt;eventstats&lt;/CODE&gt;, or a presentation function like &lt;CODE&gt;chart&lt;/CODE&gt; or &lt;CODE&gt;timechart&lt;/CODE&gt;.  Also, since your amount of relative time is fixed, it's probably slightly more efficient to just tell splunk the number of seconds to subtract.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats max(Last_Policy_Request) as maxDate
| where (Last_Policy_Request &amp;lt; maxDate - 172800) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 03:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354814#M174624</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-16T03:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Relative Time based on last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354815#M174625</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup report.csv
| rename "location.u_number" AS Store_Number wifi_mac_address AS Mac_Address
| search u_last_policyrequest_time=* "install_status" = "In Use"
| fields u_last_policyrequest_time Store_Number
| eval Last_Policy_Request = strptime(u_last_policyrequest_time, "%Y-%m-%d %H:%M") 
| evenstats max(Last_Policy_Request) AS max_Last_Policy_Request
| eval compare_time = relative_time(max_Last_Policy_Request, "-48h")
| where Last_Policy_Request &amp;lt; compare_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The rest of the stuff doesn't really make sense to me but I think that above clears up what is supposed to happen up to here.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 00:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354815#M174625</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-26T00:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Relative Time based on last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354816#M174626</link>
      <description>&lt;P&gt;@woodcock - need to reverse the last condition.  Where each event's Last Policy Request &amp;gt;= compare_time.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 01:12:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354816#M174626</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-26T01:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Relative Time based on last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354817#M174627</link>
      <description>&lt;P&gt;Maybe, I'm not sure.  Let's let OP decide; what do you say @JoshuaJohn?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 01:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Relative-Time-based-on-last-event/m-p/354817#M174627</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-26T01:39:48Z</dc:date>
    </item>
  </channel>
</rss>

