<?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 join 2 indexes with a field searched from the first index? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112700#M29619</link>
    <description>&lt;P&gt;Never mind, I used your provided samples and created a simple search which you can use. It's the one in the answers &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Dec 2014 09:49:14 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2014-12-15T09:49:14Z</dc:date>
    <item>
      <title>How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112691#M29610</link>
      <description>&lt;P&gt;I have 2 indexes and would like to join them with a common field and the names are not same . I tried all posts with join but was unable to do it. &lt;/P&gt;

&lt;P&gt;Here is the query I tried without any luck/&lt;/P&gt;

&lt;P&gt;Index1 has field name as batch and index2 has field name as batch_id and named differently in both indexes(batch &amp;amp; batch_id). The batch field is got through a rex query but evaluated to add to the field list. Please help.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest="@w0" index=slingneat event="pushApns" 25597 
| rex field=_raw "\\\\\"time\\\\\":\\\\\"(?.*?)\\\\\",\\\\\"batch\\\\\":\\\\\"(?.*?)\\\\\",\\\\\"tms_id\\\\\":\\\\\"(?.*?)\\\\\",\\\\\"src\\\\\":\\\\\"(?.*?)\\\\\"" 
| eval batch=batch
| eval tms_id=tms_id 
| eval time=time 
| eval src=src 
| eval batch_id=batch 
| join batch_id [ search index= analyticslogs table_name="neat"  ] 
| table batch_id, client_version
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;[Edited]&lt;BR /&gt;
I am able to get the query running by making the fields common.Thanks for the answer.  I cant search on both indexes because only batch_id is common between the indexes. So I have to find first batch_id for condition in index1 and then search in other index.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112691#M29610</guid>
      <dc:creator>arungeorge09</dc:creator>
      <dc:date>2020-09-28T18:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112692#M29611</link>
      <description>&lt;P&gt;Hi arungeorge09,&lt;/P&gt;

&lt;P&gt;looks a bit over-complicated what you're doing here. &lt;/P&gt;

&lt;P&gt;Using your provide event examples, I created two files and indexed them. Using those indexed events I was able to get your result by using a very simple single search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest="@w0" ( index=slingneat event="push*" ) OR ( index= analyticslogs table_name="neat" )
| rex field=_raw "time.+?\"(?P&amp;lt;time&amp;gt;\d+).+?batch.+?\"(?P&amp;lt;batch_id&amp;gt;\d+)" 
| eval alert_text=urldecode(alert_text) | eval formatted_time=strftime(time/1000,"%F %T") 
| eval neat_client_app=if(neat_client_app!="", neat_client_app, "N/A")
| streamstats last(alert_text) AS alert_text last(os_ver) AS os_ver 
| stats count(evant) AS noofalerts by neat_client_app, os_ver, batch_id, formatted_time, alert_text
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You're using &lt;CODE&gt;eval&lt;/CODE&gt; to create fields which are not used afterwards, so I skipped them. Also, my &lt;CODE&gt;eval&lt;/CODE&gt; for &lt;CODE&gt;neat_client_app&lt;/CODE&gt; is just there because I have no clue where you got this field from.&lt;/P&gt;

&lt;P&gt;Try it and you will see that it will run much faster.&lt;/P&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2014 08:08:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112692#M29611</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-14T08:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112693#M29612</link>
      <description>&lt;P&gt;@Mus&lt;BR /&gt;
How do I use mulitple fields for join. Can you post a link.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2014 09:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112693#M29612</guid>
      <dc:creator>arungeorge09</dc:creator>
      <dc:date>2014-11-14T09:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112694#M29613</link>
      <description>&lt;P&gt;can you provide two sample events from each index? &lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2014 10:14:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112694#M29613</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-14T10:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112695#M29614</link>
      <description>&lt;P&gt;First Index&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;167&amp;gt;1 2014-11-15T16:45:44.542-07:00 cpneat05.sling.com neat 11151 gcm [meta@28281 sequenceId="43096" sysUpTime="858744854"][analytics@28281 event="pushGcm" platform="GCM" outcome="0" errorCode="0" errorDesc="Push to apns success" errorContext="TCP-SSL" operation="PUSH_GCM" opTime="46" startTime="1416095144542" appId="appId" deviceToken="token" args="{\"time\":\"1416095144194\",\"batch\":\"26966\",\"tms_id\":\"tmsId\",\"src\":\"src\"}" txId="907472412"] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second Index data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;68.230.42.81 - - [15/Nov/2014:15:45:46 -0800] "POST /da/vm HTTP/1.1" 200 30 "-" "da-android-tablet/4.1.22" "-" "unique_user=3cdee44a7b555a8486f3680f33d46e336c82a38b935ecf652357c47b1a02aef0&amp;amp;client_id=DRA_Android_Tablet&amp;amp;client_version=4.1.22&amp;amp;player_instance_id=99000445086028&amp;amp;os_name=Android&amp;amp;os_ver=4.4.2&amp;amp;partner=dish&amp;amp;app_id=appId&amp;amp;HHID=A253E6EB4D041C43E044001A4B0AA2BC&amp;amp;bundle_id=bundleId&amp;amp;lang=en&amp;amp;friendly_name=SM-T217S&amp;amp;table_name=neat&amp;amp;pns_registration_token=deviceToken&amp;amp;pns_platform=GCM&amp;amp;source_system=src&amp;amp;neat_alert_id=118124209&amp;amp;alert_metadata=%7b%22time%22:%221416095144194%22%2c%22batch%22:%2226966%22%2c%22tms_id%22:%22tmsId%22%2c%22src%22:%22src%22%7d&amp;amp;arrive_timestamp=1416095145&amp;amp;action=Media%20Card&amp;amp;pns_id=467842546567&amp;amp;alert_text=Exciting%20Game:%20Ducks%20at%20Kings%0a2-2%2c%20End%20of%203rd%20pd%0aKopitar%20power%20play%20goal%20ties%20it%20for%20Kings%2c%20forcing%20OT.&amp;amp;batch_id=26966&amp;amp;device_id=24d1d65a1b00f472&amp;amp;submit_timestamp=1416095144194&amp;amp;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Nov 2014 06:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112695#M29614</guid>
      <dc:creator>arungeorge09</dc:creator>
      <dc:date>2014-11-17T06:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112696#M29615</link>
      <description>&lt;P&gt;I have my working query now which is pretty complex but does the job &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest="@w0" index=slingneat event="push*" | rex field=_raw "\\\\\"time\\\\\":\\\\\"(?.*?)\\\\\",\\\\\"batch\\\\\":\\\\\"(?.*?)\\\\\",\\\\\"tms_id\\\\\":\\\\\"(?.*?)\\\\\",\\\\\"src\\\\\":\\\\\"(?.*?)\\\\\"" | eval batch=batch|eval tms_id=tms_id | eval time=time | eval src=src | eval batch_id=batch | eval pns_platform=platform|eval batchPlatform=batch."#".platform| join pns_platform [search index= analyticslogs table_name="neat" ]|eval alert_text=urldecode(alert_text)|eval formatted_time=strftime(time/1000,"%F %T") |stats count(event) as noofalerts by neat_client_app,os_ver,batch, formatted_time,alert_text| table neat_client_app ,os_ver, formatted_time,alert_text,batch, noofalerts
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Nov 2014 06:56:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112696#M29615</guid>
      <dc:creator>arungeorge09</dc:creator>
      <dc:date>2014-11-17T06:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112697#M29616</link>
      <description>&lt;P&gt;where is the field &lt;CODE&gt;neat_client_app&lt;/CODE&gt;  coming from?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2014 09:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112697#M29616</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-17T09:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112698#M29617</link>
      <description>&lt;P&gt;update ping....&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2014 08:23:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112698#M29617</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-19T08:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112699#M29618</link>
      <description>&lt;P&gt;Its a calculated field&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2014 09:45:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112699#M29618</guid>
      <dc:creator>arungeorge09</dc:creator>
      <dc:date>2014-12-15T09:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to join 2 indexes with a field searched from the first index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112700#M29619</link>
      <description>&lt;P&gt;Never mind, I used your provided samples and created a simple search which you can use. It's the one in the answers &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2014 09:49:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-2-indexes-with-a-field-searched-from-the-first-index/m-p/112700#M29619</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-12-15T09:49:14Z</dc:date>
    </item>
  </channel>
</rss>

