<?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: Join 2 splunk searches and get the output in table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676832#M231464</link>
    <description>&lt;P&gt;Ideally, you should rewrite your search to avoid using joins as they are slow.&lt;/P&gt;&lt;P&gt;If you want to continue with joins, you subsearch should have the same field name as the joining field. The subsearch executes before the main search so in your example App1 is not known in the subsearch (in fact, none of the fields from the main search are available to the subsearch in the join).&lt;/P&gt;&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "Allocated new applicationId"
| rex field=_raw "^(?:[^ \n]* ){4}(?P&amp;lt;App1&amp;gt;.+)"
| eval _time=strftime(_time,"%Y-%m-%d %H:%M")
| table _time, App1
| rename _time as Time1
| join type=inner App1
[ search index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "OPERATION=Submit Application Request"
| rex field=_raw "^(?:[^=\n]*=){6}\w+_\d+_(?P&amp;lt;App1&amp;gt;.+)"
| eval _time=strftime(_time,"%Y-%m-%d %H:%M")
| rename _time as Time2
| table Time2, App1]
| table Time1, App1, Time2&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 07 Feb 2024 12:04:43 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2024-02-07T12:04:43Z</dc:date>
    <item>
      <title>Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676830#M231463</link>
      <description>&lt;P&gt;Search Query 1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bmanikya_0-1707306576366.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29280iC36E2411545F53A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bmanikya_0-1707306576366.png" alt="bmanikya_0-1707306576366.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Search Query 2&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bmanikya_1-1707306604874.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29281i6F39DC3F7BA4CD7B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bmanikya_1-1707306604874.png" alt="bmanikya_1-1707306604874.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Would like to join search query 1 and 2 and get the results, but no results found.&lt;/P&gt;&lt;P&gt;index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "Allocated new applicationId"&lt;BR /&gt;| rex field=_raw "^(?:[^ \n]* ){4}(?P&amp;lt;App1&amp;gt;.+)"&lt;BR /&gt;| eval _time=strftime(_time,"%Y-%m-%d %H:%M")&lt;BR /&gt;| table _time, App1&lt;BR /&gt;| rename _time as Time1&lt;BR /&gt;| join type=inner App1&lt;BR /&gt;[ search index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "OPERATION=Submit Application Request"&lt;BR /&gt;| rex field=_raw "^(?:[^=\n]*=){6}\w+_\d+_(?P&amp;lt;App2&amp;gt;.+)"&lt;BR /&gt;| eval _time=strftime(_time,"%Y-%m-%d %H:%M")&lt;BR /&gt;| table _time, App2&lt;BR /&gt;| search App2=App1&lt;BR /&gt;| rename _time as Time2]&lt;BR /&gt;| table Time1, App1, Time2, App2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 11:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676830#M231463</guid>
      <dc:creator>bmanikya</dc:creator>
      <dc:date>2024-02-07T11:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676832#M231464</link>
      <description>&lt;P&gt;Ideally, you should rewrite your search to avoid using joins as they are slow.&lt;/P&gt;&lt;P&gt;If you want to continue with joins, you subsearch should have the same field name as the joining field. The subsearch executes before the main search so in your example App1 is not known in the subsearch (in fact, none of the fields from the main search are available to the subsearch in the join).&lt;/P&gt;&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "Allocated new applicationId"
| rex field=_raw "^(?:[^ \n]* ){4}(?P&amp;lt;App1&amp;gt;.+)"
| eval _time=strftime(_time,"%Y-%m-%d %H:%M")
| table _time, App1
| rename _time as Time1
| join type=inner App1
[ search index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "OPERATION=Submit Application Request"
| rex field=_raw "^(?:[^=\n]*=){6}\w+_\d+_(?P&amp;lt;App1&amp;gt;.+)"
| eval _time=strftime(_time,"%Y-%m-%d %H:%M")
| rename _time as Time2
| table Time2, App1]
| table Time1, App1, Time2&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 07 Feb 2024 12:04:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676832#M231464</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-07T12:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676833#M231465</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254877"&gt;@bmanikya&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;at first Splunk isn't a database, so avoid to use join as usual for al of us coming from databases!&lt;/P&gt;&lt;P&gt;there are other more efficient methods to correlate events from two searches.&lt;/P&gt;&lt;P&gt;Anyway, in your search there's a thing that I don't understand:&lt;/P&gt;&lt;P&gt;in the second search you have:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| table _time, App2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| search App2=App1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but after the table command, you have only those two fields, so, where do you take the app1 field'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Anyway, try to redesign you searches using stats command and the join field as correlation key, something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "Allocated new applicationId") OR (index=imdc_gold_hadoopmon_metrics sourcetype=hadoop_resourcemanager "OPERATION=Submit Application Request")
| rex "^(?:[^ \n]* ){4}(?P&amp;lt;App1&amp;gt;.+)"
| rex "^(?:[^=\n]*=){6}\w+_\d+_(?P&amp;lt;App2&amp;gt;.+)"
| eval 
   Time1=if(searchmatch("Allocated new applicationId"),strftime(_time,"%Y-%m-%d %H:%M"),""),
   Time2=if(searchmatch("OPERATION=Submit Application Request"),strftime(_time,"%Y-%m-%d %H:%M"),""),
   app=coalesce(app1,app2)
| stats 
   values(Time1) AS Time1
   values(Time2) AS Time2
   BY app
| table Time1, App1, Time2, App2&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 12:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/676833#M231465</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-02-07T12:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677026#M231506</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;In Hadoop ResourceManager,&amp;nbsp; Once after "Operation=Submit Application Request" resourcemanager will "Allocate New ApplicationID". I would like to see how much time difference between 2 sub searches in the splunk query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 02:45:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677026#M231506</guid>
      <dc:creator>bmanikya</dc:creator>
      <dc:date>2024-02-09T02:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677029#M231507</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bmanikya_0-1707448031295.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29314iF6931DBC74A995E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bmanikya_0-1707448031295.png" alt="bmanikya_0-1707448031295.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;Results are empty for App1 and App2.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 03:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677029#M231507</guid>
      <dc:creator>bmanikya</dc:creator>
      <dc:date>2024-02-09T03:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677037#M231508</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254877"&gt;@bmanikya&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;check the regexes.&lt;/P&gt;&lt;P&gt;if you share some samples of your logs we could help you.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 08:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677037#M231508</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-02-09T08:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 splunk searches and get the output in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677040#M231509</link>
      <description>&lt;P&gt;Please share some sample anonymised events in code blocks &amp;lt;/&amp;gt; to prevent reformatting and the lose of important data.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 08:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-splunk-searches-and-get-the-output-in-table/m-p/677040#M231509</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-09T08:45:25Z</dc:date>
    </item>
  </channel>
</rss>

