<?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: Merge two tables from two different sources in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359004#M106134</link>
    <description>&lt;P&gt;This one is not adding the data from the subquery after the join command&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2017 13:47:42 GMT</pubDate>
    <dc:creator>krrish0930</dc:creator>
    <dc:date>2017-09-27T13:47:42Z</dc:date>
    <item>
      <title>Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359000#M106130</link>
      <description>&lt;P&gt;i have a requirement to merge two tables &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**table 1**
appname      |  source 
app1         |  src1 
app2         |  src 2 
app3         |  src 3

**table 2**
appname    | userinfo
app1       | usr1
app3       | usr 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;merge two tables depending on the appname and the result should be like&lt;/P&gt;

&lt;P&gt;appname | source | userinfo&lt;BR /&gt;
app1 | src1 |  usr1&lt;BR /&gt;
app2 | src2  |&lt;BR /&gt;
app3  | src3  | usr3&lt;BR /&gt;
I have tried something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=appdata | spath path=result{} output=x|mvexpand x | stats latest(src) by appname
| join type=left appname [| search index=usrdata | spath path=result{} output=x | mvexpand x | table appname userinfo]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this query is populating data from only the first search before the join command.&lt;/P&gt;

&lt;P&gt;Any help is much appreciated. Thanks!!!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 16:20:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359000#M106130</guid>
      <dc:creator>krrish0930</dc:creator>
      <dc:date>2017-09-26T16:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359001#M106131</link>
      <description>&lt;P&gt;The pipe before &lt;CODE&gt;search&lt;/CODE&gt; in your subsearch is probably one error.  There may be others.&lt;/P&gt;

&lt;P&gt;I'd use this sort of format to do that (assuming there aren't more than about 10K relevant events in usrdata) ... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=appdata 
| spath path=result{} output=x
| mvexpand x 
| stats latest(src) as src by appname
| append [search index=usrdata 
     | spath path=result{} output=y 
     | mvexpand y 
     | table appname userinfo]
| stats values(src) as src values(userinfo) as userinfo by appname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The other thing I'd check is whether &lt;CODE&gt;src&lt;/CODE&gt; needs to be &lt;CODE&gt;x.src&lt;/CODE&gt; and &lt;CODE&gt;appname&lt;/CODE&gt; and &lt;CODE&gt;userinfo&lt;/CODE&gt; need to be &lt;CODE&gt;y.appname&lt;/CODE&gt; and &lt;CODE&gt;y.userinfo&lt;/CODE&gt;.  run each part of the seaerch independently with &lt;CODE&gt;|head 5&lt;/CODE&gt; to get ssample output to verify that you are getting good results.&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;mvexpand&lt;/CODE&gt;  verb is assuming that there will be a multivalue field called x (or y in the subsearch).  If x (or y) is not an mv field, then it won't hurt, but it is redundant.   &lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 20:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359001#M106131</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-26T20:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359002#M106132</link>
      <description>&lt;P&gt;Thanks for the help DalJeanis. It helped big time but the only thing is when i have tried searching using the query which you gave. It displayed duplicate values like below.&lt;/P&gt;

&lt;P&gt;Appname |  source | userinfo&lt;BR /&gt;
app1        | src 1 |&lt;BR /&gt;
app1        |          | usr1&lt;BR /&gt;
app2        | src 2 |&lt;BR /&gt;
app3         |src3   | &lt;BR /&gt;
app3         |           | usr3&lt;/P&gt;

&lt;P&gt;can you suggest me a way to remove duplicates and give everything in a single line like&lt;BR /&gt;
app1 | src1 | usr1&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 20:55:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359002#M106132</guid>
      <dc:creator>krrish0930</dc:creator>
      <dc:date>2017-09-26T20:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359003#M106133</link>
      <description>&lt;P&gt;Hi - I did with 2 CSV indexes&lt;BR /&gt;
mapping - app=appname , source=sc , userinfo=us&lt;/P&gt;

&lt;P&gt;index="app1" &lt;BR /&gt;
| stats values(app),values(sc) by app&lt;BR /&gt;
| mvexpand values(app)&lt;BR /&gt;
| mvexpand values(sc)&lt;BR /&gt;
| join type=left app [search index="app2" &lt;BR /&gt;
    |stats values(app),values(us) by app&lt;BR /&gt;
    |   mvexpand values(app) &lt;BR /&gt;
    | mvexpand values(us) ] &lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 08:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359003#M106133</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-27T08:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359004#M106134</link>
      <description>&lt;P&gt;This one is not adding the data from the subquery after the join command&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 13:47:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359004#M106134</guid>
      <dc:creator>krrish0930</dc:creator>
      <dc:date>2017-09-27T13:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359005#M106135</link>
      <description>&lt;P&gt;Plz check the field mapping it works for me&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 14:02:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359005#M106135</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-27T14:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two tables from two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359006#M106136</link>
      <description>&lt;P&gt;Hmmm.  That can't happen from that search language, because the &lt;CODE&gt;stats&lt;/CODE&gt; command will roll them together.&lt;/P&gt;

&lt;P&gt;Please verify that you are running with the &lt;CODE&gt;stats&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;If this is happening with the &lt;CODE&gt;stats&lt;/CODE&gt; command, that would indicate that there are trailing spaces or other unprintable characters at the end of the &lt;CODE&gt;appname&lt;/CODE&gt; field in the &lt;CODE&gt;usrdata&lt;/CODE&gt; index.  If so, then add this immediately before the &lt;CODE&gt;stats&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed field=appname "s/^(\S+)\s+$/\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2017 14:53:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-two-tables-from-two-different-sources/m-p/359006#M106136</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-27T14:53:50Z</dc:date>
    </item>
  </channel>
</rss>

