<?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: Syntax/use of subsearches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681365#M232828</link>
    <description>&lt;P&gt;format can take up to 6 parameters - these default so that the values are put in quotes, there are ANDs between field/value pairs from the same row, rows are enclosed in brackets, there are ORs between rows, and the whole thing is enclosed in brackets. For example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;( ( a="11" AND b="21" AND c="31" ) OR ( a="12" AND b="22" AND c="32" ) OR ( a="13" AND b="23" AND c="33" ) )&lt;/LI-CODE&gt;&lt;P&gt;These are how the parameter (positions) map to the formatted result&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1 2 a="11" 3 b="21" 3 c="31" 4 5 2 a="12" 3 b="22" 3 c="32" 4 5 2 a="13" 3 b="23" 3 c="33" 4 6&lt;/LI-CODE&gt;&lt;P&gt;You can test this with this runanywhere example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=3
| streamstats count as a
| eval a=a+10, b=a+10, c=a+20
| format 1 2 3 4 5 6&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 20 Mar 2024 12:01:06 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2024-03-20T12:01:06Z</dc:date>
    <item>
      <title>Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681323#M232819</link>
      <description>&lt;P&gt;I have a query …&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;index=blah "BAD_REQUEST" | rex "(?i) requestId (?P&amp;lt;requestId&amp;gt;[^:]+)" | table requestId | dedup requestId&lt;/P&gt;&lt;P&gt;…that returns 7 records/fields…&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;92d246dd-7aac-41f7-a398-27586062e4fa&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;ba79c6f5-5452-4211-9b89-59d577adbc50&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;711b9bb4-b9f1-4a2b-ba56-f2b3a9cdf87c&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;e227202a-0b0a-4cdf-9b11-3080b0ce280f&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;6099d5a3-61fc-418b-87b4-ddc57c482dd6&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;348fb576-0c36-4de9-a55a-97157b00a304&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;c34b7b96-094d-45bb-b03d-f9c98a4efd5f&lt;/P&gt;&lt;P&gt;…that I then want to use as input for another search on the same index&lt;/P&gt;&lt;P&gt;I looked at manual and can see that subsearches are allowed [&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/9.1.2312/Search/Aboutsubsearches" target="_blank" rel="noopener"&gt;About subsearches - Splunk Documentation&lt;/A&gt;] but when I add my subsearch as input …&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;index=blah [search &lt;EM&gt;index=blah "BAD_REQUEST" | rex "(?i) requestId (?P&amp;lt;requestId&amp;gt;[^:]+)" | table requestId | dedup requestId&lt;/EM&gt;]&lt;/P&gt;&lt;P&gt;..I would have expected at least 7 records to have been returned BUT I do not see any output.&lt;/P&gt;&lt;P&gt;There are no syntax issues so can someone explain to me what I’m not seeing/doing?&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 08:06:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681323#M232819</guid>
      <dc:creator>Mick_OBrien</dc:creator>
      <dc:date>2024-03-20T08:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681334#M232821</link>
      <description>&lt;P&gt;Your search assume that requestid has already been extracted into a field in the index. If you want to just do a string search based on the requestids, try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=blah [search index=blah "BAD_REQUEST" | rex "(?i) requestId (?P&amp;lt;search&amp;gt;[^:]+)" | table search | dedup search]&lt;/LI-CODE&gt;&lt;P&gt;The field search (and query) are given special treatment for subsearches in that the field name is not return, just the contents of the field&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 09:20:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681334#M232821</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-20T09:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681346#M232822</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;&lt;/P&gt;&lt;P&gt;Changed to match format as detailed...&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;index=blah [search index=blah "BAD_REQUEST" | rex "(?i) requestId (?P&amp;lt;&lt;STRONG&gt;search&lt;/STRONG&gt;&amp;gt;[^:]+)" | table &lt;STRONG&gt;search&lt;/STRONG&gt; | dedup &lt;STRONG&gt;search&lt;/STRONG&gt;]&lt;/P&gt;&lt;P&gt;...but new format ONLY returned rows containing&amp;nbsp;&lt;SPAN&gt;92d246dd-7aac-41f7-a398-27586062e4fa [first row] and no other rows.&amp;nbsp; I removed 'dedup' but that did not help&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can I include all returned items from inner search as input to outer [main] search?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 10:18:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681346#M232822</guid>
      <dc:creator>Mick_OBrien</dc:creator>
      <dc:date>2024-03-20T10:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681350#M232824</link>
      <description>&lt;P&gt;Firstly, if your subsearch uses the same source index as the outer search, it's more often than not that the search can be written without using the subsearch.&lt;/P&gt;&lt;P&gt;Secondly, the subsearches have their limitations (for execution time and number of returned results). Their most confusing and annoying "feature" however is that if the subsearch hits such limit, it gets silently finalized and you're only getting partial (possibly empty) results from the subsearch _with no warning about that whatsoever_.&lt;/P&gt;&lt;P&gt;So if your subsearch run on its own produces proper results and your "outer search" with the results from the subsearch manually copy-pasted produces proper results as well it's highly probable that this is the issue you're hitting.&lt;/P&gt;&lt;P&gt;Check your job log to see what your main search is rendered into in the end (after the subsearch is run).&lt;/P&gt;&lt;P&gt;(Of course &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; 's point of field extraction is still valid).&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 10:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681350#M232824</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-03-20T10:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681354#M232826</link>
      <description>&lt;P&gt;Try with format (I thought this was no longer necessary but it looks like it is!)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=blah [search index=blah "BAD_REQUEST" | rex "(?i) requestId (?P&amp;lt;search&amp;gt;[^:]+)" | table search | dedup search | format]&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 20 Mar 2024 10:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681354#M232826</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-20T10:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681357#M232827</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;&lt;/P&gt;&lt;P&gt;With 'format' at the end worked - thank you very much&lt;/P&gt;&lt;P&gt;Just checked documentation which indicates [to me] that returned string have input search results separated by 'OR' command - do I understand correctly?&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Format" target="_blank" rel="noopener"&gt;format - Splunk Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This command is used implicitly by subsearches. This command takes the results of a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;A title="Splexicon:Subsearch" href="https://docs.splunk.com/Splexicon:Subsearch" target="_blank" rel="noopener noreferrer"&gt;subsearch&lt;/A&gt;&lt;/STRONG&gt;, formats the results into a single result and places that result into a new field called&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;search.&lt;/P&gt;&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;format&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command performs similar functions as the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="http://docs.splunk.com/Documentation/SplunkCloud/9.1.2312/SearchReference/Return" target="_blank" rel="noopener"&gt;return&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;mvsep&lt;STRONG&gt;Syntax:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;mvsep="&amp;lt;string&amp;gt;"&lt;STRONG&gt;Description:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;The separator to use for multivalue fields.&lt;STRONG&gt;Default:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ORmvsep&lt;STRONG&gt;Syntax:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;mvsep="&amp;lt;string&amp;gt;"&lt;STRONG&gt;Description:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;The separator to use for multivalue fields.&lt;STRONG&gt;Default:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 11:01:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681357#M232827</guid>
      <dc:creator>Mick_OBrien</dc:creator>
      <dc:date>2024-03-20T11:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681365#M232828</link>
      <description>&lt;P&gt;format can take up to 6 parameters - these default so that the values are put in quotes, there are ANDs between field/value pairs from the same row, rows are enclosed in brackets, there are ORs between rows, and the whole thing is enclosed in brackets. For example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;( ( a="11" AND b="21" AND c="31" ) OR ( a="12" AND b="22" AND c="32" ) OR ( a="13" AND b="23" AND c="33" ) )&lt;/LI-CODE&gt;&lt;P&gt;These are how the parameter (positions) map to the formatted result&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1 2 a="11" 3 b="21" 3 c="31" 4 5 2 a="12" 3 b="22" 3 c="32" 4 5 2 a="13" 3 b="23" 3 c="33" 4 6&lt;/LI-CODE&gt;&lt;P&gt;You can test this with this runanywhere example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=3
| streamstats count as a
| eval a=a+10, b=a+10, c=a+20
| format 1 2 3 4 5 6&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 20 Mar 2024 12:01:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681365#M232828</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-20T12:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681398#M232844</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;&lt;/P&gt;
&lt;P&gt;I ran...&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults count=3
| streamstats count as a
| eval a=a+10, b=a+10, c=a+20
| format&lt;/LI-CODE&gt;
&lt;P&gt;...which gave...&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;( ( a="11" AND b="21" AND c="31" ) OR ( a="12" AND b="22" AND c="32" ) OR ( a="13" AND b="23" AND c="33" ) )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...which tallies with fields/rows as 'AND'/'OR' but if don't understand output from your original example...&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults count=3
| streamstats count as a
| eval a=a+10, b=a+10, c=a+20
| format 1 2 3 4 5 6&lt;/LI-CODE&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;1 2 a="11" 3 b="21" 3 c="31" 4 5 2 a="12" 3 b="22" 3 c="32" 4 5 2 a="13" 3 b="23" 3 c="33" 4 6&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;??&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 14:19:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681398#M232844</guid>
      <dc:creator>Mick_OBrien</dc:creator>
      <dc:date>2024-03-20T14:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681414#M232856</link>
      <description>&lt;P&gt;Suppose you wanted a differently formatted return, e.g. &amp;amp; for AND | for OR, curly brackets for the inner group and square brackets for the outer group, you would substitute the corresponding numbers for the symbols you wanted, e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=3
| streamstats count as a
| eval a=a+10, b=a+10, c=a+20
| format "[" "{" "&amp;amp;" "}" "|" "]"&lt;/LI-CODE&gt;&lt;P&gt;which gives&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[ { a="11" &amp;amp; b="21" &amp;amp; c="31" } | { a="12" &amp;amp; b="22" &amp;amp; c="32" } | { a="13" &amp;amp; b="23" &amp;amp; c="33" } ]&lt;/LI-CODE&gt;&lt;P&gt;Possibly not the most useful example, but I have used this sort of thing to, for example, remove the brackets, and change the ANDs to ORs etc.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 15:39:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681414#M232856</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-03-20T15:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax/use of subsearches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681417#M232857</link>
      <description>&lt;P&gt;Thanks - now I get it&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 15:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Syntax-use-of-subsearches/m-p/681417#M232857</guid>
      <dc:creator>Mick_OBrien</dc:creator>
      <dc:date>2024-03-20T15:58:18Z</dc:date>
    </item>
  </channel>
</rss>

