<?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 and pass value to sub search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506223#M141632</link>
    <description>&lt;P&gt;&amp;nbsp;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/202289"&gt;@harkirat9712&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I understand the data format correctly, the combined search could be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST (sourcetype=source1 OR sourcetype=source2) (url="/api/v1/test" OR (url="/api/*/*/*" AND Response_Status="200"))
| rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)"
| eval matchUrl="\/api\/[^\/]*\/".id."\/.*"
| where (url="/api/v1/test" OR match(url,matchUrl))
| table _time id url&lt;/LI-CODE&gt;&lt;P&gt;and the rex for the second would be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST sourcetype=source1  url="/api/v1/test" 
| rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)" 
| table _time id
| join max=0 id [
  search index=TEST sourcetype=source2 url="/api/*/*/*" Response_Status="200" 
  | rex field=url "\/api\/[^\/]*/(?&amp;lt;id&amp;gt;[\d.]+)\/"
  | rename _time as sub_time
  | table id sub_time url 
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I hope this is what you need. I have just removed the values() part of what I thought was in the data, so now it's just looking for the id between the //&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jun 2020 21:57:18 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2020-06-25T21:57:18Z</dc:date>
    <item>
      <title>Join and pass value to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506071#M141589</link>
      <description>&lt;P&gt;HI Team,&lt;/P&gt;&lt;P&gt;I would like to use join to search for "id" and pass it to sub search and need the consolidate result with time.&lt;/P&gt;&lt;P&gt;search 1: searching for value next to "id" provide me list&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST sourcetype=source1  url="/api/v1/test" |  rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)" | table _time id&lt;/LI-CODE&gt;&lt;P&gt;Above search gives me integer "id" I will pass in search2.&lt;/P&gt;&lt;P&gt;Search2:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST sourcetype=source2 url="/api/*/values(id)/*" Response_Status="200" | table url _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need output from search2 referencing id from search 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 23:12:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506071#M141589</guid>
      <dc:creator>harkirat9712</dc:creator>
      <dc:date>2020-06-24T23:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Join and pass value to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506073#M141591</link>
      <description>&lt;P&gt;Subsearches run before the outer search, so what you want to do is not possible.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.4/Search/Aboutsubsearches" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.4/Search/Aboutsubsearches&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However, you can do the outer search which collects both data sets and then picks the rows wanted&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST (sourcetype=source1 OR sourcetype=source2) (url="/api/v1/test" OR (url="/api/*/values(id)/*" AND Response_Status="200"))
| rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)"
| eval matchUrl="\/api\/[^\/]*\/values\(".id."\)\/.*"
| where (url="/api/v1/test" OR match(url,matchUrl))
| table _time id url&lt;/LI-CODE&gt;&lt;P&gt;or you could do a join where you&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST sourcetype=source1  url="/api/v1/test" 
| rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)" 
| table _time id
| join max=0 id [
  search index=TEST sourcetype=source2 url="/api/*/values(*)/*" Response_Status="200" 
  | rex field=url "\/api\/[^\/]*/values\((?&amp;lt;id&amp;gt;[\d.]+)\)\/"
  | rename _time as sub_time
  | table id sub_time url 
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not tested either search as I don't have a suitable data set. The join will give you a different output where the second searches are joined together with the parent, whereas the first will give you interleaved rows, but of course you can aggregate with stats.&lt;/P&gt;&lt;P&gt;The join approach can be difficult to debug, as there are limitations on join subsearches, particularly if your data set is large.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hopefully this gives you a start.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 00:10:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506073#M141591</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-06-25T00:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join and pass value to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506107#M141604</link>
      <description>&lt;P&gt;Small correction:&lt;/P&gt;&lt;P&gt;url in&amp;nbsp;&lt;SPAN&gt;Search2:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;url="/api/*/value-of-id-from-search-1/*"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/api/run1/2982989/done*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST sourcetype=source2 url="/api/*/values-of-id/*" Response_Status="200" | table url _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am now stuck on . Could you please correct below?&lt;/P&gt;&lt;P&gt;in answer-1&amp;nbsp;&lt;/P&gt;&lt;P&gt;eval matchUrl="\/api\/[^\/]*\/values\(".id."\)\/.*"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in answer-2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rex field=url "\/api\/[^\/]*/values\((?&amp;lt;id&amp;gt;[\d.]+)\)\/"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 07:39:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506107#M141604</guid>
      <dc:creator>harkirat9712</dc:creator>
      <dc:date>2020-06-25T07:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Join and pass value to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506186#M141629</link>
      <description>Does the command map &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.3/SearchReference/Map" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.3/SearchReference/Map&lt;/A&gt; help you?</description>
      <pubDate>Thu, 25 Jun 2020 16:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506186#M141629</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-06-25T16:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Join and pass value to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506223#M141632</link>
      <description>&lt;P&gt;&amp;nbsp;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/202289"&gt;@harkirat9712&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I understand the data format correctly, the combined search could be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST (sourcetype=source1 OR sourcetype=source2) (url="/api/v1/test" OR (url="/api/*/*/*" AND Response_Status="200"))
| rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)"
| eval matchUrl="\/api\/[^\/]*\/".id."\/.*"
| where (url="/api/v1/test" OR match(url,matchUrl))
| table _time id url&lt;/LI-CODE&gt;&lt;P&gt;and the rex for the second would be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=TEST sourcetype=source1  url="/api/v1/test" 
| rex "'id':'(?&amp;lt;id&amp;gt;[\d.]+)" 
| table _time id
| join max=0 id [
  search index=TEST sourcetype=source2 url="/api/*/*/*" Response_Status="200" 
  | rex field=url "\/api\/[^\/]*/(?&amp;lt;id&amp;gt;[\d.]+)\/"
  | rename _time as sub_time
  | table id sub_time url 
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I hope this is what you need. I have just removed the values() part of what I thought was in the data, so now it's just looking for the id between the //&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 21:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-and-pass-value-to-sub-search/m-p/506223#M141632</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-06-25T21:57:18Z</dc:date>
    </item>
  </channel>
</rss>

