<?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 Calculate time between two different events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91744#M23679</link>
    <description>&lt;P&gt;I have log entries looking as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Nov 16 08:37:47 psdkxt05 MID=xxx005I;XID=;SID=;UID=;STM=2010-11-16 08:37:47,993;

Nov 16 08:33:08 psdkxt05 MID=xxx004E;XID=;SID=;UID=;STM=2010-11-16 08:33:08,824;

Nov 16 08:07:44 psdkxt05 MID=XXX005I;XID=;SID=;UID=;STM=2010-11-16 08:07:44,255;

Nov 16 08:03:03 psdkxt05 MID=XXX004E;XID=;SID=;UID=;STM=2010-11-16 08:03:03,120;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have to calculate the time between 004E and 005I - but I do NOT want the calculation  between 005I and 004E&lt;/P&gt;

&lt;P&gt;I have following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host = psdkxt05 MID=XXX004E OR MID=XXX005I 
| EVAL PRC=SUBSTR(MID,1,3)
| EVAL ERR=SUBSTR(MID,5,3)
| SORT -_time
| delta _time as diff
| EVAL Outage(Minutes)=ROUND(diff/-60) 
| TABLE PRC ERR Outage(Minutes) _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives following result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; 1. 1   11/16/10 8:37:47.000 AM XXX 05I
 2. 2   11/16/10 8:33:08.000 AM XXX 04E 5
 3. 3   11/16/10 8:07:44.000 AM XXX 05I 25
 4. 4   11/16/10 8:03:03.000 AM XXX    04E  5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I avoid the calculation in line 3?&lt;/P&gt;</description>
    <pubDate>Thu, 18 Nov 2010 18:33:37 GMT</pubDate>
    <dc:creator>JYTTEJ</dc:creator>
    <dc:date>2010-11-18T18:33:37Z</dc:date>
    <item>
      <title>Calculate time between two different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91744#M23679</link>
      <description>&lt;P&gt;I have log entries looking as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Nov 16 08:37:47 psdkxt05 MID=xxx005I;XID=;SID=;UID=;STM=2010-11-16 08:37:47,993;

Nov 16 08:33:08 psdkxt05 MID=xxx004E;XID=;SID=;UID=;STM=2010-11-16 08:33:08,824;

Nov 16 08:07:44 psdkxt05 MID=XXX005I;XID=;SID=;UID=;STM=2010-11-16 08:07:44,255;

Nov 16 08:03:03 psdkxt05 MID=XXX004E;XID=;SID=;UID=;STM=2010-11-16 08:03:03,120;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have to calculate the time between 004E and 005I - but I do NOT want the calculation  between 005I and 004E&lt;/P&gt;

&lt;P&gt;I have following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host = psdkxt05 MID=XXX004E OR MID=XXX005I 
| EVAL PRC=SUBSTR(MID,1,3)
| EVAL ERR=SUBSTR(MID,5,3)
| SORT -_time
| delta _time as diff
| EVAL Outage(Minutes)=ROUND(diff/-60) 
| TABLE PRC ERR Outage(Minutes) _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives following result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; 1. 1   11/16/10 8:37:47.000 AM XXX 05I
 2. 2   11/16/10 8:33:08.000 AM XXX 04E 5
 3. 3   11/16/10 8:07:44.000 AM XXX 05I 25
 4. 4   11/16/10 8:03:03.000 AM XXX    04E  5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I avoid the calculation in line 3?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2010 18:33:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91744#M23679</guid>
      <dc:creator>JYTTEJ</dc:creator>
      <dc:date>2010-11-18T18:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time between two different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91745#M23680</link>
      <description>&lt;P&gt;This looks like a good opportunity for "... | transaction ...".  When you build a transaction, it will automatically compute a "duration" field for that transaction that is the number of seconds from the beginning to end.  I don't fully understand your data, but something like this might work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=psdkxt05 MID=XXX004E OR MID=XXX005 | 
transaction beginswith=XXX004E endswith=XXX005I |
EVAL PRC=SUBSTR(MID,1,3) |
EVAL ERR=SUBSTR(MID,5,3) |
EVAL Outage(Minutes)=duration/60 |
TABLE PRC ERR Outage(Minutes) _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Transaction" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Transaction&lt;/A&gt; for more details.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2010 20:23:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91745#M23680</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2010-11-18T20:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time between two different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91746#M23681</link>
      <description>&lt;P&gt;THANK YOU!I did try the transaction before asking the question. But could not make it work- but it does now with your help :-). Thank you so much. (I am quite new in the SPLUNK world...)&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2010 21:43:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-between-two-different-events/m-p/91746#M23681</guid>
      <dc:creator>JYTTEJ</dc:creator>
      <dc:date>2010-11-18T21:43:15Z</dc:date>
    </item>
  </channel>
</rss>

