<?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 Passing a field value from one search command in the pipeline to another in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-field-value-from-one-search-command-in-the-pipeline-to/m-p/507135#M141828</link>
    <description>&lt;P&gt;I have a search which produces a list of fields in an output table, including a user ID. I want to take the at ID, search another index,&amp;nbsp;and add additional output columns to the table. Functionally it behaves like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval requesting_user="david"
| appendcols
    [search index=admon sAMAccountName=$requesting_user$ earliest=0 latest=now
    | stats last(mail) as mail, last(givenName) as givenName, last(cn) as cn]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end, I want a single row with the requesting_user, mail, givenName and cn fields. But I'm not quite sure how to join these two searches together into a single row of output. I've experimented with appendcols, appendpipe, append, and map. Only map seems to be able to read the requesting_user token, but seems to throw away the requesting_user field.&lt;/P&gt;&lt;P&gt;The rest of the commands I've tried don't seem to be able to read the token or something else is going on, because I only get null values for those fields. When I execute the appendcols command substituting the token for the actual user name, it retrieves the values I want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me understand how include the fields from the bottom search into the output table of the top search?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jul 2020 19:13:40 GMT</pubDate>
    <dc:creator>_smp_</dc:creator>
    <dc:date>2020-07-02T19:13:40Z</dc:date>
    <item>
      <title>Passing a field value from one search command in the pipeline to another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-field-value-from-one-search-command-in-the-pipeline-to/m-p/507135#M141828</link>
      <description>&lt;P&gt;I have a search which produces a list of fields in an output table, including a user ID. I want to take the at ID, search another index,&amp;nbsp;and add additional output columns to the table. Functionally it behaves like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval requesting_user="david"
| appendcols
    [search index=admon sAMAccountName=$requesting_user$ earliest=0 latest=now
    | stats last(mail) as mail, last(givenName) as givenName, last(cn) as cn]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end, I want a single row with the requesting_user, mail, givenName and cn fields. But I'm not quite sure how to join these two searches together into a single row of output. I've experimented with appendcols, appendpipe, append, and map. Only map seems to be able to read the requesting_user token, but seems to throw away the requesting_user field.&lt;/P&gt;&lt;P&gt;The rest of the commands I've tried don't seem to be able to read the token or something else is going on, because I only get null values for those fields. When I execute the appendcols command substituting the token for the actual user name, it retrieves the values I want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me understand how include the fields from the bottom search into the output table of the top search?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 19:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-field-value-from-one-search-command-in-the-pipeline-to/m-p/507135#M141828</guid>
      <dc:creator>_smp_</dc:creator>
      <dc:date>2020-07-02T19:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a field value from one search command in the pipeline to another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-field-value-from-one-search-command-in-the-pipeline-to/m-p/507151#M141832</link>
      <description>&lt;P&gt;With the exception of &lt;FONT face="courier new,courier"&gt;map&lt;/FONT&gt;, the commands you tried (as well as &lt;FONT face="courier new,courier"&gt;join&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;multisearch&lt;/FONT&gt;) execute the subquery independent of the main search.&amp;nbsp; The subquery has no awareness of the fields in the main search and there is no way to pass arguments to the subquery.&lt;/P&gt;&lt;P&gt;Subsearches are similar, but they run first and make their results available to the main search.&amp;nbsp; So, your problem may be solved by swapping the order of operations.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=admon [ | makeresults | eval requesting_user="david" ] sAMAccountName=requesting_user earliest=0 latest=now
| stats last(mail) as mail, last(givenName) as givenName, last(cn) as cn&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 21:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-field-value-from-one-search-command-in-the-pipeline-to/m-p/507151#M141832</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-02T21:03:47Z</dc:date>
    </item>
  </channel>
</rss>

