<?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 After obtaining the Time difference of two time/date fields, if the time greater than a hr create a alert. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463492#M130658</link>
    <description>&lt;P&gt;Im pretty new to splunk, so my approach may be incorrect. However, At this time my query is as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search query
| eval pollingTime=strptime(requestDate,"%Y-%m-%d %H:%M:%S.%3N") 
| eval drainingTime=strptime(receivedDate,"%Y-%m-%d %H:%M:%S.%3N")
| eval timeDiff=tostring((drainingTime-pollingTime),"duration")
| table requestDate receivedDate timeDiff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which above Im able to obtain timeDiff value in the format (00:00:0.000000). If I want check wether the value us greater then a hour how should I go about doing this?&lt;/P&gt;

&lt;P&gt;My thoughts were something like: &lt;/P&gt;

&lt;P&gt;| eval isDelayed=if(timeDiff &amp;gt;= ? )&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2019 16:53:39 GMT</pubDate>
    <dc:creator>dcephas</dc:creator>
    <dc:date>2019-12-09T16:53:39Z</dc:date>
    <item>
      <title>After obtaining the Time difference of two time/date fields, if the time greater than a hr create a alert.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463492#M130658</link>
      <description>&lt;P&gt;Im pretty new to splunk, so my approach may be incorrect. However, At this time my query is as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search query
| eval pollingTime=strptime(requestDate,"%Y-%m-%d %H:%M:%S.%3N") 
| eval drainingTime=strptime(receivedDate,"%Y-%m-%d %H:%M:%S.%3N")
| eval timeDiff=tostring((drainingTime-pollingTime),"duration")
| table requestDate receivedDate timeDiff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which above Im able to obtain timeDiff value in the format (00:00:0.000000). If I want check wether the value us greater then a hour how should I go about doing this?&lt;/P&gt;

&lt;P&gt;My thoughts were something like: &lt;/P&gt;

&lt;P&gt;| eval isDelayed=if(timeDiff &amp;gt;= ? )&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 16:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463492#M130658</guid>
      <dc:creator>dcephas</dc:creator>
      <dc:date>2019-12-09T16:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: After obtaining the Time difference of two time/date fields, if the time greater than a hr create a alert.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463493#M130659</link>
      <description>&lt;P&gt;You can perform the evaluation before converting the variable to a string. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     ...
    | eval pollingTime=strptime(requestDate,"%Y-%m-%d %H:%M:%S.%3N") 
    | eval drainingTime=strptime(receivedDate,"%Y-%m-%d %H:%M:%S.%3N")
    | eval timeDiff=(drainingTime-pollingTime)
    | where timeDiff&amp;gt;3600 
    | eval timeDiff=tostring(timeDiff, "duration")
    | table requestDate receivedDate timeDiff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If &lt;CODE&gt;timeDiff&lt;/CODE&gt; is greater than 3600 seconds (1 hour), then only those events will show up. &lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 18:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463493#M130659</guid>
      <dc:creator>zacharychristen</dc:creator>
      <dc:date>2019-12-09T18:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: After obtaining the Time difference of two time/date fields, if the time greater than a hr create a alert.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463494#M130660</link>
      <description>&lt;P&gt;Thank you this works perfectly for me&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 19:09:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/After-obtaining-the-Time-difference-of-two-time-date-fields-if/m-p/463494#M130660</guid>
      <dc:creator>dcephas</dc:creator>
      <dc:date>2019-12-09T19:09:48Z</dc:date>
    </item>
  </channel>
</rss>

