<?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: Subtract Search results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61497#M180153</link>
    <description>&lt;P&gt;Thanks, eventually figured our the ideal setting was 20m&lt;/P&gt;</description>
    <pubDate>Fri, 16 Dec 2011 16:05:41 GMT</pubDate>
    <dc:creator>lokival</dc:creator>
    <dc:date>2011-12-16T16:05:41Z</dc:date>
    <item>
      <title>Subtract Search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61493#M180149</link>
      <description>&lt;P&gt;New to splunk - Using version 4.2.3, build 105575 &lt;/P&gt;

&lt;P&gt;I need to figure out how to subtract the time between two events so as to get a duration. My current search looks like this -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id_numer | search "MsgNo=0" OR "Hang Up"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which gives me results like -&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;1  12/29/09 9:34:17.934 AM  12/29&lt;BR /&gt;
09:34:17.934 2-11150042&amp;gt; Hang Up&lt;/P&gt;

&lt;P&gt;2  12/29/09 9:29:51.043 AM  12/29&lt;BR /&gt;
09:29:51.043 2-11150042&amp;gt; RCV:&lt;BR /&gt;
SessNo=111, MsgNo=0, NextExp=0&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;How do I subtract these two results so I can get the time answer to &lt;/P&gt;

&lt;P&gt;{time of first result) - (time of second result) = total time taken&lt;/P&gt;

&lt;P&gt;That is -&lt;/P&gt;

&lt;P&gt;9:34:17.934 - 9:29:51.043 = ?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2011 03:07:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61493#M180149</guid>
      <dc:creator>lokival</dc:creator>
      <dc:date>2011-08-21T03:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract Search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61494#M180150</link>
      <description>&lt;P&gt;Do these two events have a field in common? If so, you can use the &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.3/SearchReference/Transaction"&gt;transaction command&lt;/A&gt; to do all these calculations for you. It sounds like you have the id_number field in common. If that is the case, you can do something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your search] | transaction id_number startswith="MsgNo=0" endswith="Hang Up"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will give you the duration of the transaction in a field aptly named duration.&lt;/P&gt;

&lt;P&gt;The transcations chapter in the docs is worth a read: &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.3/Knowledge/Searchfortransactions"&gt;http://docs.splunk.com/Documentation/Splunk/4.2.3/Knowledge/Searchfortransactions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2011 03:49:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61494#M180150</guid>
      <dc:creator>ftk</dc:creator>
      <dc:date>2011-08-21T03:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract Search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61495#M180151</link>
      <description>&lt;P&gt;Yes, the events have the id_number in common, but using the transaction command you describe returns 0 results.&lt;/P&gt;

&lt;P&gt;Oddly, playing with the maxspan value (10m / 30m / 45m) gives results?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2011 18:18:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61495#M180151</guid>
      <dc:creator>lokival</dc:creator>
      <dc:date>2011-08-26T18:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract Search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61496#M180152</link>
      <description>&lt;P&gt;Maxspan finds all transactions which fit into the desired time constraint. It is useful when you can guarantee a maximum time between your starting and ending events, but not if you don't know the maximum possible time.&lt;/P&gt;

&lt;P&gt;You might want to play with "startswith" and "endswith" some more; you could even take out the "startswith", then try with the query as &lt;CODE&gt;| transaction id_number endswith="Hang Up"&lt;/CODE&gt; just to see if you get any results.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2011 18:34:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61496#M180152</guid>
      <dc:creator>acdevlin</dc:creator>
      <dc:date>2011-08-26T18:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract Search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61497#M180153</link>
      <description>&lt;P&gt;Thanks, eventually figured our the ideal setting was 20m&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2011 16:05:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61497#M180153</guid>
      <dc:creator>lokival</dc:creator>
      <dc:date>2011-12-16T16:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract Search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61498#M180154</link>
      <description>&lt;P&gt;Hey guys I have a follow up question similar to this ask. I'm familiar with how transaction work, but i'm having fits trying to find or calculate the difference between duration events. Transaction groups "like" events, then sums the time within that  event grouping. Ok, enough of a rehash of the manual.&lt;/P&gt;

&lt;P&gt;My question is this. has someone come up with a way to find the duration "between" the durations? Here is my result set i'm working with. The ask is how do I get a running total of the difference 1 and 2, then 3 and 4. Of course i'll want to display this in my chart as well:D&lt;BR /&gt;
Here's what I have so far - &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;eio&lt;/EM&gt; | rex "(?i)] [(?P&lt;STATEIO&gt;[^\ ]+)\s+] [(?P&lt;ISSUEDIO&gt;[^\ ]+)" | transaction stateio startswith="issuedio=PauseIO" endswith="issuedio=ResumeIO" | eval durationstr=tostring(duration,"duration")| rename durationstr as "PauseIO Durations" | table"PauseIO Durations", _time&lt;/ISSUEDIO&gt;&lt;/STATEIO&gt;&lt;/P&gt;

&lt;P&gt;1    [requested   ] [ResumeIO       Live] &lt;BR /&gt;
         [completed   ] [ResumeIO       Live] &lt;BR /&gt;
 duration=18  &lt;/P&gt;

&lt;P&gt;2       [requested   ] [PauseIO        Live] &lt;BR /&gt;
         [completed   ] [PauseIO        Live] &lt;BR /&gt;
duration=17  &lt;/P&gt;

&lt;P&gt;3    [requested   ] [ResumeIO       Live] &lt;BR /&gt;
         [completed   ] [ResumeIO       Live] &lt;BR /&gt;
duration=18 &lt;/P&gt;

&lt;P&gt;4       [requested   ] [PauseIO        Live] &lt;BR /&gt;
         [completed   ] [PauseIO        Live] &lt;BR /&gt;
duration=17  &lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 23:00:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-Search-results/m-p/61498#M180154</guid>
      <dc:creator>deeboh</dc:creator>
      <dc:date>2012-04-16T23:00:03Z</dc:date>
    </item>
  </channel>
</rss>

