<?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: Use results from one search in another query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-results-from-one-search-in-another-query/m-p/398627#M168766</link>
    <description>&lt;P&gt;Hi dwong2,&lt;/P&gt;

&lt;P&gt;there are multiple options for this problem, but it is hard to provide the one solution that works best for you without more details.&lt;/P&gt;

&lt;P&gt;So, lets start with using a sub search: Use the search that returns the least results in the sub search, this is because sub searches have some limits that can bight you &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Aboutsubsearches#Subsearch_performance_considerations"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Aboutsubsearches#Subsearch_performance_considerations&lt;/A&gt; .&lt;/P&gt;

&lt;P&gt;A simple example would be :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=2 [ search index=1 | fields SomeFieldYouWant | format ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will search &lt;CODE&gt;index=2&lt;/CODE&gt; for a single result found in &lt;CODE&gt;index=1&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Format"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Format&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The next level is to use &lt;CODE&gt;return&lt;/CODE&gt; with a sub search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=2 [ search index=1 | fields SomeFieldYouWant | return ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will search &lt;CODE&gt;index=2&lt;/CODE&gt; for a list of &lt;CODE&gt;OR&lt;/CODE&gt; results found in &lt;CODE&gt;index=1&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Return"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Return&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The much better option is to ignore all kinds of sub searches, joins, appends, transactions at all and just use &lt;CODE&gt;stats&lt;/CODE&gt; ; Read more about the stats approach here  &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt; or here &lt;A href="http://wiki.splunk.com/Virtual_.conf"&gt;http://wiki.splunk.com/Virtual_.conf&lt;/A&gt; the March 2016 session of @sideview&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jun 2018 20:12:57 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2018-06-21T20:12:57Z</dc:date>
    <item>
      <title>Use results from one search in another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-results-from-one-search-in-another-query/m-p/398626#M168765</link>
      <description>&lt;P&gt;How do I take the results of one query and use it in another.  I want to take the results of trackedsessions and use it in the tile query. (i.e. tile/trackedsessions)&lt;/P&gt;

&lt;P&gt;tracked sessions:&lt;BR /&gt;
....search &lt;BR /&gt;
| eval View=case(like(publishId,"%U"),"unsubscribed",like(publishId,"%S"),"subscribed") &lt;BR /&gt;
| transaction startswith="Enter" endswith="Timeout" or "Exit" by deviceID View &lt;BR /&gt;
| table View deviceID eventcount&lt;BR /&gt;&lt;BR /&gt;
| stats count(deviceID) as count by View&lt;/P&gt;

&lt;P&gt;tile:&lt;BR /&gt;
...search&lt;BR /&gt;
| stats count(tile) as tile, count as trackedsessions &lt;BR /&gt;
| eval percentage=round((tile/trackedsessions*100),2)&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jun 2018 05:40:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-results-from-one-search-in-another-query/m-p/398626#M168765</guid>
      <dc:creator>dwong2</dc:creator>
      <dc:date>2018-06-21T05:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Use results from one search in another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-results-from-one-search-in-another-query/m-p/398627#M168766</link>
      <description>&lt;P&gt;Hi dwong2,&lt;/P&gt;

&lt;P&gt;there are multiple options for this problem, but it is hard to provide the one solution that works best for you without more details.&lt;/P&gt;

&lt;P&gt;So, lets start with using a sub search: Use the search that returns the least results in the sub search, this is because sub searches have some limits that can bight you &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Aboutsubsearches#Subsearch_performance_considerations"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Aboutsubsearches#Subsearch_performance_considerations&lt;/A&gt; .&lt;/P&gt;

&lt;P&gt;A simple example would be :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=2 [ search index=1 | fields SomeFieldYouWant | format ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will search &lt;CODE&gt;index=2&lt;/CODE&gt; for a single result found in &lt;CODE&gt;index=1&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Format"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Format&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The next level is to use &lt;CODE&gt;return&lt;/CODE&gt; with a sub search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=2 [ search index=1 | fields SomeFieldYouWant | return ] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will search &lt;CODE&gt;index=2&lt;/CODE&gt; for a list of &lt;CODE&gt;OR&lt;/CODE&gt; results found in &lt;CODE&gt;index=1&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Return"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Return&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The much better option is to ignore all kinds of sub searches, joins, appends, transactions at all and just use &lt;CODE&gt;stats&lt;/CODE&gt; ; Read more about the stats approach here  &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt; or here &lt;A href="http://wiki.splunk.com/Virtual_.conf"&gt;http://wiki.splunk.com/Virtual_.conf&lt;/A&gt; the March 2016 session of @sideview&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jun 2018 20:12:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-results-from-one-search-in-another-query/m-p/398627#M168766</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-06-21T20:12:57Z</dc:date>
    </item>
  </channel>
</rss>

