<?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: subsearch result as source in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563280#M196257</link>
    <description>&lt;P&gt;That's curious, I don't need the explicit "| fields source" in multiple tests on my 8.2.x environment... I know I missed the "as source" in my original response, then quickly edited it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Aug 2021 13:10:30 GMT</pubDate>
    <dc:creator>terminaloutcome</dc:creator>
    <dc:date>2021-08-14T13:10:30Z</dc:date>
    <item>
      <title>subsearch result as source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563256#M196245</link>
      <description>&lt;P&gt;&amp;nbsp;I am trying to craft a search that uses the most recent source as the basis for my search. The source is a file path &amp;lt;&lt;SPAN&gt;C:\foo\bar.csv&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I think that a sub search is the best option because the source name is going to change weekly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my sub search that returns one result with the file name&lt;/P&gt;&lt;P&gt;index=foo&lt;BR /&gt;| stats latest(source) AS SourceName&lt;BR /&gt;| return $SourceName&lt;/P&gt;&lt;P&gt;This is the search that I am trying to use:&lt;/P&gt;&lt;P&gt;index= foo | eval source=[search index=foo | stats latest(source) AS SN | return $SN ]&lt;/P&gt;&lt;P&gt;But I am getting this error:&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Error in 'eval' command: The expression is malformed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have tested it when using the file path instead of the sub search and it does work but there is one problem. I need to put the file path in quotes. I am thinking that things are breaking down because the file path has \'s in it. I tried to look into concatenating strings&amp;nbsp; to put the sub-search in quotes and I found the strcat command but that is looking for 2 fields instead of one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 20:59:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563256#M196245</guid>
      <dc:creator>mpartee</dc:creator>
      <dc:date>2021-08-13T20:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch result as source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563265#M196250</link>
      <description>&lt;P&gt;Start by running the subsearch by itself to verify the result is reasonably correct as a source name.&lt;/P&gt;&lt;P&gt;Once you have that working, I agree you'll likely run into problems with backslashes.&amp;nbsp; Regrettably, I don't have a working method to escape backslashes because they're also the escape character.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2021 00:47:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563265#M196250</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-08-14T00:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch result as source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563277#M196255</link>
      <description>&lt;P&gt;How about this? I don't have a windows machine to try but it works on test data:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;index=foo&lt;BR /&gt;&amp;nbsp; [&amp;nbsp;|&amp;nbsp;tstats latest(source) as source where index=foo&amp;nbsp;]&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2021 12:57:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563277#M196255</guid>
      <dc:creator>terminaloutcome</dc:creator>
      <dc:date>2021-08-14T12:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch result as source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563278#M196256</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233073"&gt;@mpartee&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Correction to&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/167526"&gt;@terminaloutcome&lt;/a&gt;&amp;nbsp;solution, below should work for you;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo
  [ | tstats latest(source) as source where index=foo | fields source ] &lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 14 Aug 2021 13:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563278#M196256</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-08-14T13:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch result as source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563280#M196257</link>
      <description>&lt;P&gt;That's curious, I don't need the explicit "| fields source" in multiple tests on my 8.2.x environment... I know I missed the "as source" in my original response, then quickly edited it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2021 13:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-result-as-source/m-p/563280#M196257</guid>
      <dc:creator>terminaloutcome</dc:creator>
      <dc:date>2021-08-14T13:10:30Z</dc:date>
    </item>
  </channel>
</rss>

