<?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 use a result value, as fieldname in subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53009#M12888</link>
    <description>&lt;P&gt;I have a first search, that return "system1"&lt;/P&gt;

&lt;P&gt;Then I want to use that value, to get the appropriate value out of a subsearch timechart :&lt;BR /&gt;&lt;BR /&gt;
first restult :&lt;BR /&gt;
system&lt;BR /&gt;
system1&lt;/P&gt;

&lt;P&gt;second result : &lt;BR /&gt;
       system1 system2 system3&lt;BR /&gt;
_time     1       2       3&lt;BR /&gt;
_time     4       5       4&lt;BR /&gt;
_time     4       4       4&lt;/P&gt;

&lt;P&gt;How could I do that ?&lt;BR /&gt;
is there  a way to put the first result in a parameter, that could be used in the subsearch as fieldname ?&lt;/P&gt;

&lt;P&gt;index=myfirstquery | table system | subsearch [ _time=$_time$ | eval myValue=fieldName[$system$]]&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 14:41:58 GMT</pubDate>
    <dc:creator>sbsbb</dc:creator>
    <dc:date>2020-09-28T14:41:58Z</dc:date>
    <item>
      <title>use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53009#M12888</link>
      <description>&lt;P&gt;I have a first search, that return "system1"&lt;/P&gt;

&lt;P&gt;Then I want to use that value, to get the appropriate value out of a subsearch timechart :&lt;BR /&gt;&lt;BR /&gt;
first restult :&lt;BR /&gt;
system&lt;BR /&gt;
system1&lt;/P&gt;

&lt;P&gt;second result : &lt;BR /&gt;
       system1 system2 system3&lt;BR /&gt;
_time     1       2       3&lt;BR /&gt;
_time     4       5       4&lt;BR /&gt;
_time     4       4       4&lt;/P&gt;

&lt;P&gt;How could I do that ?&lt;BR /&gt;
is there  a way to put the first result in a parameter, that could be used in the subsearch as fieldname ?&lt;/P&gt;

&lt;P&gt;index=myfirstquery | table system | subsearch [ _time=$_time$ | eval myValue=fieldName[$system$]]&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:41:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53009#M12888</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2020-09-28T14:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53010#M12889</link>
      <description>&lt;P&gt;You can never pass variables from outer searches to subsearches, because subsearches run before outer searches and as such cannot read values that haven't been extracted/evaluated in the outer searches yet.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2013 13:08:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53010#M12889</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-09-02T13:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53011#M12890</link>
      <description>&lt;P&gt;I think you might be able to turn it around, making the so-called first search the subsearch;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;second_search_terms [search first_search_terms | dedup system | fields + system] | further_processing
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;search_terms would be stuff like &lt;CODE&gt;earliest / latest, index, sourcetype&lt;/CODE&gt; etc.&lt;/P&gt;

&lt;P&gt;The idea is that the inner search will (via the &lt;CODE&gt;fields +&lt;/CODE&gt; command) only return the field &lt;CODE&gt;system&lt;/CODE&gt;, so that the outer search will effectively look like;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;second_search_terms (system=aaa OR system=bbb or system=ccc) | further_processing
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think that this is what you're after.&lt;/P&gt;

&lt;P&gt;EDIT: Fixed a typo&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2013 13:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53011#M12890</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-09-02T13:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53012#M12891</link>
      <description>&lt;P&gt;I'm not sure if this is bringing me further, where did you pass the fieldname to the second search part ?&lt;BR /&gt;
If one of the search is returning "system1" as result, I have to read the content of the "system1" field in the second part...&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2013 05:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53012#M12891</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-09-03T05:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53013#M12892</link>
      <description>&lt;P&gt;Read up on how subsearches work. &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/Tutorial/Useasubsearch"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/Tutorial/Useasubsearch&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2013 07:24:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53013#M12892</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-09-03T07:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53014#M12893</link>
      <description>&lt;P&gt;I know pretty well how subsearch work, that doesn't help, but maybe is return what I'm searching for&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/Return"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/Return&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I think change subsearch order like Kristian suggested + return function should do the job&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2013 11:37:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53014#M12893</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-09-05T11:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: use a result value, as fieldname in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53015#M12894</link>
      <description>&lt;P&gt;well, &lt;CODE&gt;return&lt;/CODE&gt; and &lt;CODE&gt;fields&lt;/CODE&gt; are pretty similar in effect&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2013 12:41:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/use-a-result-value-as-fieldname-in-subsearch/m-p/53015#M12894</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-09-05T12:41:07Z</dc:date>
    </item>
  </channel>
</rss>

