<?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: How do you Calculate _time difference between subsearch and main search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378900#M111046</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest AND
[ search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd
| rename uid as UID | eval pub_time=_time 
| table UID pub_time 
| outputlookup pubtimes.csv
| table UID ]
| lookup pubtimes.csv UID
| eval process_time = pub_time - _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Feb 2019 05:35:23 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-02-12T05:35:23Z</dc:date>
    <item>
      <title>How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378898#M111044</link>
      <description>&lt;P&gt;I'm trying to calculate the &lt;CODE&gt;_time&lt;/CODE&gt; difference between the subsearch and main search; but if I try and pass the time through to the main search, it seems to want to include it in the actual search and return me no results.&lt;/P&gt;

&lt;P&gt;So, I have two systems, one to publish and one to ingest. For each publish in the last 4 hours, I want to look back in time and find when its ingestion was to see how long it spent in the system.  The linkage between the two searches is the "UID"; but in the subsearch, I have to rename it from &lt;CODE&gt;uid&lt;/CODE&gt; to &lt;CODE&gt;UID&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;My search as follows gives me all the ingest events for the last 4hours' worth of successfully published events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest [search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd | rename uid as UID | fields UID]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would expect something similar to this to work, although I don't know how to pass &lt;CODE&gt;pub_time&lt;/CODE&gt; through to the main search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest [search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd | rename uid as UID | eval pub_time=_time | fields UID] | eval process_time=pub_time-_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Feb 2019 15:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378898#M111044</guid>
      <dc:creator>gregorymountfor</dc:creator>
      <dc:date>2019-02-11T15:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378899#M111045</link>
      <description>&lt;P&gt;Try this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest 
| join uid 
    [ search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd 
    | eval pub_time=_time 
    | fields uid pub_time] 
| eval process_time = pub_time-_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However a faster solution is this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest 
| append 
    [ search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd 
    | eval pub_time=_time 
    | fields uid pub_time] 
| stats latest(*) as * by uid 
| eval process_time = pub_time-_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps you.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 19:57:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378899#M111045</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-11T19:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378900#M111046</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest AND
[ search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd
| rename uid as UID | eval pub_time=_time 
| table UID pub_time 
| outputlookup pubtimes.csv
| table UID ]
| lookup pubtimes.csv UID
| eval process_time = pub_time - _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Feb 2019 05:35:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378900#M111046</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T05:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378901#M111047</link>
      <description>&lt;P&gt;this gives me errors "Streamed search execute failed because: Error in 'lookup' command: Lookups: The lookup table 'pubtimes.csv' does not exist or is not available. "&lt;BR /&gt;
I've not used a lookup before so am not sure how to debug this further just yet.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 08:19:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378901#M111047</guid>
      <dc:creator>gregorymountfor</dc:creator>
      <dc:date>2019-02-12T08:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378902#M111048</link>
      <description>&lt;P&gt;I can't understand why the first version (with &lt;CODE&gt;join&lt;/CODE&gt;) doesn't work - it just returns 0 results. &lt;BR /&gt;
I tried renaming uid in the inner &amp;amp; outer search to match but no joy.&lt;/P&gt;

&lt;P&gt;The second version (with &lt;CODE&gt;append&lt;/CODE&gt;) returns the expected amount of events, but the output table is just &lt;CODE&gt;uid&lt;/CODE&gt; &amp;amp; &lt;CODE&gt;pub_time&lt;/CODE&gt; ; not actually the &lt;CODE&gt;process_time&lt;/CODE&gt; . &lt;BR /&gt;
I tried adding &lt;CODE&gt;| table uid process_time&lt;/CODE&gt; which just leaves an empty &lt;CODE&gt;process_time&lt;/CODE&gt; column, so I'm not sure that the eval is actually working&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 08:33:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378902#M111048</guid>
      <dc:creator>gregorymountfor</dc:creator>
      <dc:date>2019-02-12T08:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378903#M111049</link>
      <description>&lt;P&gt;I had a silly typo (one place had &lt;CODE&gt;pubtimes.csv&lt;/CODE&gt; and the other had &lt;CODE&gt;pRubtimes.csv&lt;/CODE&gt;.  I edited it and fixed it.  Try it again.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 08:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378903#M111049</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T08:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378904#M111050</link>
      <description>&lt;P&gt;yup, I noticed &amp;amp; corrected that. &lt;BR /&gt;
looking at the &lt;CODE&gt;outputlookup&lt;/CODE&gt; documentation, I'm suspecting that maybe I don't have appropriate permissions to use the command. I'll check that with our admin later today about that.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 08:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378904#M111050</guid>
      <dc:creator>gregorymountfor</dc:creator>
      <dc:date>2019-02-12T08:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378905#M111051</link>
      <description>&lt;P&gt;try this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest | eval start_time = _time
 | append 
     [ search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd 
     | eval pub_time=_time 
     | fields uid pub_time] 
 | stats latest(*) as * by uid 
 | eval process_time = pub_time-start_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Feb 2019 08:57:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378905#M111051</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-12T08:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378906#M111052</link>
      <description>&lt;P&gt;still no joy: for some reason the start_time is not getting populated.&lt;/P&gt;

&lt;P&gt;I put a &lt;CODE&gt;| table uid pub_time start_time&lt;/CODE&gt; after this expression and I can see that the start_time is just nonexistent.&lt;/P&gt;

&lt;P&gt;I moved the &lt;CODE&gt;eval start_time = _time&lt;/CODE&gt; to just after the subsearch (before the &lt;CODE&gt;stats latest(*)&lt;/CODE&gt; ) and now for some reason its value is exactly the same as the pub_time value&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 10:27:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378906#M111052</guid>
      <dc:creator>gregorymountfor</dc:creator>
      <dc:date>2019-02-12T10:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378907#M111053</link>
      <description>&lt;P&gt;I just tried the &lt;CODE&gt;join&lt;/CODE&gt; version again and it worked - I must have forgotten to pass the renamed UID out.&lt;/P&gt;

&lt;P&gt;So this was successful:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=mca_mmr sourcetype=ixs-9 Method=Ingest&lt;/CODE&gt;&lt;BR /&gt;
 &lt;CODE&gt;| join UID&lt;/CODE&gt;&lt;BR /&gt;
  &lt;CODE&gt;[ search index=mca_mmr earliest=-4h sourcetype=jbpm process=publishEnd&lt;/CODE&gt;&lt;BR /&gt;
 &lt;CODE&gt;| eval pub_time=_time | rename uid as UID&lt;/CODE&gt;&lt;BR /&gt;
 &lt;CODE&gt;| fields UID pub_time]&lt;/CODE&gt;&lt;BR /&gt;
 &lt;CODE&gt;| eval process_time = pub_time-_time | table UID process_time&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 10:54:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378907#M111053</guid>
      <dc:creator>gregorymountfor</dc:creator>
      <dc:date>2019-02-12T10:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Calculate _time difference between subsearch and main search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378908#M111054</link>
      <description>&lt;P&gt;Good to hear. Although it be better to get it working with &lt;CODE&gt;append|stats&lt;/CODE&gt; method too. Anyways I am sure you have other things to prioritise.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 11:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Calculate-time-difference-between-subsearch-and-main/m-p/378908#M111054</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-12T11:02:47Z</dc:date>
    </item>
  </channel>
</rss>

