<?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 String Field from Outer Search into Inner Map Search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212317#M187904</link>
    <description>&lt;P&gt;The outer search does produce a field called Problem. Sorry, I should have mentioned that I verified that already. &lt;/P&gt;

&lt;P&gt;Single quotes causes the map search to fail/produce no result. The error given is: Unable to run query ''search'.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jan 2016 14:58:52 GMT</pubDate>
    <dc:creator>ErikaE</dc:creator>
    <dc:date>2016-01-04T14:58:52Z</dc:date>
    <item>
      <title>Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212315#M187902</link>
      <description>&lt;P&gt;My search looks like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name source="Source A.csv" | eval Start2=strptime(Start, "%m/%d/%Y%H:%M") | eval End2=strptime(End, "%m/%d/%Y%H:%M") | map maxsearches=99999 search="search index=index_name earliest=$Start2$ latest=$End2$ source=\"Source B.csv\" | eval Problem2=\""$Problem$\"" | stats values($Problem2$) as Problem3, avg(Data) as Average, min(Data) as Min, max(Data) as Max, stdev(Data) as Stdev" |  table Average Min Max Stdev Problem3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Problem is a field in &lt;CODE&gt;Source A&lt;/CODE&gt; of the form &lt;CODE&gt;XX003&lt;/CODE&gt; or &lt;CODE&gt;X2999&lt;/CODE&gt;, a letter or two, then three or four numbers. I am using the &lt;CODE&gt;Start&lt;/CODE&gt; and &lt;CODE&gt;End&lt;/CODE&gt; fields from &lt;CODE&gt;Source A&lt;/CODE&gt; to look in &lt;CODE&gt;Source B&lt;/CODE&gt;'s &lt;CODE&gt;Data&lt;/CODE&gt; field and calculate stats for each &lt;CODE&gt;Problem&lt;/CODE&gt; in &lt;CODE&gt;Source A&lt;/CODE&gt;. I can't seem to get the &lt;CODE&gt;Problem&lt;/CODE&gt; to pass through the &lt;CODE&gt;map&lt;/CODE&gt; search. Help! &lt;/P&gt;

&lt;P&gt;I have tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval Problem=$Problem$ (like some other examples) 
eval Problem="$Problem$ 
eval Problem=\"$Problem\" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the example in the code above. I have a nearly identical search with a numerical field i.e. &lt;CODE&gt;OtherProblem=2.9&lt;/CODE&gt; that works great. &lt;/P&gt;

&lt;P&gt;Help!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 16:07:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212315#M187902</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2015-12-31T16:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212316#M187903</link>
      <description>&lt;P&gt;If you just run this search does it produce a field called Problem?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=index_name source="Source A.csv" | eval Start2=strptime(Start, "%m/%d/%Y%H:%M") | eval End2=strptime(End, "%m/%d/%Y%H:%M") | table Problem
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If not,  then that's your ahem.. problem.  Otherwise try this:&lt;BR /&gt;
(use single quotes around your search, and simplify the search as much as possible):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name source="Source A.csv" 
 | eval Start2=strptime(Start, "%m/%d/%Y%H:%M") 
 | eval End2=strptime(End, "%m/%d/%Y%H:%M")
 | table Start2 End2 Problem
 | map maxsearches=99999 search='
  search index=index_name earliest=$Start2$ latest=$End2$ source="Source B.csv" | 
  | stats values($Problem$) as Problem, avg(Data) as Average, min(Data) as Min, max(Data) as Max, stdev(Data) as Stdev
 '
 | table Average Min Max Stdev Problem
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There's no need to use eval in the map search to bring the variable in.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 16:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212316#M187903</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-12-31T16:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212317#M187904</link>
      <description>&lt;P&gt;The outer search does produce a field called Problem. Sorry, I should have mentioned that I verified that already. &lt;/P&gt;

&lt;P&gt;Single quotes causes the map search to fail/produce no result. The error given is: Unable to run query ''search'.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 14:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212317#M187904</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2016-01-04T14:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212318#M187905</link>
      <description>&lt;P&gt;Map might not be the best command for this situation. I think you can run this in a single search by using streamstats and a pipelined search command. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name AND (source="Source A.csv" OR source="Source B.csv") 
| eval Start=strptime(Start, "%m/%d/%Y%H:%M") 
| eval End=strptime(End, "%m/%d/%Y%H:%M") 
| streamstats min(Start) as Start max(End) as End 
| search source="Source B.csv" AND (_time&amp;lt;End OR _time&amp;gt;Start) 
| stats avg(Data) as Average min(Data) as Min, max(Data) as Max, stdev(Data) as Stdev by Problem
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also I've changed your stats command to use Problem as a By clause, I think it will be more meaningful, but it might not be. Feel free to change it back to a values function. Also have a look at this splunk answer: &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;See &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats&lt;/A&gt;&lt;BR /&gt;
See &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212318#M187905</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2016-01-04T16:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212319#M187906</link>
      <description>&lt;P&gt;Your search returns no results, because Problem is not a field in source B. The 5th line of the search tosses out the Problem field when you search within source B. The sixth line returns results when you modify it to: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats avg(Data) as Average min(Data) as Min, max(Data) as Max, stdev(Data) as Stdev by Start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;The only field in common between the two sources is time.&lt;/STRONG&gt;  In the example you linked, there is a common field, user, which does not exist in my data set. &lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 16:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212319#M187906</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2016-01-05T16:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212320#M187907</link>
      <description>&lt;P&gt;Can you possibly post a couple of example lines from each source? It would be useful to know what fields are available.&lt;/P&gt;

&lt;P&gt;What you're probably going to need is a transaction command: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 09:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212320#M187907</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2016-01-06T09:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pass String Field from Outer Search into Inner Map Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212321#M187908</link>
      <description>&lt;P&gt;Can you try converting it back to the format you had with many double quotes, but not using eval?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 12:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-String-Field-from-Outer-Search-into-Inner-Map-Search/m-p/212321#M187908</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-01-06T12:46:40Z</dc:date>
    </item>
  </channel>
</rss>

