<?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 add a field from a subsearch to every event in a parent search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202933#M58920</link>
    <description>&lt;P&gt;I don't know but the email_to field never appears in the table.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2016 17:29:45 GMT</pubDate>
    <dc:creator>jwalthour</dc:creator>
    <dc:date>2016-11-02T17:29:45Z</dc:date>
    <item>
      <title>How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202929#M58916</link>
      <description>&lt;P&gt;I'm wanting to do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined
[ search index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m|head 1|rename email as email_to|return email_to ]
| table sourcetype source email_to
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, the results look like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;access_combined source1 abc@mydomain.com
access_combined source2 abc@mydomain.com
access_combined source3 abc@mydomain.com
access_combined source4 abc@mydomain.com
access_combined source5 abc@mydomain.com
access_combined source6 abc@mydomain.com
access_combined source7 abc@mydomain.com
access_combined source8 abc@mydomain.com
access_combined source9 abc@mydomain.com
access_combined source10 abc@mydomain.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically, the email address gets appended to every event in search results. I've tried &lt;CODE&gt;join&lt;/CODE&gt;, &lt;CODE&gt;append&lt;/CODE&gt;, &lt;CODE&gt;appendpipe&lt;/CODE&gt;, &lt;CODE&gt;appendcols&lt;/CODE&gt;, everything I can think of. Nothing works as intended. What am I not understanding here?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 15:52:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202929#M58916</guid>
      <dc:creator>jwalthour</dc:creator>
      <dc:date>2016-11-02T15:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202930#M58917</link>
      <description>&lt;P&gt;Maybe not the best solution, but a solution nonetheless is to use &lt;CODE&gt;filldown&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined  | table sourcetype source | appendcols [ search index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m | head 1| table email | rename email as email_to ] | filldown email_to
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Nov 2016 16:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202930#M58917</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-11-02T16:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202931#M58918</link>
      <description>&lt;P&gt;If you just want to add a column with same value as email_to (no filtering of main  search), try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=main sourcetype=access_combined | eval email_to= [ search index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m|head 1|eval email="\"".email."\""|return email ]
 | table sourcetype source email_to
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to filter the main search as well create a new field, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=main sourcetype=access_combined
 [ search index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m|head 1|rename email as email_to|return email_to ] | eval email_to= [ search index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m|head 1|eval email="\"".email."\""|return email ] 
 | table sourcetype source email_to
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Nov 2016 16:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202931#M58918</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-02T16:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202932#M58919</link>
      <description>&lt;P&gt;The SPL gives an error: "Error in 'eval' command: Fields cannot be assigned a boolean result. Instead, try if([bool expr], [expr], [expr])."&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 17:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202932#M58919</guid>
      <dc:creator>jwalthour</dc:creator>
      <dc:date>2016-11-02T17:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202933#M58920</link>
      <description>&lt;P&gt;I don't know but the email_to field never appears in the table.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 17:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202933#M58920</guid>
      <dc:creator>jwalthour</dc:creator>
      <dc:date>2016-11-02T17:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202934#M58921</link>
      <description>&lt;P&gt;Does the search below have a single result row with a column "email_to" or does it return no results?&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m | head 1| table email | rename email as email_to&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 17:50:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202934#M58921</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-11-02T17:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202935#M58922</link>
      <description>&lt;P&gt;Hi, I would use eval&lt;/P&gt;

&lt;P&gt;...&lt;BR /&gt;
| eval email_to = [&lt;BR /&gt;
     search index=myidx sourcetype=oncall name="oncall_group" earliest=-24h latest=-0m&lt;BR /&gt;
     | head 1&lt;BR /&gt;
     | rename email as email_to&lt;BR /&gt;
     | return $email_to&lt;BR /&gt;
]&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;The $ does the following (field has the value xy):&lt;/P&gt;

&lt;P&gt;return field    -&amp;gt; returns field="xy"&lt;BR /&gt;
return $field  -&amp;gt; returns xy&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:49:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/202935#M58922</guid>
      <dc:creator>BMacher</dc:creator>
      <dc:date>2020-09-29T19:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/580072#M202123</link>
      <description>&lt;P&gt;Awesome!&amp;nbsp; Did not know about return.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 01:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/580072#M202123</guid>
      <dc:creator>lmonahan</dc:creator>
      <dc:date>2022-01-06T01:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a field from a subsearch to every event in a parent search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/610592#M212355</link>
      <description>&lt;P&gt;Below one works for me.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| gentimes start=1 end=5&lt;BR /&gt;| eval &lt;BR /&gt;[| makeresults&lt;BR /&gt;| eval foo="test"&lt;BR /&gt;| return foo]&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Aug 2022 02:10:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-field-from-a-subsearch-to-every-event-in-a-parent/m-p/610592#M212355</guid>
      <dc:creator>jawaharas</dc:creator>
      <dc:date>2022-08-24T02:10:26Z</dc:date>
    </item>
  </channel>
</rss>

