<?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 Help creating JOIN search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411897#M118769</link>
    <description>&lt;P&gt;I'm trying to compare Field X from Index A  with Field Y from Index B. Though the field names are different, they store the same value. IF value matches I need result from field Z  from index B&lt;/P&gt;

&lt;P&gt;Below is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = A |fields X |rename X as Y |join Y  [|search index= B] |stats values(Z) by Y
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above search doesn't work. &lt;BR /&gt;
Is it because of subsearch result limitation? &lt;BR /&gt;
Help with the correct search to achieve it.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2019 14:38:35 GMT</pubDate>
    <dc:creator>NAVEEN_CTS</dc:creator>
    <dc:date>2019-07-23T14:38:35Z</dc:date>
    <item>
      <title>Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411897#M118769</link>
      <description>&lt;P&gt;I'm trying to compare Field X from Index A  with Field Y from Index B. Though the field names are different, they store the same value. IF value matches I need result from field Z  from index B&lt;/P&gt;

&lt;P&gt;Below is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = A |fields X |rename X as Y |join Y  [|search index= B] |stats values(Z) by Y
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above search doesn't work. &lt;BR /&gt;
Is it because of subsearch result limitation? &lt;BR /&gt;
Help with the correct search to achieve it.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 14:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411897#M118769</guid>
      <dc:creator>NAVEEN_CTS</dc:creator>
      <dc:date>2019-07-23T14:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411898#M118770</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=A OR index=B | fields X Y Z | eval XY =coalesce(X,Y) | stats values(Z) by XY&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 15:00:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411898#M118770</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-07-23T15:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411899#M118771</link>
      <description>&lt;P&gt;coalesce brings all the values. I want only if  value in field X matches with value in Field Y&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 15:10:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411899#M118771</guid>
      <dc:creator>NAVEEN_CTS</dc:creator>
      <dc:date>2019-07-23T15:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411900#M118772</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B | fields X Y Z index | rename X as Y
 | stats values(Z),dc(index) as count by Y
 | where count=2|table values(Z),Y
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 15:32:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411900#M118772</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2019-07-23T15:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411901#M118773</link>
      <description>&lt;P&gt;@NAVEEN_CTS coalesce() will not bring all the values. It is just a pre-step to stats where you are creating a new field for correlation between Index A and Index B. Since X exists only in index A and Y exists only in index B when you perform &lt;CODE&gt;coalesce()&lt;/CODE&gt; it will ensure that values from both index are present as XY.&lt;/P&gt;

&lt;P&gt;Then you need to filter results which are present in both the indexes as inner join.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B 
| fields index X Y Z 
| eval XY =coalesce(X,Y) 
| stats values(Z) as Z values(index) as index by XY
| search index="A" AND index="B"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 15:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411901#M118773</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-07-23T15:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411902#M118774</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B
| fields X Y Z index
| eval X=coalesce(X, Y)
| stats values(Z) as Z, dc(index) as idx_count by X
| where idx_count&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;as illustrated by &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults| eval X="foo", index="A"
| append 
    [| makeresults| eval Y="foo", Z="bar", index="B"]
| append 
    [| makeresults| eval Y="fo", Z="br", index="B"]
| eval X=coalesce(X, Y)
| stats values(Z) as Z, dc(index) as idx_count by X
| where idx_count&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 15:40:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411902#M118774</guid>
      <dc:creator>grittonc</dc:creator>
      <dc:date>2019-07-23T15:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411903#M118775</link>
      <description>&lt;P&gt;Thank you .This worked as i expected&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 16:10:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411903#M118775</guid>
      <dc:creator>NAVEEN_CTS</dc:creator>
      <dc:date>2019-07-23T16:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411904#M118776</link>
      <description>&lt;P&gt;Ok got it . Thank you @niketnilay &lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 16:12:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411904#M118776</guid>
      <dc:creator>NAVEEN_CTS</dc:creator>
      <dc:date>2019-07-23T16:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating JOIN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411905#M118777</link>
      <description>&lt;P&gt;@NAVEEN_CTS, I am glad you found the comment useful. Personally, I prefer search with index values so that I can implement left , right, full outer join and other joins using stats command.&lt;/P&gt;

&lt;P&gt;Like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index="A" OR index="B"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index="A" AND index!="B"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index!="A" AND index="B"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc.&lt;BR /&gt;
Using &lt;CODE&gt;dc()&lt;/CODE&gt; aggregate you can only perform inner join. However, in your case since that is what you need your accepted answer should do the needful, which is the same as &lt;/P&gt;

&lt;P&gt;| search index="A" AND index="B"&lt;BR /&gt;
Do up-vote the comments if they helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 17:57:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-creating-JOIN-search/m-p/411905#M118777</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-07-23T17:57:55Z</dc:date>
    </item>
  </channel>
</rss>

