<?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 use output of a 1st query list as input in second query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617657#M214656</link>
    <description>&lt;P&gt;You can also use subsearches. If you want to limit the data from your second search to a list of ids generated in the first search, it's&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search2 [ search1 | fields id ]&lt;/LI-CODE&gt;&lt;P&gt;where the search 1 will do the stats count by uniqueid and make the returned field 'id' in the above case. In the search2, there should be an ID that will then match against the results of search 1.&lt;/P&gt;&lt;P&gt;You can see the effect of what search1 passes to search 2 by running search 1 standalone and adding&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| format&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;to the end&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 06:42:13 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2022-10-19T06:42:13Z</dc:date>
    <item>
      <title>How to use output of a 1st query list as input in second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617617#M214643</link>
      <description>&lt;P&gt;I have an&amp;nbsp;&lt;BR /&gt;```&lt;BR /&gt;index=xyz data.id=1&lt;BR /&gt;```&lt;BR /&gt;which gives me list of unique id's [1,2,3,4,5]Not sure how to store the above result to get it used for another query.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;| stats count by uniqueId&lt;BR /&gt;&lt;BR /&gt;Now I want to use the list above and get the data from another query and find the values&lt;BR /&gt;Query 2 will return&amp;nbsp;&lt;BR /&gt;1 -&amp;gt; good&lt;BR /&gt;2 -&amp;gt; Bad&lt;BR /&gt;3 -&amp;gt; Neural / etc&lt;/P&gt;&lt;P&gt;Index2 I want to use the result [1,2,3,4] for the next query which will give me some extra information based on the ID only. Eg: Query 2 has&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;index=xyz data.msg.id=1, data.xyz.val=good&lt;/P&gt;&lt;P&gt;How can we do that?&lt;BR /&gt;&lt;BR /&gt;I am trying something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="test"
actionSubCateg IN (xyz)
landingPageURL="xyz/?search=game_gupta"
data.msg.queryName="query FindBtf"
| table data.msg.id

Find in second query the results of top

[ search index="test" 
actionSubCateg="game" 
| rename data.DATA.id as id
| fields id, scope
| table id, scope]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 01:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617617#M214643</guid>
      <dc:creator>agupta13</dc:creator>
      <dc:date>2022-10-19T01:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use output of a 1st query list as input in second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617652#M214655</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/250474"&gt;@agupta13&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the easiest solution is the jin command, but it's avery slow and not performant solution, so I hint a different approach like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index="test" actionSubCateg IN (xyz) landingPageURL="xyz/?search=game_gupta" data.msg.queryName="query FindBtf") OR ([ search index="test" 
actionSubCateg="game")
| eval id=if(actionSubCateg="game",'data.DATA.id', 'data.msg.id'
| stats values(scope) AS scope values(data.xyz.val) AS val BY id&lt;/LI-CODE&gt;&lt;P&gt;in this way you have a row for each id.&lt;/P&gt;&lt;P&gt;if you want you can take only the ids present in both searches adding a little condition&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index="test" actionSubCateg IN (xyz) landingPageURL="xyz/?search=game_gupta" data.msg.queryName="query FindBtf") OR ([ search index="test" 
actionSubCateg="game")
| eval id=if(actionSubCateg="game",'data.DATA.id', 'data.msg.id'
| stats values(scope) AS scope values(data.xyz.val) AS val dc(actionSubCateg) AS actionSubCateg_count BY id
| where actionSubCateg_count&amp;gt;1&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 06:06:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617652#M214655</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-19T06:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use output of a 1st query list as input in second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617657#M214656</link>
      <description>&lt;P&gt;You can also use subsearches. If you want to limit the data from your second search to a list of ids generated in the first search, it's&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search2 [ search1 | fields id ]&lt;/LI-CODE&gt;&lt;P&gt;where the search 1 will do the stats count by uniqueid and make the returned field 'id' in the above case. In the search2, there should be an ID that will then match against the results of search 1.&lt;/P&gt;&lt;P&gt;You can see the effect of what search1 passes to search 2 by running search 1 standalone and adding&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| format&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;to the end&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 06:42:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-output-of-a-1st-query-list-as-input-in-second-query/m-p/617657#M214656</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-19T06:42:13Z</dc:date>
    </item>
  </channel>
</rss>

