<?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: Splunk - Output of one query as an input to another query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569782#M198587</link>
    <description>&lt;P&gt;The query in the screenshot looks good to me, but I don't know your data so I can't tell what may need to be corrected.&amp;nbsp; In particular, does the reqid field contain text that matches what the rex command expects?&amp;nbsp; I'm guessing it does not, which means the two queries cannot be linked. (Recall that the &lt;FONT face="courier new,courier"&gt;table&lt;/FONT&gt; command passes on only the named fields.)&lt;/P&gt;&lt;P&gt;Perhaps we need to refactor the queries.&amp;nbsp; The base search should include everything up to (but not including) the first table command.&lt;/P&gt;&lt;P&gt;The second search, which will populate the first panel, uses the base search and adds &lt;FONT face="courier new,courier"&gt;| table reqid&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;The third search populates the second panel as it currently does.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Oct 2021 19:44:29 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-10-05T19:44:29Z</dc:date>
    <item>
      <title>Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569629#M198536</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I have two different queries running on same dashboard but a different panel.&amp;nbsp; Below is the query one which results the "reqid" as the output (ex:123456)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query 1&lt;/STRONG&gt;:&amp;nbsp;sourcetype=test*-cloudwatch-logs file.txt | rex "RequestId: (?&amp;amp;lt;reqid&amp;amp;gt;[\S+]*)\s" | table reqid | dedup reqid&lt;/P&gt;&lt;P&gt;Output return as ex : 123456&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, i would like feed the output of &lt;STRONG&gt;query1&lt;/STRONG&gt; as input of &lt;STRONG&gt;query2.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query 2:&amp;nbsp; &lt;/STRONG&gt;$query1_output$&amp;nbsp;| rex "uploaded to: s3://sample-us-east-1-s3/transmit-os/(?&amp;amp;lt;filename&amp;amp;gt;.*)" | table filename&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Can someone suggest me is this right way of passing? How can i update the source code (XML) for the changes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 00:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569629#M198536</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-05T00:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569687#M198553</link>
      <description>&lt;P&gt;One does not "pass" results from one query to another in Splunk dashboards.&amp;nbsp; If you need to use the results of one query in another query then use post processing (&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/Viz/Savedsearches#Post-process_searches_2" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/Viz/Savedsearches#Post-process_searches_2&lt;/A&gt;).&amp;nbsp; Post processing defines a base search and one or more post-processing searches that refine or enhance the results of the base search.&lt;/P&gt;&lt;P&gt;In your example, Query 1 would be the base search and Query 2 the post-processing search.&amp;nbsp; The code would look something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;panel&amp;gt;
  ...
  &amp;lt;search id="base"&amp;gt;
    &amp;lt;query&amp;gt;sourcetype=test*-cloudwatch-logs file.txt | rex "RequestId: (?&amp;amp;lt;reqid&amp;amp;gt;[\S+]*)\s" | dedup reqid | table reqid&amp;lt;/query&amp;gt;
  &amp;lt;/search&amp;gt;
&amp;lt;/panel&amp;gt;
&amp;lt;panel&amp;gt;
  ...
  &amp;lt;search base="base"&amp;gt;
    &amp;lt;query&amp;gt;| rex "uploaded to: s3://sample-us-east-1-s3/transmit-os/(?&amp;amp;lt;filename&amp;amp;gt;.*)" | table filename&amp;lt;/query&amp;gt;
  &amp;lt;/search&amp;gt;
&amp;lt;/panel&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Oct 2021 12:39:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569687#M198553</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-10-05T12:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569746#M198575</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;The two queries are working individually great. Also I tried as you suggested , but its not returning anything. Even if running two queries together in splunk search not working. Can you please suggest in any another way i can pass the output of first query as an input to the second query?&lt;/P&gt;&lt;P&gt;I appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 17:49:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569746#M198575</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-05T17:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569766#M198582</link>
      <description>&lt;P&gt;This is the only way, AFAIK, to share results among panels in a dashboard.&lt;/P&gt;&lt;P&gt;Please share your dashboard code (sanitized as necessary).&amp;nbsp; Which panel is not returning results?&amp;nbsp; Have you tried running the queries in a search window?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 18:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569766#M198582</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-10-05T18:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569772#M198584</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I tried as you suggested. Below is the screen shot of running two commands as one in splunk search. It doesn't return anything. (same query runds through dashboard). Its taking the command as whole instaed of running first query and then pass it as an input to second query.&lt;/P&gt;&lt;P&gt;The code looks like this in xml file:&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;&amp;lt;row&amp;gt;
  &amp;lt;panel&amp;gt;
    &amp;lt;table&amp;gt;
     &amp;lt;search id="base"&amp;gt;
       &amp;lt;query&amp;gt;sourcetype=sample*-cloudwatch-logs file.txt | rex "RequestId: (?&amp;amp;lt;reqid&amp;amp;gt;[\S+]*)\s" | table reqid | dedup reqid&amp;lt;/query&amp;gt;
     &amp;lt;earliest&amp;gt;-7d@h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
   &amp;lt;/search&amp;gt;
   &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
   &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
   &amp;lt;/table&amp;gt;
  &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;
&amp;lt;row&amp;gt;
&amp;lt;panel&amp;gt;
  &amp;lt;table&amp;gt;
   &amp;lt;search base = "base"&amp;gt;
    &amp;lt;query&amp;gt;| rex "uploaded to: s3:\/\/sample.*?-test-.*?-us-east-1-s3/transmit-os/(?&amp;amp;lt;filename&amp;amp;gt;.*)" | table filename&amp;lt;/query&amp;gt;
   &amp;lt;/search&amp;gt;
   &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
   &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
 &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check and let me know what else i can do to make it work. Also, please check the attached pic of splunk running in my UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 19:31:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569772#M198584</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-05T19:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569780#M198586</link>
      <description>&lt;P&gt;Try declaring the first search as a base search and base both panel on it, one with the straight results and the other with the additional search commands&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 19:42:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569780#M198586</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-05T19:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569782#M198587</link>
      <description>&lt;P&gt;The query in the screenshot looks good to me, but I don't know your data so I can't tell what may need to be corrected.&amp;nbsp; In particular, does the reqid field contain text that matches what the rex command expects?&amp;nbsp; I'm guessing it does not, which means the two queries cannot be linked. (Recall that the &lt;FONT face="courier new,courier"&gt;table&lt;/FONT&gt; command passes on only the named fields.)&lt;/P&gt;&lt;P&gt;Perhaps we need to refactor the queries.&amp;nbsp; The base search should include everything up to (but not including) the first table command.&lt;/P&gt;&lt;P&gt;The second search, which will populate the first panel, uses the base search and adds &lt;FONT face="courier new,courier"&gt;| table reqid&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;The third search populates the second panel as it currently does.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 19:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569782#M198587</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-10-05T19:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569785#M198588</link>
      <description>&lt;P&gt;Does the first query always returns one row with one field?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 20:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569785#M198588</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-10-05T20:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569797#M198595</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes, thats right. It always returns Only one row with one field. How can i make my queries better to get the result i need?&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you so much for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 21:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569797#M198595</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-05T21:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569818#M198601</link>
      <description>&lt;P&gt;I tried using subsearch for the same as below. For some reason its not working with sub query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The overall query for subsearch is,&lt;/P&gt;&lt;P&gt;query 2 is,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[search sourcetype=sample*-cloudwatch-logs file.txt | rex "RequestId: (?&amp;lt;reqid&amp;gt;[\S+]*)\s" | table reqid | dedup reqid]&lt;/STRONG&gt; | rex "uploaded to: s3:\/\/sample.*?-test-.*?-us-east-1-s3/(?&amp;lt;json&amp;gt;.*)" | table json | where isnotnull(json)&lt;/P&gt;&lt;P&gt;query 1 is,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[search sourcetype=sample*-cloudwatch-logs file.txt | rex "RequestId: (?&amp;lt;reqid&amp;gt;[\S+]*)\s" | table reqid | dedup reqid]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its not returning anything in splunk search.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 01:30:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569818#M198601</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-06T01:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569883#M198628</link>
      <description>&lt;P&gt;can you please share some examples i can try with?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 13:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569883#M198628</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-06T13:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569890#M198631</link>
      <description>&lt;P&gt;Where did the subsearches come from?&amp;nbsp; We never mentioned those in this thread.&amp;nbsp; Subsearches behave differently and take this thread in a new direction.&lt;/P&gt;&lt;P&gt;FTR, there is nothing gained by starting a query with a subsearch (subsearches run first, anyway) nor by making the entire query a subsearch.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 13:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569890#M198631</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-10-06T13:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569892#M198632</link>
      <description>&lt;P&gt;I came across this approach when i was looking for solution. So i just gave a try to check if it works. I am still looking for the solution for this issue. I am really not sure what else i can try&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 13:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569892#M198632</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-06T13:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569893#M198633</link>
      <description>&lt;P&gt;I think this approach might work for you.&lt;/P&gt;&lt;P&gt;Step 1: Run your first search/query1 (which gives a single row/column result) and use approach from below link to capture the result as token. In this example, you'll be displaying the result as table as well as saving it as a token.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-store-search-results-in-a-token-or-variable/m-p/424746" target="_blank"&gt;https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-store-search-results-in-a-token-or-variable/m-p/424746&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Step 2: Use the token generated in Step 1 in your second search/query2.&lt;/P&gt;&lt;P&gt;Now, you can do a text base search (like google search) in your query2 but it's better to specify the index/sourcetype you want to search against, it'll perform much better.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 13:44:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569893#M198633</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-10-06T13:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Output of one query as an input to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569901#M198636</link>
      <description>&lt;P&gt;Thanks. It worked&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":clapping_hands:"&gt;👏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 14:16:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Output-of-one-query-as-an-input-to-another-query/m-p/569901#M198636</guid>
      <dc:creator>kumarnis45</dc:creator>
      <dc:date>2021-10-06T14:16:35Z</dc:date>
    </item>
  </channel>
</rss>

