<?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 Having issues reporting information from inner searches in a nested query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402266#M116406</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I will try to explain my issue as concisely as possible. I suspect the issue is attributed to me misunderstanding the usage of &lt;CODE&gt;fields&lt;/CODE&gt; and &lt;CODE&gt;return&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The use case is using a saved search to resolve an IP to a user who queried a specific domain.&lt;/P&gt;

&lt;P&gt;Below is the trouble query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| savedsearch IPresolver src=$clientIP$  
    [ search sourcetype=DNSlogs (some time range B)
        [ search sourcetype=intel (some time range C)
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return clientIP queried_domain _time] 
| table user queried_domain _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where IPresolver looks like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch src=$src$ (some time range A)
|dedup user
|fields user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and my resulting table looks like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user           queried_domain          _time
johndoe          &amp;lt;blank&amp;gt;               &amp;lt;timestamp from events from the saved search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm having a hard time understanding why I'm able to return &lt;CODE&gt;clientIP&lt;/CODE&gt; for the purpose of populating a &lt;CODE&gt;savedsearch&lt;/CODE&gt; command but I'm unable to use &lt;CODE&gt;queried_domain&lt;/CODE&gt; for reporting purposes in my outer most query. Also, I'm unsure  how to report the correct &lt;CODE&gt;_time&lt;/CODE&gt; as it should be the timestamp from the DNS log events.&lt;/P&gt;

&lt;P&gt;I should also note that both inner queries work as expected and this was validated through the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=DNS logs (some time range B)
    [search sourcetype=intel (some time range C)
    |stats values(intelstuff) as queried_domain
    |format]
|table clientIP queried_domain _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd greatly appreciate some insight as to why this implementation doesn't work (I checked job inspector and it did not contain useful information).&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 08 Apr 2019 17:04:20 GMT</pubDate>
    <dc:creator>nickcardenas</dc:creator>
    <dc:date>2019-04-08T17:04:20Z</dc:date>
    <item>
      <title>Having issues reporting information from inner searches in a nested query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402266#M116406</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I will try to explain my issue as concisely as possible. I suspect the issue is attributed to me misunderstanding the usage of &lt;CODE&gt;fields&lt;/CODE&gt; and &lt;CODE&gt;return&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The use case is using a saved search to resolve an IP to a user who queried a specific domain.&lt;/P&gt;

&lt;P&gt;Below is the trouble query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| savedsearch IPresolver src=$clientIP$  
    [ search sourcetype=DNSlogs (some time range B)
        [ search sourcetype=intel (some time range C)
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return clientIP queried_domain _time] 
| table user queried_domain _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where IPresolver looks like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch src=$src$ (some time range A)
|dedup user
|fields user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and my resulting table looks like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user           queried_domain          _time
johndoe          &amp;lt;blank&amp;gt;               &amp;lt;timestamp from events from the saved search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm having a hard time understanding why I'm able to return &lt;CODE&gt;clientIP&lt;/CODE&gt; for the purpose of populating a &lt;CODE&gt;savedsearch&lt;/CODE&gt; command but I'm unable to use &lt;CODE&gt;queried_domain&lt;/CODE&gt; for reporting purposes in my outer most query. Also, I'm unsure  how to report the correct &lt;CODE&gt;_time&lt;/CODE&gt; as it should be the timestamp from the DNS log events.&lt;/P&gt;

&lt;P&gt;I should also note that both inner queries work as expected and this was validated through the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=DNS logs (some time range B)
    [search sourcetype=intel (some time range C)
    |stats values(intelstuff) as queried_domain
    |format]
|table clientIP queried_domain _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd greatly appreciate some insight as to why this implementation doesn't work (I checked job inspector and it did not contain useful information).&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 17:04:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402266#M116406</guid>
      <dc:creator>nickcardenas</dc:creator>
      <dc:date>2019-04-08T17:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues reporting information from inner searches in a nested query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402267#M116407</link>
      <description>&lt;P&gt;According to what's you've written, tour base search IPresolver, ends with  &lt;EM&gt;| fields user&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;This means, fields like queried_domain are getting dropped, so they are not available to the table command. &lt;/P&gt;

&lt;P&gt;I would adjust the IPResolver line to &lt;EM&gt;| fields _time, user, queried_domain&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:58:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402267#M116407</guid>
      <dc:creator>solarboyz1</dc:creator>
      <dc:date>2020-09-29T23:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues reporting information from inner searches in a nested query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402268#M116408</link>
      <description>&lt;P&gt;The problem is that when you use a subsearch to pass search criteria into another search, it doesn't pass it as a new field, but as a filter when used in this context. There are a couple ways to pass in the actual field, one involves using another subsearch to pass in the field after an eval and another way would be to do it with a join on that subsearch to append that data to your resulting event(s).&lt;/P&gt;

&lt;P&gt;Here's the subsearch method:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| savedsearch IPresolver src=$clientIP$ 
    [ search sourcetype=DNSlogs 
        [ search sourcetype=intel 
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return clientIP queried_domain _time] 
| eval 
    [ search sourcetype=DNSlogs $clientIP$ 
        [ search sourcetype=intel 
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return queried_domain] 
| eval 
    [ search sourcetype=DNSlogs $clientIP$ 
        [ search sourcetype=intel 
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return _time] 
| table user queried_domain _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm making an assumption that the intel sourcetype contains the clientIP with this query.  If that's not the case, feel free to let me know and I can help you adjust it so it uses whatever field that is used to join the events.&lt;/P&gt;

&lt;P&gt;If you want to do it with a join, we just need to know what field is being used to join the DNSlogs to the intel logs.&lt;/P&gt;

&lt;P&gt;Edited to include the solution to the time should be DNS time problem statement as well.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 17:28:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402268#M116408</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2019-04-08T17:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues reporting information from inner searches in a nested query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402269#M116409</link>
      <description>&lt;P&gt;Hello! Thank you for your help! &lt;/P&gt;

&lt;P&gt;The intel sourcetype only generates a list of domains (&lt;CODE&gt;clientIP&lt;/CODE&gt; is from the DNS logs). The domain names are then compared to the DNS logs with the field &lt;CODE&gt;queried_domain&lt;/CODE&gt; which explains the &lt;CODE&gt;format&lt;/CODE&gt; command on line 5 and the renaming on line 4 of my original posted trouble query. This makes it so that in the DNS portion of my trouble query does something like this: &lt;CODE&gt;queried_domain=domaina.com AND queried_domain-domianb.com&lt;/CODE&gt; and so on. Matching events in the DNS logs contain &lt;CODE&gt;clientIP&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I've also considered the eval method but I'm unsure how to actually implement that. I've seen people online do something like &lt;CODE&gt;|eval something = [search ]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 17:43:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402269#M116409</guid>
      <dc:creator>nickcardenas</dc:creator>
      <dc:date>2019-04-08T17:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues reporting information from inner searches in a nested query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402270#M116410</link>
      <description>&lt;P&gt;Hello! This makes sense, however, the change does not affect the output. Regardless, I appreciate your answer! &lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 17:47:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402270#M116410</guid>
      <dc:creator>nickcardenas</dc:creator>
      <dc:date>2019-04-08T17:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues reporting information from inner searches in a nested query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402271#M116411</link>
      <description>&lt;P&gt;The search I just updated on the answer is doing that, but instead of field= subsearch, I'm having the subsearch generate that with the return command.  The problem with this is you have to pass that clientip into your search three times.  Shouldn't be a problem if you have this on a dashboard with tokens, but that will get annoying when having to do it by hand each time.  We could use map instead to get around that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1
| eval clientIP="255.255.255.255"
| map search="| savedsearch IPresolver src=$clientIP$ 
    [ search sourcetype=DNSlogs 
        [ search sourcetype=intel 
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return clientIP queried_domain _time] 
| eval 
    [ search sourcetype=DNSlogs $clientIP$ 
        [ search sourcetype=intel 
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return queried_domain] 
| eval 
    [ search sourcetype=DNSlogs $clientIP$ 
        [ search sourcetype=intel 
        | stats values(intelstuff) as queried_domain 
        | format] 
    | return _time] 
| table user queried_domain _time"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Apr 2019 17:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Having-issues-reporting-information-from-inner-searches-in-a/m-p/402271#M116411</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2019-04-08T17:47:59Z</dc:date>
    </item>
  </channel>
</rss>

