<?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: Combine the two queries and calculate count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345373#M165969</link>
    <description>&lt;P&gt;Hey @zork67, if @somesoni2 solved your problem, please don't forget to accept an answer! You can upvote posts as well. (Karma points will be awarded for either action.) Happy Splunking!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2017 00:12:39 GMT</pubDate>
    <dc:creator>lfedak_splunk</dc:creator>
    <dc:date>2017-09-22T00:12:39Z</dc:date>
    <item>
      <title>Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345371#M165967</link>
      <description>&lt;P&gt;Hello experts. &lt;/P&gt;

&lt;P&gt;I tried to execute the query, as described here &lt;A href="https://answers.splunk.com/answers/106906/how-to-perform-math-on-single-values.html"&gt;https://answers.splunk.com/answers/106906/how-to-perform-math-on-single-values.html&lt;/A&gt;  &lt;/P&gt;

&lt;P&gt;In my case, too, there are two requests.&lt;/P&gt;

&lt;P&gt;1st search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ns SUBMIT_SM  REQUEST host="notif*" | rex field=_raw "CID\:(?&amp;lt;CID&amp;gt;.*)\ actor-id" | dedup CID 
 | stats count as part 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2nd search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ns SUBMIT_SM  REQUEST host="notif*" | stats count as uniq
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to combine these requests into one to calculate the ratio&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | multisearch
       [ search index=ns SUBMIT_SM  REQUEST host="notif*" | rex field=_raw "CID\:(?&amp;lt;CID&amp;gt;.*)\ actor-id" | dedup CID 
         | eval marker="s" ]
       [ search index=ns SUBMIT_SM  REQUEST host="notif*" 
         | eval marker="o" ]
     | stats count(eval(marker=="s")) as part
             count(eval(marker=="o")) as uniq
     | eval velocity=(part/uniq)*100)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I receive an error:&lt;/P&gt;

&lt;P&gt;Error in 'multisearch' command: Multisearch subsearches may only contain purely streaming operations (subsearch 1 contains a non-streaming command.)&lt;BR /&gt;
The search job has failed due to an error. You may be able to see the job in the Job Inspector.&lt;/P&gt;

&lt;P&gt;I tried it differently&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ns SUBMIT_SM  REQUEST host="notif*" 
 | stats count as part 
 | append [ search index=ns SUBMIT_SM  REQUEST host="notif*" | rex field=_raw "CID\:(?&amp;lt;CID&amp;gt;.*)\ actor-id" | dedup CID | stats count as uniq] | eval velocity=part/uniq
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But velocity was not calculated&lt;/P&gt;

&lt;P&gt;Help&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345371#M165967</guid>
      <dc:creator>zork67</dc:creator>
      <dc:date>2017-09-21T15:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345372#M165968</link>
      <description>&lt;P&gt;I would do like this (as both have same base search)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ns SUBMIT_SM  REQUEST host="notif*" | rex field=_raw "CID\:(?&amp;lt;CID&amp;gt;.*)\ actor-id"
| stats dc(CID) as part count as uniq
| eval velocity=(part/uniq)*100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 16:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345372#M165968</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-21T16:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345373#M165969</link>
      <description>&lt;P&gt;Hey @zork67, if @somesoni2 solved your problem, please don't forget to accept an answer! You can upvote posts as well. (Karma points will be awarded for either action.) Happy Splunking!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 00:12:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345373#M165969</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-09-22T00:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345374#M165970</link>
      <description>&lt;P&gt;Thanks, but still an error&lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The expression is malformed.&lt;BR /&gt;
The search job has failed due to an error. You may be able view the job in the Job Inspector.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 09:37:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345374#M165970</guid>
      <dc:creator>zork67</dc:creator>
      <dc:date>2017-09-22T09:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345375#M165971</link>
      <description>&lt;P&gt;There is an additional braces in the eval, removed. (search was copied from question so didn't see that)&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 14:37:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345375#M165971</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-22T14:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345376#M165972</link>
      <description>&lt;P&gt;I decided this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ns SUBMIT_SM  REQUEST host="notif*" 
| stats count as part 
| appendcols [search index=ns SUBMIT_SM  REQUEST host="notif*" 
| rex field=_raw "CID\:(?&amp;lt;CID&amp;gt;.*)\ actor-id" 
| dedup CID
| stats count(CID) as uniq ]
| eval ratio=part/uniq
| fields ratio
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks to all&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 14:40:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345376#M165972</guid>
      <dc:creator>zork67</dc:creator>
      <dc:date>2017-09-22T14:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Combine the two queries and calculate count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345377#M165973</link>
      <description>&lt;P&gt;@zork67 If your problem is resolved, please accept an answer (it's OK to accept your own answer) to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 15:20:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-the-two-queries-and-calculate-count/m-p/345377#M165973</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-09-22T15:20:56Z</dc:date>
    </item>
  </channel>
</rss>

