<?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 to combine two sources from same index with a common field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393132#M114369</link>
    <description>&lt;P&gt;If ID is the only common field, then grouping by other field would not give you any results. Whats your requirement here?&lt;/P&gt;</description>
    <pubDate>Wed, 16 May 2018 18:29:45 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-05-16T18:29:45Z</dc:date>
    <item>
      <title>how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393131#M114368</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have and index=A with two sources A and B  and I want to get two fields(Geo_Name,Geo_Type) from source B using the ID as common field and do what ever stats on that&lt;/P&gt;

&lt;P&gt;Below are the sources with fields&lt;/P&gt;

&lt;P&gt;source A=ID,Views,Co,Camp,Creative,Insertion_Order,Place,Site,Co&lt;BR /&gt;
sourceB=ID,Views,Camp,Creative,Insertion_Order,Place,Geo_Name,_Geo_type&lt;/P&gt;

&lt;P&gt;Below is the query I am using&lt;/P&gt;

&lt;P&gt;index=main sourcetype=sftp (source=A OR source=B) &lt;BR /&gt;
| stats dc(source) as count sum(Views) as views values("Co") as CO values(Geo_Name) as GEO by ID&lt;BR /&gt;
|search count=2|fields- count&lt;/P&gt;

&lt;P&gt;but when a I do the stats by Co instead of ID(common field) I dont get any results&lt;/P&gt;

&lt;P&gt;index=main sourcetype=sftp (source=A OR source=B) &lt;BR /&gt;
| stats dc(source) as count sum(Views) as views values("Co") as CO values(Geo_Name) as GEO by "Co"&lt;BR /&gt;
|search count=2|fields- count&lt;/P&gt;

&lt;P&gt;Does join work ? or any other command which gives that&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:29:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393131#M114368</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-29T19:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393132#M114369</link>
      <description>&lt;P&gt;If ID is the only common field, then grouping by other field would not give you any results. Whats your requirement here?&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 18:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393132#M114369</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-16T18:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393133#M114370</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;Sorry for the confusion .Let me be clear in my explanation&lt;/P&gt;

&lt;P&gt;Both source A and B are csv files which are ingested into splunk everyday through a script, Source A has Site and CO which are not there in Source B and Source B has  two fields (Geo_Name,_Geo_type) which are not there in Source A. I want to combine these based on a common field of many,I took ID as common field .&lt;/P&gt;

&lt;P&gt;source A=ID,Views,Co,Camp,Creative,Insertion_Order,Place,Site,Co&lt;BR /&gt;
sourceB=ID,Views,Camp,Creative,Insertion_Order,Place,Geo_Name,_Geo_type&lt;/P&gt;

&lt;P&gt;but the second query when I ran by Co does nit give any results.What  is the best way to join all these fields and do necessary stats command&lt;/P&gt;

&lt;P&gt;index=main sourcetype=sftp (source=A OR source=B) &lt;BR /&gt;
| stats dc(source) as count sum(Views) as views values("Co") as CO values(Geo_Name) as GEO by "Co"&lt;BR /&gt;
|search count=2|fields- count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393133#M114370</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-29T19:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393134#M114371</link>
      <description>&lt;P&gt;I see two &lt;CODE&gt;Co&lt;/CODE&gt; in sourceA. Is that a typo? If its a type and field &lt;CODE&gt;Co&lt;/CODE&gt; is not common in both sources, your stats will only aggregate data from one source (sourceA) and dc(source) will be 1. Hence your filter after stats will not show any result.&lt;/P&gt;

&lt;P&gt;When trying to join two sources,  fields in by clause of stats should be the field or fields that are common in both sources and uniquely identify a record. So, if field &lt;CODE&gt;Co&lt;/CODE&gt; alone can't do the above, you should use ID or combination of ID and Co.&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 15:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393134#M114371</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-17T15:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393135#M114372</link>
      <description>&lt;P&gt;Ya Co is a field.How to use the combination of both ID and Co,as I want the results by Co ,instead of values which accumulates all of them&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 15:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393135#M114372</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2018-05-17T15:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393136#M114373</link>
      <description>&lt;P&gt;Does field &lt;CODE&gt;Co&lt;/CODE&gt; exists in both ? Your list of fields shows different but your comment says otherwise. You can only combine two sources if there are common fields (name and value wise). If field &lt;CODE&gt;Co&lt;/CODE&gt; exists in both then your query should work fine. If it doesnt, you'd need to do stats twice, first to populate &lt;CODE&gt;Co&lt;/CODE&gt; to all rows and then aggregate by field &lt;CODE&gt;Co&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=sftp (source=A OR source=B) 
| stats dc(source) as count sum(Views) as Views values(Site) as Site values("Co") as Co values(Geo_Name) as Geo_Name by ID
|search count=2|fields- count
| stats sum(Views) as Views values(Site) as Site  values(Geo_Name) as GEO by Co
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 May 2018 15:45:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393136#M114373</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-17T15:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to combine two sources from same index with a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393137#M114374</link>
      <description>&lt;P&gt;I see what you are saying,it does not work without the common one if you do a by.&lt;/P&gt;

&lt;P&gt;Thanks somesoni2&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 16:00:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-combine-two-sources-from-same-index-with-a-common-field/m-p/393137#M114374</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2018-05-17T16:00:04Z</dc:date>
    </item>
  </channel>
</rss>

