<?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: join with subsearch that has different field name, and so efficiently in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74709#M18856</link>
    <description>&lt;P&gt;Still not able to come up with a join; I tried subsearch, and that's not producing the results I expect either.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Sep 2012 23:06:37 GMT</pubDate>
    <dc:creator>myudkowsky</dc:creator>
    <dc:date>2012-09-28T23:06:37Z</dc:date>
    <item>
      <title>join with subsearch that has different field name, and so efficiently</title>
      <link>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74705#M18852</link>
      <description>&lt;P&gt;I would like to join search results with subsearch results, but I need to rename or define a new field name in order to tie one search to the other properly. Unfortunately, I can't seem to get the subsearch to use that new variable name.&lt;/P&gt;

&lt;P&gt;First, the main search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo | eval join_id=parentsessionid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This finds all the foo, and the parent's session id. I name this parentsessionid as "join_id" because I want to use it to join with results from the parent session. Note that both "foo" and "bar" will have sessionid and parentsessionid fields - so I have to tread carefully, and I need to carefully check the field.&lt;/P&gt;

&lt;P&gt;Now I want to join with a subsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | join join_id [ search bar | eval join_id=sessionid ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This would seem, in theory, to join the two togther -- the "bar" information from the parent session with the "foo" information from the child.&lt;/P&gt;

&lt;P&gt;In all, the search looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo | eval join_id=parentsessionid
 | join join_id [ search bar | eval join_id=sessionid ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately, this does not work. The output is simply the result of a simple "foo" search, as if though the "bar" search never happened.&lt;/P&gt;

&lt;P&gt;For those who prefer a real example,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2c0657b033a076d7df0e2b7d8d4288c7 (call_start OR connectionid) 
 | eval join_id=parentsessionid
 | join join_id [ search 34ec4840b397715e47d33304ba1b9be0 (session event connection.connected) 
 | eval join_id=sessionid ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I also realize that this seems to hideously ineffective. I'm searching over a very large number of "bar" entries and then discarding almost all of them. I wouldn't mind a tip or two on how to make the search more efficient.  But at present I'm more concerned about getting it to work in the first place.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 15:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74705#M18852</guid>
      <dc:creator>myudkowsky</dc:creator>
      <dc:date>2012-09-28T15:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: join with subsearch that has different field name, and so efficiently</title>
      <link>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74706#M18853</link>
      <description>&lt;P&gt;I should mention that the output of each individual search is, in fact correct. &lt;/P&gt;

&lt;P&gt;That is, &lt;/P&gt;

&lt;P&gt;foo | eval join_id=parentsessionid | stats values(join_id)&lt;/P&gt;

&lt;P&gt;produces a the expected result.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:31:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74706#M18853</guid>
      <dc:creator>myudkowsky</dc:creator>
      <dc:date>2020-09-28T12:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: join with subsearch that has different field name, and so efficiently</title>
      <link>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74707#M18854</link>
      <description>&lt;P&gt;Generally it is wise to avoid &lt;CODE&gt;join&lt;/CODE&gt; if possible. It's very expensive resource-wise and there's often (though of course not always) a smoother solution that's more suited for Splunk instead of being more suited for SQL. If you can find a set of &lt;CODE&gt;eval&lt;/CODE&gt; statements that will create a &lt;CODE&gt;join_id&lt;/CODE&gt; that comes from the parent session ID in the cases where you want that, and the current session ID where you want that, you could use &lt;CODE&gt;transaction&lt;/CODE&gt; instead. It's admittedly somewhat resource consuming as well, but it's smoother and often makes more sense to use.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval join_id=if(someconditionforparentsessionid, parentsessionid, sessionid) | transaction join_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Sep 2012 15:11:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74707#M18854</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-09-28T15:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: join with subsearch that has different field name, and so efficiently</title>
      <link>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74708#M18855</link>
      <description>&lt;P&gt;Ayn,&lt;/P&gt;

&lt;P&gt;Thanks for the suggestion. Unfortunately, I have been unable so far to come up with a transaction for this, which was my first choice. AFAICT I need the specific session ID info from the "foo" search first.&lt;/P&gt;

&lt;P&gt;I'll try again, however, because your answer just gave me an idea for a new "if" that I haven't tried yet.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 15:22:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74708#M18855</guid>
      <dc:creator>myudkowsky</dc:creator>
      <dc:date>2012-09-28T15:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: join with subsearch that has different field name, and so efficiently</title>
      <link>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74709#M18856</link>
      <description>&lt;P&gt;Still not able to come up with a join; I tried subsearch, and that's not producing the results I expect either.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 23:06:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/join-with-subsearch-that-has-different-field-name-and-so/m-p/74709#M18856</guid>
      <dc:creator>myudkowsky</dc:creator>
      <dc:date>2012-09-28T23:06:37Z</dc:date>
    </item>
  </channel>
</rss>

