<?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: Finding the _time difference between two subsearches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59001#M14533</link>
    <description>&lt;P&gt;The first search worked great, but the results scared me. Thanks for the help. I was definitely making it more complicated than I should have.&lt;/P&gt;</description>
    <pubDate>Fri, 25 May 2012 18:42:16 GMT</pubDate>
    <dc:creator>nelsonb</dc:creator>
    <dc:date>2012-05-25T18:42:16Z</dc:date>
    <item>
      <title>Finding the _time difference between two subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/58999#M14531</link>
      <description>&lt;P&gt;I'm unable to get this search to output anything except the _time of the first search:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|set diff [ search index="collect" host="app*" | regex _raw="backgroundWorkerLoad\w+Completed(?!\sEND)" | dedup source | rename _time AS time_one ] [ search index="collect" host="app*" | regex _raw="backgroundWorkerLoad\w+Completed\sEND" | dedup source | rename _time AS time_two ] | convert timeformat="%H:%M:%S" ctime(time_one) ctime(time_two) | eval duration=time_two-time_one | table source time_one time_two duration&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;anyway it's a logfile that timestamps when the backgroundworker sub starts a routine followed by another entry where it ENDs. It happens multiple times per source so dedup being used in this way probably isn't the best idea. There are many difference sources being indexed each with a unique name. Is this the way to do this? Thanks in advance. &lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2012 21:51:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/58999#M14531</guid>
      <dc:creator>nelsonb</dc:creator>
      <dc:date>2012-05-23T21:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the _time difference between two subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59000#M14532</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=collect host=app* "backgroundWorkLoad Completed" 
| stats range(_time) as duration earliest(_time) as time_one latest(_time) as time_two by source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will probably get you the right results efficiently. Otherwise:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=collect host=app* "backgroundWorkLoad Completed"
| eval time_one=if(match(_raw, "backgroundWorkerLoad\w+Completed(?!\sEND)"),_time,null()
| eval time_two=if(match(_raw, "backgroundWorkerLoad\w+Completed\sEND"),_time,null())
| stats earliest(time_one) as time_one latest(time_two) as time_two by source 
| eval duration=time_two-time_one
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should get you the same as what you appear to intend.&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2012 00:09:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59000#M14532</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-05-24T00:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the _time difference between two subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59001#M14533</link>
      <description>&lt;P&gt;The first search worked great, but the results scared me. Thanks for the help. I was definitely making it more complicated than I should have.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 18:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59001#M14533</guid>
      <dc:creator>nelsonb</dc:creator>
      <dc:date>2012-05-25T18:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the _time difference between two subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59002#M14534</link>
      <description>&lt;P&gt;The one problem with doing the stat by source though is that it's only returning one result by source. Each source has several hundred occurences of these pairs of events happening. Is there some other way to sort the returns? I'm trying a few variations.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 19:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59002#M14534</guid>
      <dc:creator>nelsonb</dc:creator>
      <dc:date>2012-05-25T19:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the _time difference between two subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59003#M14535</link>
      <description>&lt;P&gt;Okay, then you need to use the &lt;CODE&gt;transaction&lt;/CODE&gt; command, which automatically calculates duration. Something like: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=collect host=app* "backgroundWorkLoad Completed" | transaction source startswith=("backgroundWorkLoad Completed NOT END") endswith=("backgroundworkerload Completed END") maxevents=2 | table source duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;might work.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 23:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59003#M14535</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-05-25T23:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the _time difference between two subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59004#M14536</link>
      <description>&lt;P&gt;This returned all the results I was looking for. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 17:53:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-the-time-difference-between-two-subsearches/m-p/59004#M14536</guid>
      <dc:creator>nelsonb</dc:creator>
      <dc:date>2012-05-29T17:53:35Z</dc:date>
    </item>
  </channel>
</rss>

