<?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 do I find count of duplicates along with total events count? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296257#M89385</link>
    <description>&lt;P&gt;You can simplify building raw and get the same results, to wit:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="val1 val1 val2 val2 val3" | makemv delim=" " raw | mvexpand raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Jan 2018 17:58:55 GMT</pubDate>
    <dc:creator>wrangler2x</dc:creator>
    <dc:date>2018-01-12T17:58:55Z</dc:date>
    <item>
      <title>How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296250#M89378</link>
      <description>&lt;P&gt;I have &lt;CODE&gt;payload&lt;/CODE&gt; field in my events with duplicate values like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;val1
val1
val2
val2
val3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to do I search for the count of duplicate events (in above e.g 2 with val1,val2) vs count of total events (5)? I am able to find duplicates using search &lt;CODE&gt;stats count by payload  | where count &amp;gt; 1&lt;/CODE&gt; but can't able to figure out beyond that...&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 00:04:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296250#M89378</guid>
      <dc:creator>relango</dc:creator>
      <dc:date>2018-01-12T00:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296251#M89379</link>
      <description>&lt;P&gt;hey &lt;/P&gt;

&lt;P&gt;Try this run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="val1" | append [| makeresults | eval raw="val1" ] | append [| makeresults | eval raw="val2"] | append [| makeresults | eval raw="val2" ] | append [| makeresults | eval raw="val3" ] | stats count(raw) as count by raw  | eventstats sum(count) as total_count | where count &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ideally in your environment you should write&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch | stats count(payload) as count by payload| eventstats sum(count) as total_count | where count &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this works!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 08:29:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296251#M89379</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-12T08:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296252#M89380</link>
      <description>&lt;P&gt;Thanks that works!. But I actually want to count the duplicates and also bucket it by time. Here what I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch | bin _time span=1d| stats count by payload,_time | eventstats sum(count) as total | where count &amp;gt; 1 | eventstats count as dup_count | table count, dup_count, total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works, but one problem. The results are repeated for each value of payload and _time. How can I get just one result for each day. &lt;/P&gt;

&lt;P&gt;Basically, I am trying to find the percentage of duplicate payloads per day by computing count of duplicate payloads per day and total number of payloads&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296252#M89380</guid>
      <dc:creator>relango</dc:creator>
      <dc:date>2018-01-12T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296253#M89381</link>
      <description>&lt;P&gt;hey I do not understand what do you want to achieve. You can just provide me sample input like you did for the above question and also provide what output you want.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:08:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296253#M89381</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-12T15:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296254#M89382</link>
      <description>&lt;P&gt;Using above example: I added one more duplicate "val4" to above example and tried this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="val1" | append [| makeresults | eval raw="val1" ] | append [| makeresults | eval raw="val2"] | append [| makeresults | eval raw="val2" ] | append [| makeresults | eval raw="val3" ]| append [| makeresults | eval raw="val4" ] | append [| makeresults | eval raw="val4" ]   | stats count(raw) as count by raw  | eventstats sum(count) as total_count | where count &amp;gt; 1 |eventstats count as dup_count | table dup_count,total_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It correctly returns dup_count as 3 and total_count 7 , but it is repeated three times for each duplicated value (val1,val2,val3) , but I just need one.&lt;/P&gt;

&lt;P&gt;Piping it to &lt;CODE&gt;| dedup total_count&lt;/CODE&gt; works for this eg: but not for the actual use case in which I am also trying to bucket stats by 1 day. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:38:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296254#M89382</guid>
      <dc:creator>relango</dc:creator>
      <dc:date>2020-09-29T17:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296255#M89383</link>
      <description>&lt;P&gt;you are misunderstanding the concept &lt;CODE&gt;| dedup total_count&lt;/CODE&gt;  is just removing duplicates in a column  as you have three time 7 now after this it is showing only one time as it removed duplicates  whereas &lt;CODE&gt;|eventstats count as dup_count&lt;/CODE&gt; works at each event/row which means total statistics if you see you have three rows that is why it is returning 3 &lt;BR /&gt;
I hope you understand what I am trying to say&lt;BR /&gt;
If you are interested to find total payloads and duplicated payloads then try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="val1" | append [| makeresults | eval raw="val1" ] | append [| makeresults | eval raw="val2"] | append [| makeresults | eval raw="val2" ] | append [| makeresults | eval raw="val3" ]| append [| makeresults | eval raw="val4" ] | append [| makeresults | eval raw="val4" ]   | stats count(raw) as count by raw   | eventstats sum(count) as total_count | where count &amp;gt; 1 | stats count as duplicated_payload_count first(total_count) as total_payload_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;as there are &lt;CODE&gt;7&lt;/CODE&gt; entries so &lt;CODE&gt;total_payload_count&lt;/CODE&gt; is &lt;CODE&gt;7&lt;/CODE&gt; and  &lt;CODE&gt;3&lt;/CODE&gt; duplicated entries so &lt;CODE&gt;duplicated_payload_count&lt;/CODE&gt; is three.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 15:37:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296255#M89383</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-12T15:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296256#M89384</link>
      <description>&lt;P&gt;hey did you find above query helpful?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 17:29:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296256#M89384</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-12T17:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296257#M89385</link>
      <description>&lt;P&gt;You can simplify building raw and get the same results, to wit:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="val1 val1 val2 val2 val3" | makemv delim=" " raw | mvexpand raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jan 2018 17:58:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296257#M89385</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2018-01-12T17:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296258#M89386</link>
      <description>&lt;P&gt;I was just looking at another Splunk Answer which was asking something slightly different, and what that person was looking for was to get a running total to the side of the count. I tried to answer that question but it had been closed, with a pointer to this one as being the same question (doesn't look the same to me, but heh...). Here is how you do that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="val1 val1 val2 val2 val3 val4 val4 val4" | makemv delim=" " raw | mvexpand raw
| stats count by raw
| where count &amp;gt; 1
| sort - count
| accum count as totalCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course the line beginning with &lt;CODE&gt;makeresults&lt;/CODE&gt; would be replaced by your base search, as well ast the &lt;CODE&gt;stats count by raw&lt;/CODE&gt;. You get the &lt;STRONG&gt;counts&lt;/STRONG&gt; 3, 2, 2 in this example, and the &lt;STRONG&gt;totalCounts&lt;/STRONG&gt; 3, 5, 7.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 23:08:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296258#M89386</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2018-01-17T23:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find count of duplicates along with total events count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296259#M89387</link>
      <description>&lt;P&gt;The other Splunk Answer is here: &lt;A href="https://answers.splunk.com/answers/609288/how-to-get-count-of-events-as-well-as-count-of-sta.html#answer-form"&gt;https://answers.splunk.com/answers/609288/how-to-get-count-of-events-as-well-as-count-of-sta.html#answer-form&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 23:09:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-count-of-duplicates-along-with-total-events-count/m-p/296259#M89387</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2018-01-17T23:09:27Z</dc:date>
    </item>
  </channel>
</rss>

