<?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: time difference between two rows same field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281540#M84956</link>
    <description>&lt;P&gt;You should try all the answers and whichever one works best, click "Accept" to close out the question.&lt;/P&gt;</description>
    <pubDate>Sat, 17 Oct 2015 22:00:00 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-10-17T22:00:00Z</dc:date>
    <item>
      <title>time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281534#M84950</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/741i1343FC07DCBE3DA7/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How to calculate difference between both the times ? One with alertstatus=Problem and other with alertstatus=OK&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 12:13:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281534#M84950</guid>
      <dc:creator>splunksurekha</dc:creator>
      <dc:date>2015-10-16T12:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281535#M84951</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
You can use appendcols.... something like (assuming and alert name of "aname"):&lt;BR /&gt;
&lt;CODE&gt;|inputlookup yourlookupfile|search alertname=aname alertdate="*Sep 25*" AND alertstatus="Problem"|eval stime=strptime(alertdate, "%a %b %d %H:%M:%S %Y")|appendcols [|inputlookup yourlookupfile|search alertname=aname alertdate="*Sep 25*" AND alertstatus="OK"|eval etime=strptime(alertdate, "%a %b %d %H:%M:%S %Y")]|eval problemDuration_Min=((etime-stime)/60)|fields alertdate,alertname,host,hostname,problemDuration_Min&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;you can tweak your search criteria per your requirement...&lt;BR /&gt;
Check out available &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.0/SearchReference/CommonEvalFunctions#Date_and_Time_functions"&gt;time functions&lt;/A&gt; and &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.0/SearchReference/Commontimeformatvariables"&gt;Date/Time format options&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 14:49:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281535#M84951</guid>
      <dc:creator>Yasaswy</dc:creator>
      <dc:date>2015-10-16T14:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281536#M84952</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup zbxAlertReport
| search alertname="Jboss server.log size exceeded 5GB on dc10schdjob01.syd.sf.priv" alertdate="*Sep 25*"
| eval atertEpoch = strftime(alertdate, "%a %b %D %H:%M:%S %Y"
| streamstats current=f last(alertEpoch) AS nextTime
| eval  timeDelta = nextTime - alertEpoch
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Oct 2015 14:56:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281536#M84952</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-16T14:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281537#M84953</link>
      <description>&lt;P&gt;Thank you so much Yasaswy it worked. Thanks a lot. &lt;/P&gt;

&lt;P&gt;Thanks Woodcock, but somehow it didnt work for me. &lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 07:22:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281537#M84953</guid>
      <dc:creator>splunksurekha</dc:creator>
      <dc:date>2015-10-17T07:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281538#M84954</link>
      <description>&lt;P&gt;I forgot that &lt;CODE&gt;inputlookup&lt;/CODE&gt; does not create &lt;CODE&gt;_time&lt;/CODE&gt; so I went back and updated my answer so that it should work.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 14:41:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281538#M84954</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-17T14:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281539#M84955</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup zbxAlertReport | search alertname="Jboss server.log size exceeded 5GB on dc10schdjob01.syd.sf.priv" alertdate="*Sep 25* | convert mktime(alertdate)  timeformat="%a %b %D %H:%M:%S %Y" | diff attribute=alertdate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Oct 2015 18:57:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281539#M84955</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-10-17T18:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: time difference between two rows same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281540#M84956</link>
      <description>&lt;P&gt;You should try all the answers and whichever one works best, click "Accept" to close out the question.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 22:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-difference-between-two-rows-same-field/m-p/281540#M84956</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-17T22:00:00Z</dc:date>
    </item>
  </channel>
</rss>

