<?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: How to get total and sub search total per unique field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390205#M113663</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval exception=coalesce(exception, "WAS_NULL") 
| stats count BY app_id, exception 
| eventstats sum(count) AS total_count BY app_id 
| search NOT exception="WAS_NULL"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See this run-anywhere PoC:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal 
| rename component AS exception, sourcetype AS app_id 
| eval exception=coalesce(exception, "WAS_NULL") 
| stats count BY app_id, exception 
| eventstats sum(count) AS total_count BY app_id 
| search NOT exception="WAS_NULL"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 27 Jul 2019 19:59:25 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-07-27T19:59:25Z</dc:date>
    <item>
      <title>How to get total and sub search total per unique field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390201#M113659</link>
      <description>&lt;P&gt;I'm trying to chart the exception rate of various apps that we run, and would ideally be generating a table that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;App ID | Exception | Number of ops with this exception | Total number of ops for this app
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I haven't quite been able to get it working. The closest I have is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count as total_count, count(exception) as exception_count by app_id, exception
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This isn't quite right since it only finds operations where an exception isn't null. Thus, for every row in the output table, total_count = exception_count. It seems like I need to find all operations, then filters by app_id, then finds the total_count, then filter by exception, then find the exception_count. What's the best way to do this?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390201#M113659</guid>
      <dc:creator>watersd</dc:creator>
      <dc:date>2020-09-30T01:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get total and sub search total per unique field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390202#M113660</link>
      <description>&lt;P&gt;Can you try sum instead of count?&lt;/P&gt;

&lt;P&gt;| stats count as total_count, sum(exception) as exception_count by app_id&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:19:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390202#M113660</guid>
      <dc:creator>nareshinsvu</dc:creator>
      <dc:date>2020-09-30T01:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to get total and sub search total per unique field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390203#M113661</link>
      <description>&lt;P&gt;@watersd for the community to assist you better please add more context to your question. Kindly add some mock/anonymized sample data for us to understand what values you have for app_id, exception and also what an event look like which does not have exception.&lt;BR /&gt;
Can you try the following search where if an event has exception field it will be counted as exception? I have removed &lt;CODE&gt;exception&lt;/CODE&gt; fields from split by field and moved it as aggregate function for counting when it is not null.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
| stats count as total_count, count(eval(isnotnull(exception)) as exception_count by app_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jul 2019 02:45:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390203#M113661</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-07-17T02:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get total and sub search total per unique field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390204#M113662</link>
      <description>&lt;P&gt;Thanks. I updated the question with more info. It seems like I do need the exception field in the split by clause eventually.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 17:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390204#M113662</guid>
      <dc:creator>watersd</dc:creator>
      <dc:date>2019-07-18T17:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to get total and sub search total per unique field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390205#M113663</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval exception=coalesce(exception, "WAS_NULL") 
| stats count BY app_id, exception 
| eventstats sum(count) AS total_count BY app_id 
| search NOT exception="WAS_NULL"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See this run-anywhere PoC:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal 
| rename component AS exception, sourcetype AS app_id 
| eval exception=coalesce(exception, "WAS_NULL") 
| stats count BY app_id, exception 
| eventstats sum(count) AS total_count BY app_id 
| search NOT exception="WAS_NULL"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Jul 2019 19:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390205#M113663</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-27T19:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get total and sub search total per unique field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390206#M113664</link>
      <description>&lt;P&gt;Amazing! That's exactly what I was looking for. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 17:07:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-total-and-sub-search-total-per-unique-field-value/m-p/390206#M113664</guid>
      <dc:creator>watersd</dc:creator>
      <dc:date>2019-07-29T17:07:46Z</dc:date>
    </item>
  </channel>
</rss>

