<?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 create a table with fields from two indexes based on one common field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247377#M73808</link>
    <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B | table index common_field,fieldC,fieldE,fieldN,fieldO | stats values(*) as * by common_field | where mvcount(index)=2 | fields  - index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will take all events from both index=A and index=B, group them by common_field, and show only the events which are present in both index (mvcount(index)=2)&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2015 15:02:31 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2015-09-30T15:02:31Z</dc:date>
    <item>
      <title>How to create a table with fields from two indexes based on one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247374#M73805</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I've found many answers to questions that are &lt;EM&gt;similar&lt;/EM&gt; to my question, but not quite the same. Still, my apologies if this has been answered before......&lt;/P&gt;

&lt;P&gt;We have live events from a web based application being indexed into, e.g., indexA&lt;BR /&gt;
We also have a daily CSV file (generated from a SQL query) being ingested into indexB&lt;/P&gt;

&lt;P&gt;The events look something like (actually they don't but I hope you will understand my example:) )&lt;BR /&gt;
indexA - &lt;STRONG&gt;common_field&lt;/STRONG&gt;, fieldB, fieldC,fieldD,fieldE&lt;BR /&gt;
IndexB - fieldM,fieldN,&lt;STRONG&gt;common_field&lt;/STRONG&gt;, fieldO,fieldP&lt;/P&gt;

&lt;P&gt;My objective is to produce a table that has...&lt;BR /&gt;
&lt;STRONG&gt;common_field&lt;/STRONG&gt;,fieldC,fieldE,fieldN,fieldO&lt;/P&gt;

&lt;P&gt;I've tried playing around with subsearches, but can't seem to get all the fields that I need. I did, also, toy with join, but got lost on that too!&lt;/P&gt;

&lt;P&gt;Thank you for any hints, tips, advice&lt;BR /&gt;
Mark.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 14:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247374#M73805</guid>
      <dc:creator>markwymer</dc:creator>
      <dc:date>2015-09-30T14:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with fields from two indexes based on one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247375#M73806</link>
      <description>&lt;P&gt;Have you tried something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexA | join common_field [search index=indexB] | table common_field,fieldC,fieldE,fieldN,fieldO
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2015 14:25:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247375#M73806</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-09-30T14:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with fields from two indexes based on one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247376#M73807</link>
      <description>&lt;P&gt;How big is that CSV you load up daily? It may make more sense to use that CSV as a lookup table. If you're already indexing, you can use &lt;CODE&gt;outputlookup&lt;/CODE&gt; to create one from it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index-with-csv | table common_field fieldA fieldB | outputlookup my-csv-lookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then use that lookup against your app logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index-with-applog | lookup my-csv-lookup common_field | table common_field fieldA fieldB ... fieldY fieldZ
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This method will be a lot more efficient than a &lt;CODE&gt;join&lt;/CODE&gt; or a &lt;CODE&gt;transaction&lt;/CODE&gt;. If you're ingesting the CSV daily (likely via a scheduled job somewhere?) you can have a scheduled search to run that &lt;CODE&gt;| outputlookup&lt;/CODE&gt; search and regenerate the lookup table within Splunk at a time shortly after the CSV gets dropped off for Splunk to index it.&lt;/P&gt;

&lt;P&gt;Alternatively, if you happen to be using DB Connect in your environment, you can use that to run your SQL query directly against your database and generate the lookup table automatically, or even use an on-the-fly lookup. However, the above should work with your existing setup.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 14:38:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247376#M73807</guid>
      <dc:creator>Ricapar</dc:creator>
      <dc:date>2015-09-30T14:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with fields from two indexes based on one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247377#M73808</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B | table index common_field,fieldC,fieldE,fieldN,fieldO | stats values(*) as * by common_field | where mvcount(index)=2 | fields  - index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will take all events from both index=A and index=B, group them by common_field, and show only the events which are present in both index (mvcount(index)=2)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 15:02:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247377#M73808</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-30T15:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with fields from two indexes based on one common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247378#M73809</link>
      <description>&lt;P&gt;Thanks for the response Ricapar. The CSV is a daily update which accumulated in Splunk so  single common_field may have multiple entries tracking its usage.&lt;/P&gt;

&lt;P&gt;You are quite correct, the most appropriate would be to use DB Connect to directly query the fields from our Data Warehouse. unfortunately, our DBA's are quite reluctant to give us, effectively, API access to the data. It &lt;EM&gt;is&lt;/EM&gt; being worked on and so are they &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 14:41:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-with-fields-from-two-indexes-based-on-one/m-p/247378#M73809</guid>
      <dc:creator>markwymer</dc:creator>
      <dc:date>2015-10-01T14:41:09Z</dc:date>
    </item>
  </channel>
</rss>

