<?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: Pass the output of one query to another query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379650#M173081</link>
    <description>&lt;P&gt;I assume you will have to use a &lt;CODE&gt;join&lt;/CODE&gt; here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc |rex field=notes "Job:(?.*)\\nApp" | join Job [ index=xyz | rex "]\s+(?\S+)\s+(?:((EVENT:)?\s(?\S+)\s+(STATUS:)?\s+(?\S+)\s+(JOB:)?\s+(?\S+)(\s+(MACHINE:)?\s+(?\S+))?(\s+(EXITCODE:)?\s+(?\S+))?))" |search event_1="CHANGE_STATUS" |fields Job Job_Status] | table Job  Job_Status Incident_Create_Number Incident_Create_Assigned_Group
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Feb 2019 13:40:00 GMT</pubDate>
    <dc:creator>DMohn</dc:creator>
    <dc:date>2019-02-12T13:40:00Z</dc:date>
    <item>
      <title>Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379645#M173076</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
My 1st query returns 3 fields output.Out of which one filed has to be given as input to the second query which fetches 3 fields along with this result value.&lt;BR /&gt;
Kidnly help&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 11:02:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379645#M173076</guid>
      <dc:creator>Deepz2612</dc:creator>
      <dc:date>2019-02-12T11:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379646#M173077</link>
      <description>&lt;P&gt;Try this as a starting point: &lt;CODE&gt;YOUR_SEARCH | append [SECOND SEARCH]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You need to supply more details if you want better help.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 11:06:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379646#M173077</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-12T11:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379647#M173078</link>
      <description>&lt;P&gt;Hi @Deepz2612 ,&lt;BR /&gt;
You can go through these documentations of sub-search:-&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/5.0/Tutorial/Useasubsearch"&gt;https://docs.splunk.com/Documentation/Splunk/5.0/Tutorial/Useasubsearch&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.splunk.com/blog/2012/11/05/book-excerpt-finding-specific-transactions.html"&gt;https://www.splunk.com/blog/2012/11/05/book-excerpt-finding-specific-transactions.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 11:21:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379647#M173078</guid>
      <dc:creator>MoniM</dc:creator>
      <dc:date>2019-02-12T11:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379648#M173079</link>
      <description>&lt;P&gt;I have events like below with Job name and Incident number  &lt;/P&gt;

&lt;P&gt;Index= abc&lt;BR /&gt;
        Job: scdefgh_tal1080_d_b&lt;BR /&gt;
        App: YSC&lt;BR /&gt;
        Incident_Create_Number:  INC0000XXXXXXXX&lt;BR /&gt;&lt;BR /&gt;
So I wrote a query to extract them as below:&lt;BR /&gt;
index=abc |rex field=notes "Job:(?.*)\nApp" |table Job Incident_Create_Number Incident_Create_Assigned_Group&lt;/P&gt;

&lt;P&gt;I have events where like below having Job name and its status&lt;BR /&gt;
Index= xyz&lt;BR /&gt;
CAUAJM_I_40245 EVENT: CHANGE_STATUS    STATUS: TERMINATED      JOB: iascamdsp_tal1080_d_b&lt;/P&gt;

&lt;P&gt;So I wrote a query to extract them as below:&lt;BR /&gt;
index=xyz | rex "]\s+(?\S+)\s+(?:((EVENT:)?\s(?\S+)\s+(STATUS:)?\s+(?\S+)\s+(JOB:)?\s+(?\S+)(\s+(MACHINE:)?\s+(?\S+))?(\s+(EXITCODE:)?\s+(?\S+))?))" |search event_1="CHANGE_STATUS"  |table  Job Job_Status &lt;/P&gt;

&lt;P&gt;Now I wanted to combine both.For the Job name in the first query I want its status from the second query.&lt;BR /&gt;
I tried using Join but its not returning any results.&lt;BR /&gt;
Kindly help!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:12:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379648#M173079</guid>
      <dc:creator>Deepz2612</dc:creator>
      <dc:date>2020-09-29T23:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379649#M173080</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your second query&amp;gt; [ search &amp;lt;your first query&amp;gt; | return &amp;lt;your field&amp;gt;] | table &amp;lt;your other fields&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first query needs to go as a subsearch (the part in []) and return the needed field back to the main search (which in your case is the second query). You can select which field to use as a result in the main search with the &lt;CODE&gt;return&lt;/CODE&gt; command. Normally it would look something like "field=value1 OR field=value2 OR ...."&lt;BR /&gt;
If you need another return format, please refer to the command documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Return"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Return&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 13:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379649#M173080</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-12T13:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379650#M173081</link>
      <description>&lt;P&gt;I assume you will have to use a &lt;CODE&gt;join&lt;/CODE&gt; here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc |rex field=notes "Job:(?.*)\\nApp" | join Job [ index=xyz | rex "]\s+(?\S+)\s+(?:((EVENT:)?\s(?\S+)\s+(STATUS:)?\s+(?\S+)\s+(JOB:)?\s+(?\S+)(\s+(MACHINE:)?\s+(?\S+))?(\s+(EXITCODE:)?\s+(?\S+))?))" |search event_1="CHANGE_STATUS" |fields Job Job_Status] | table Job  Job_Status Incident_Create_Number Incident_Create_Assigned_Group
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Feb 2019 13:40:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379650#M173081</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-12T13:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pass the output of one query to another query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379651#M173082</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;The above doesnt seem to work.It returns me 0 results.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 07:38:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-the-output-of-one-query-to-another-query/m-p/379651#M173082</guid>
      <dc:creator>Deepz2612</dc:creator>
      <dc:date>2019-02-13T07:38:11Z</dc:date>
    </item>
  </channel>
</rss>

