<?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 use field value from outer query in inputlookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646679#M223832</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Based on the source the env values get change, from the results I add a new field as 'env' using rex and then have to use the field value to differentiate the files specific to each env.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jun 2023 15:18:30 GMT</pubDate>
    <dc:creator>Thulasinathan_M</dc:creator>
    <dc:date>2023-06-12T15:18:30Z</dc:date>
    <item>
      <title>How to use field value from outer query in inputlookup?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646602#M223812</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to find whether a lookup file is available or not. If yes, I want to use the same file, if not I want to use different file, so far with some helps, I've written below query, the eval fileName if condition is working fine, in the stats I could see the correct results(desired files I'm looking for).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I'm wondering whether I could use the filename in makeresults and search for lookup file. Could someone please assist. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=main sourcetype="dummySource"  events
| stats by EventCode
| append [ | inputlookup states.csv | stats count as isAvailable ]
| stats sum(isAvailable) as available, values(EventCode) as EventCode
| eval fileName = if(available &amp;gt; 0, "1.csv", "2.csv")
| stats values(available) as available values(EventCode) as EventCode by fileName
| join type=left fileName 
   [| inputlookup [ | makeresults 
    | eval search=fileName
    | table search ]]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 13:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646602#M223812</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-06-12T13:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646619#M223815</link>
      <description>&lt;P&gt;Essentially, you can't pass values from the outer search to the inner search, this is because, in general, the inner search is executed before the outer search.&lt;/P&gt;&lt;P&gt;One exception to this is the map command. However, the search which is executed for each event, replaces the event with its results.&lt;/P&gt;&lt;P&gt;You may be able to use this by doing the test first and use inputlookup to load the relevant csv file, then append your main search as a subsearch, then use stats to join your result to event from the lookup.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 10:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646619#M223815</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-06-12T10:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646622#M223817</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;, glad to know the sub-search runs first.&lt;BR /&gt;The inner inputlookup gives me the correct fileNames, but when I try it with either of options neither worked, any suggestions on what I'm doing wrong please.&lt;BR /&gt;&lt;BR /&gt;Option1:&lt;BR /&gt;| inputlookup [| makeresults&lt;BR /&gt;[| inputlookup geo_attr_us_states.csv&lt;BR /&gt;| stats count as isAvailable&lt;BR /&gt;| eval fileName = if(isAvailable &amp;gt; 0, "1.csv", "2.csv")&lt;BR /&gt;| table fileName]]&lt;BR /&gt;&lt;BR /&gt;Option 2:&lt;BR /&gt;| inputlookup [| makeresults&lt;BR /&gt;[| inputlookup geo_attr_us_states.csv&lt;BR /&gt;| stats count as isAvailable&lt;BR /&gt;| eval fileName = if(isAvailable &amp;gt; 0, "1.csv", "2.csv")&lt;BR /&gt;| table fileName]&lt;BR /&gt;| return $fileName]&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 10:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646622#M223817</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-06-12T10:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646624#M223818</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup geo_attr_us_states.csv
| stats count as isAvailable
| eval fileName = if(isAvailable &amp;gt; 0, "1.csv", "2.csv")
| eval lookup="| inputlookup ".fileName
| map search="| makeresults | map search="$lookup$&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 Jun 2023 10:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646624#M223818</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-06-12T10:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646648#M223820</link>
      <description>&lt;P&gt;Thank you, it did the trick &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 12:27:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646648#M223820</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-06-12T12:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646668#M223826</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Sorry,&amp;nbsp; I misunderstood my existing flow and it's I've to add a field&amp;nbsp; 'env' value from the main search. As I'm a newbie to splunk couldn't find a solution for this, could you please kindly assist.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype=java ErrorCode=400 env=prod
| join type=left ErrorCode
[| inputlookup [| makeresults 
        | eval search="Errors".env.strftime(now(),"%m%d").".csv" 
        | table search]
| stats count as isAvailable
| eval fileName = if(isAvailable &amp;gt; 0, "Errors".env.strftime(now(),"%m%d").".csv", "Errors".env.strftime(relative_time(now(), "-1d"),"%m%d").".csv")
| eval lookup="| inputlookup ".fileName
| map search="| makeresults | map search="$lookup$]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 14:37:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646668#M223826</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-06-12T14:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646676#M223829</link>
      <description>&lt;P&gt;From your main search, env=prod so why not just use that string in the lookup file name?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 14:57:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646676#M223829</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-06-12T14:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646679#M223832</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Based on the source the env values get change, from the results I add a new field as 'env' using rex and then have to use the field value to differentiate the files specific to each env.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 15:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646679#M223832</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-06-12T15:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field value from outer query in inputlookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646718#M223845</link>
      <description>&lt;P&gt;Thanks, working now.!!!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 18:48:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-value-from-outer-query-in-inputlookup/m-p/646718#M223845</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-06-12T18:48:53Z</dc:date>
    </item>
  </channel>
</rss>

