<?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: Two queries in one - SearchParser Subsearch error in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400013#M115935</link>
    <description>&lt;P&gt;On lines with your query try the following run anywhere example based on &lt;CODE&gt;_internal index and sourcetype splunkd&lt;/CODE&gt;, which works fine for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype="splunkd" "INFO" 
| stats count as totalCount 
| appendcols 
    [ search index=_internal sourcetype="splunkd" "ERROR" 
    | stats count as errorCount] 
| eval errorPercentage = round(((totalCount-errorCount)/totalCount)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, based on the query provided in your question, your main search &lt;CODE&gt;index=logs source="*svc1*"&lt;/CODE&gt; is the same for both &lt;CODE&gt;"transaction attempt"&lt;/CODE&gt; and &lt;CODE&gt;"transaction error"&lt;/CODE&gt; queries. So second search is actually better search based on performance. But please explain why it would not work? What are the different log locations?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Jan 2019 15:59:18 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2019-01-16T15:59:18Z</dc:date>
    <item>
      <title>Two queries in one - SearchParser Subsearch error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400009#M115931</link>
      <description>&lt;P&gt;hi apologies but i'm not very verse in splunk.  i'm trying to run two separate queries in one search but i get the following error.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=logs source="*svc1*" "transaction attempt" | stats count as totalCount | 
appendcols | [search index=logs source="*svc1*" "transaction error" | 
stats count as errorCount] eval (errorPercentage = totalCount - errorCount \ totalCount)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Error&lt;/STRONG&gt;&lt;BR /&gt;
&lt;CODE&gt;Error in 'SearchParser': Subsearches are only valid as arguments to commands. Error at position '205' of search query 'search index=nonprod_applogs source="*svc1-...{snipped} {errorcontext = endcols | [search ind}'.&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 01:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400009#M115931</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2019-01-16T01:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Two queries in one - SearchParser Subsearch error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400010#M115932</link>
      <description>&lt;P&gt;@jaj try the following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=logs source="*svc1*" "transaction attempt" 
| stats count as totalCount 
| appendcols 
    [ search index=logs source="*svc1*" "transaction error" 
    | stats count as errorCount] 
| eval errorPercentage = round(((totalCount-errorCount)/totalCount)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, in order to avoid subsearch limitations you could have tried the following search instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=logs source="*svc1*" "transaction attempt" OR "transaction error" 
| stats count(eval(searchmatch("transaction attempt"))) as totalCount count(eval(searchmatch("transaction error"))) as errorCount
| eval errorPercentage = round(((totalCount-errorCount)/totalCount)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jan 2019 02:41:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400010#M115932</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-16T02:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Two queries in one - SearchParser Subsearch error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400011#M115933</link>
      <description>&lt;P&gt;Thanks @niketnilay however, i still get the same error with your first answer. also there is more than likely a good chance the second search will look at logs from another source (not sv1 but svc2) so i need to try to figure out first solution before consolidating logs. thx&lt;/P&gt;

&lt;P&gt;Error from number one solution:&lt;BR /&gt;
&lt;CODE&gt;Error in 'SearchParser': Subsearches are only valid as arguments to commands. Error at position '211' of search query 'search index=logs source="*svc1...{snipped} {errorcontext = ls | [ search in}'.&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 12:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400011#M115933</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2019-01-16T12:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Two queries in one - SearchParser Subsearch error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400012#M115934</link>
      <description>&lt;P&gt;@niketnilay the second one did work beautifully. however, still trying to figure out how to make 1 work because of two different log locations for each type of match (attempts vs errors). any info is super appreciated thanks&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 13:12:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400012#M115934</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2019-01-16T13:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Two queries in one - SearchParser Subsearch error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400013#M115935</link>
      <description>&lt;P&gt;On lines with your query try the following run anywhere example based on &lt;CODE&gt;_internal index and sourcetype splunkd&lt;/CODE&gt;, which works fine for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype="splunkd" "INFO" 
| stats count as totalCount 
| appendcols 
    [ search index=_internal sourcetype="splunkd" "ERROR" 
    | stats count as errorCount] 
| eval errorPercentage = round(((totalCount-errorCount)/totalCount)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, based on the query provided in your question, your main search &lt;CODE&gt;index=logs source="*svc1*"&lt;/CODE&gt; is the same for both &lt;CODE&gt;"transaction attempt"&lt;/CODE&gt; and &lt;CODE&gt;"transaction error"&lt;/CODE&gt; queries. So second search is actually better search based on performance. But please explain why it would not work? What are the different log locations?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 15:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400013#M115935</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-16T15:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Two queries in one - SearchParser Subsearch error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400014#M115936</link>
      <description>&lt;P&gt;@niketnilay worked beautifully! thanks so much &lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 18:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-queries-in-one-SearchParser-Subsearch-error/m-p/400014#M115936</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2019-01-16T18:14:52Z</dc:date>
    </item>
  </channel>
</rss>

