<?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: Find difference between time now and last event time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-difference-between-time-now-and-last-event-time/m-p/288315#M165089</link>
    <description>&lt;P&gt;First problem with this query was that you're trying to arithmetic operation of string fields (strftime give string formatted date). You need timestamps in epoch format and format it later if needed. Second thing, not problem but big scope of optimization is to use tstats command instead of regular search. So give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats max(_time) as last_event WHERE index=.......
| eval diff=tostring(now()-last_event,"duration") | table diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Nov 2017 21:24:07 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-11-16T21:24:07Z</dc:date>
    <item>
      <title>Find difference between time now and last event time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-difference-between-time-now-and-last-event-time/m-p/288314#M165088</link>
      <description>&lt;P&gt;I am not sure why I am not getting results with this query, any suggestions?&lt;/P&gt;

&lt;P&gt;index= ______&lt;BR /&gt;
| stats max(_time) as last_event &lt;BR /&gt;
| eval timenow=strftime(now(), "%Y-%m-%d %H:%M:%S.%3N")&lt;BR /&gt;
| eval last_event=strftime('last_event', "%Y-%m-%d %H:%M:%S.%3N") &lt;BR /&gt;
| eval diff = tostring((timenow - last_event), "duration") &lt;BR /&gt;
| table diff &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:49:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-difference-between-time-now-and-last-event-time/m-p/288314#M165088</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2020-09-29T16:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find difference between time now and last event time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-difference-between-time-now-and-last-event-time/m-p/288315#M165089</link>
      <description>&lt;P&gt;First problem with this query was that you're trying to arithmetic operation of string fields (strftime give string formatted date). You need timestamps in epoch format and format it later if needed. Second thing, not problem but big scope of optimization is to use tstats command instead of regular search. So give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats max(_time) as last_event WHERE index=.......
| eval diff=tostring(now()-last_event,"duration") | table diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 21:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-difference-between-time-now-and-last-event-time/m-p/288315#M165089</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-16T21:24:07Z</dc:date>
    </item>
  </channel>
</rss>

