<?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: Subsearch Join with a where clause &amp;lt;= comparison to field from main search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548300#M155523</link>
    <description>&lt;P&gt;The key thing to know here is subsearches execute &lt;STRONG&gt;before&lt;/STRONG&gt; the main search runs.&amp;nbsp; Search for the first party in the subsearch and the second party in the main search and it should work.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Apr 2021 21:00:38 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-04-16T21:00:38Z</dc:date>
    <item>
      <title>Subsearch Join with a where clause &lt;= comparison to field from main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548294#M155522</link>
      <description>&lt;P&gt;I have a problem I'm trying to solve in a subsearch query.&lt;/P&gt;&lt;P&gt;The problem I'm trying to solve, is to monitor when two separate parties generate an event to measure the time in between, with a common &lt;STRONG&gt;assignmentId&lt;/STRONG&gt;. The main search is the first party, the subsearch pulls the second party if it exists.&lt;/P&gt;&lt;P&gt;This search *almost* gets me there:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index sourceServiceId=MyService ruleId=dbdc2f48-1b2c-4869-92ea-10a12f03e3ce
| sort -_time 
| dedup assignmentId 
| join type=left assignmentId
    [ search index=my_index sourceServiceId=MyService ruleId=1caf58a6-d4b9-4a1a-a0d7-43b590a374f5
    | dedup assignmentId 
    | sort -_time ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the above search is not exactly right, as it pulls the "last event from second party". What I need is the "first event from the second party, AFTER the first party's event".&lt;/P&gt;&lt;P&gt;So, basically I want the subsearch to be ordered in ASC time order, limiting results to those that are AFTER the found record in the main search.&lt;/P&gt;&lt;P&gt;I have tried changing the query to variations of the following search, but it does not return any data at all from the subsearch. Is it not valid to use a where clause like this in a subsearch? If not, is there another strategy I can use for this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index sourceServiceId=MyService ruleId=dbdc2f48-1b2c-4869-92ea-10a12f03e3ce
| sort -_time 
| dedup assignmentId 
| join type=left left=mainResults right=subResults assignmentId
    [ search index=my_index sourceServiceId=MyService ruleId=1caf58a6-d4b9-4a1a-a0d7-43b590a374f5
    | sort 1 +_time
    | where subResults._time &amp;gt; mainResults._time ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 19:58:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548294#M155522</guid>
      <dc:creator>kfancy</dc:creator>
      <dc:date>2021-04-16T19:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch Join with a where clause &lt;= comparison to field from main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548300#M155523</link>
      <description>&lt;P&gt;The key thing to know here is subsearches execute &lt;STRONG&gt;before&lt;/STRONG&gt; the main search runs.&amp;nbsp; Search for the first party in the subsearch and the second party in the main search and it should work.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 21:00:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548300#M155523</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-04-16T21:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch Join with a where clause &lt;= comparison to field from main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548622#M155639</link>
      <description>&lt;P&gt;Unfortunately I can't do that, as sometimes the end event doesn't exist yet (async user behaviours...), which results in not finding the starting event, which is required.&lt;/P&gt;&lt;P&gt;Is there another possible approach to use?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 15:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-Join-with-a-where-clause-lt-comparison-to-field-from/m-p/548622#M155639</guid>
      <dc:creator>kfancy</dc:creator>
      <dc:date>2021-04-20T15:43:29Z</dc:date>
    </item>
  </channel>
</rss>

