<?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: Addtotals possible on stats list/count search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228369#M67509</link>
    <description>&lt;P&gt;Ok. Thank you for your explanation.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2019 16:14:23 GMT</pubDate>
    <dc:creator>jam00</dc:creator>
    <dc:date>2019-07-30T16:14:23Z</dc:date>
    <item>
      <title>Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228360#M67500</link>
      <description>&lt;P&gt;I have the following search results and would like to add the count totals up. If I add the following line:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|addtotals fieldname=Blocks
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I see the total, but the issue is for items with only one line, their count is doubled (for example, the second line with a count of &lt;CODE&gt;2899&lt;/CODE&gt; has a total of &lt;CODE&gt;5798&lt;/CODE&gt;. How do I make sure single counts in the list don't get doubled when adding the totals?&lt;/P&gt;

&lt;P&gt;Thx&lt;/P&gt;

&lt;P&gt;Broken scenario using &lt;CODE&gt;addtotals&lt;/CODE&gt; command that doubles the count for IPs that have only one domain listed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_ip     Domain                   count     Blocks
0.0.0.0    fox169.tlscdn.com         2899       5798

1.1.1.1    video.cynogage.com        3643       3886
           serve.blutonic-ads.com     160
           conf.wsm.360.cn             71
           sconf.f.360.cn              11
           quri.f.360.cn                1

2.2.2.2    video.cynogage.com        2301       2305
           rdcdn.com                    4

3.3.3.3    video.cynogage.com         594       1188

4.4.4.4    video.cynogage.com         576       1152

5.5.5.5    video.cynogage.com         837        873
           serve.blutonic-ads.com      36

6.6.6.6    video.cynogage.com         663        705
           serve.blutonic-ads.com      42

7.7.7.7    video.cynogage.com         563        566
           serve.blutonic-ads.com       3

8.8.8.8    lb.cdn.e-adguardian.com    111        517
           lb.cdn.d-adguardian.com    110
           lb.cdn.a-adguardian.com    109
           lb.cdn.c-adguardian.com    102
           lb.mspt4-01.com             79
           lb.msps4-01.com              6

9.9.9.9    video.cynogage.com         506        516
           dopefile.com                 6
           us-nj-e3.rtbauction.com      4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using the search of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname
| stats count BY domain, src_ip
| sort 0 -count 
| stats list(domain) AS Domain, list(count) AS count, sum(count) AS total BY src_ip
| sort 0 -total | head 10
| fields - total
| addtotals fieldname=Blocks
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Domain                   count     Blocks
video.cynogage.com        3643
serve.blutonic-ads.com     160
conf.wsm.360.cn             71
sconf.f.360.cn              11
quri.f.360.cn                1

fox169.tlscdn.com         2899       2899

video.cynogage.com        2301
rdcdn.com                    4

video.cynogage.com         837
serve.blutonic-ads.com      36

video.cynogage.com         663
serve.blutonic-ads.com      42

video.cynogage.com         594        594

video.cynogage.com         576        576

video.cynogage.com         563
serve.blutonic-ads.com       3

video.cynogage.com         506
dopefile.com                 6
us-nj-e3.rtbauction.com      4

lb.cdn.e-adguardian.com    111
lb.cdn.d-adguardian.com    110
lb.cdn.a-adguardian.com    109
lb.cdn.c-adguardian.com    102
lb.mspt4-01.com             79
lb.msps4-01.com              6
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:38:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228360#M67500</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2016-04-29T17:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228361#M67501</link>
      <description>&lt;P&gt;I completely do not understand your scenario; show us working and broken examples.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:50:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228361#M67501</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-29T17:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228362#M67502</link>
      <description>&lt;P&gt;Added broken scenario - thx&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 18:07:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228362#M67502</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2016-04-29T18:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228363#M67503</link>
      <description>&lt;P&gt;Based on the image, we need to see more of your search, too.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 18:29:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228363#M67503</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-29T18:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228364#M67504</link>
      <description>&lt;P&gt;Search is as follows:&lt;/P&gt;

&lt;P&gt;index=indexname&lt;BR /&gt;
|stats count by domain,src_ip&lt;BR /&gt;
|sort -count &lt;BR /&gt;
|stats list(domain) as Domain, list(count) as count, sum(count) as total by src_ip&lt;BR /&gt;
|sort -total | head 10&lt;BR /&gt;
|addtotals fieldname=Blocks&lt;BR /&gt;
|fields - total&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228364#M67504</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2020-09-29T09:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228365#M67505</link>
      <description>&lt;P&gt;OK, first let's spoof the data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| noop
| stats count as trash
| eval trash="0.0.0.0,fox169.tlscdn.com,2899::1.1.1.1,video.cynogage.com,3643::1.1.1.1,serve.blutonic-ads.com,160::1.1.1.1,conf.wsm.360.cn,71::1.1.1.1,sconf.f.360.cn,11::1.1.1.1,quri.f.360.cn,1::2.2.2.2,video.cynogage.com,2301::2.2.2.2,rdcdn.com,4::3.3.3.3,video.cynogage.com,594::4.4.4.4,video.cynogage.com,576::5.5.5.5,video.cynogage.com,837::5.5.5.5,serve.blutonic-ads.com,36::6.6.6.6,video.cynogage.com,663::6.6.6.6,serve.blutonic-ads.com,42::7.7.7.7,video.cynogage.com,563::7.7.7.7,serve.blutonic-ads.com,3::8.8.8.8,lb.cdn.e-adguardian.com,111::8.8.8.8,lb.cdn.d-adguardian.com,110::8.8.8.8,lb.cdn.a-adguardian.com,109::8.8.8.8,lb.cdn.c-adguardian.com,102::8.8.8.8,lb.mspt4-01.com,79::8.8.8.8,lb.msps4-01.com,6::9.9.9.9,video.cynogage.com,506::9.9.9.9,dopefile.com,6::9.9.9.9,us-nj-e3.rtbauction.com,4"
| makemv delim="::" trash
| mvexpand trash
| rex field=trash "(?&amp;lt;src_ip&amp;gt;[^,]+),(?&amp;lt;domain&amp;gt;[^,]+),(?&amp;lt;count&amp;gt;[^,]+)"
| fields - trash
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, these events are pre-counted so this next line will be different than yours (keep yours the same):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(count) AS count BY domain, src_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally, here is the adjusted/repaired remainder:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| sort 0 -count 
| stats list(domain) AS Domain, list(count) AS count, sum(count) AS total BY src_ip
| sort 10 -total
| rename Total AS Blocks
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jun 2016 05:06:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228365#M67505</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-24T05:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228366#M67506</link>
      <description>&lt;P&gt;Thx - query works great&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 15:08:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228366#M67506</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2016-07-05T15:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228367#M67507</link>
      <description>&lt;P&gt;Hello @woodcock. I'm not sure I understand the logic behind &lt;CODE&gt;|stats count as trash&lt;/CODE&gt;. &lt;BR /&gt;
With &lt;CODE&gt;stats count&lt;/CODE&gt; you get a 0 result. If you rename that with "trash" you're only changing the name. But without that initial statement, the query doesn't work. So,  what is the key to understand your first query? Because, you are creating a field "trash" with eval command from scratch. It's true that the field "trash" already exists from stats and you are feeding it with the eval command but I don't understand why is necessary. I'm not getting the pre-counted concept you comment, probably.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 11:06:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228367#M67507</guid>
      <dc:creator>jam00</dc:creator>
      <dc:date>2019-07-30T11:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228368#M67508</link>
      <description>&lt;P&gt;Before &lt;CODE&gt;makeresults&lt;/CODE&gt; existed, we used to use &lt;CODE&gt;| noop | stats count&lt;/CODE&gt; to create an event out of nothing.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 14:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228368#M67508</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-30T14:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Addtotals possible on stats list/count search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228369#M67509</link>
      <description>&lt;P&gt;Ok. Thank you for your explanation.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 16:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Addtotals-possible-on-stats-list-count-search/m-p/228369#M67509</guid>
      <dc:creator>jam00</dc:creator>
      <dc:date>2019-07-30T16:14:23Z</dc:date>
    </item>
  </channel>
</rss>

