<?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: Why am I getting incorrect stats count in my search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570882#M198947</link>
    <description>&lt;P&gt;Normally you can use stats values(*) as * by X&lt;/P&gt;&lt;P&gt;to do deduping and X can be whatever grouping you need to get the correct info. values(*) as * will aggregate all fields to their same name, but you may then find multi-value fields that occur, that will depend on your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Oct 2021 00:55:55 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2021-10-14T00:55:55Z</dc:date>
    <item>
      <title>Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570815#M198920</link>
      <description>&lt;P&gt;I'm trying to display a total count for each value found in attributes.eventtype&amp;nbsp;field and group them by the attributes.campaignname field. I'm display these stats from 2 specified values in attributes.campaignname:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=mail sourcetype="phish-campaign-logs" attributes.campaignname="Undelivered Phishing Campaign - FY21Q2 - 062421" OR attributes.campaignname="O365 Re-authentication - FY21Q3"
| spath output=eventtype attributes.eventtype
| dedup id
| stats count(eval(eventtype="Data Submission")) AS Data_Submission, count(eval(eventtype="Email Click")) AS Email_Click, count(eval(eventtype="Email View")) AS Email_View, , count(eval(eventtype="No Action")) AS No_Action, count(eval(eventtype="TM Complete")) AS TM_Complete, count(eval(eventtype="TM Sent")) AS TM_Sent BY attributes.campaignname
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;When running the search, I'm receiving smaller counts on each of the values in eventtype for one of the campaigns specified, "Undelivered Phishing Campaign - FY21Q2 - 062421"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="stat-cnt-multi-campaign.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/16402i60EAFDFE614D91AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="stat-cnt-multi-campaign.png" alt="stat-cnt-multi-campaign.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;If I only specify this campaign in my search, I'm able to receive back the expected total count on each of the values:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=mail sourcetype="phish-campaign-logs" attributes.campaignname="Undelivered Phishing Campaign - FY21Q2 - 062421"
| spath output=eventtype attributes.eventtype
| dedup id
| stats count(eval(eventtype="Data Submission")) AS Data_Submission, count(eval(eventtype="Email Click")) AS Email_Click, count(eval(eventtype="Email View")) AS Email_View, , count(eval(eventtype="No Action")) AS No_Action, count(eval(eventtype="TM Complete")) AS TM_Complete, count(eval(eventtype="TM Sent")) AS TM_Sent BY attributes.campaignname
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stat-cnt-single-campaign.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/16403i70F52098450BC494/image-size/large?v=v2&amp;amp;px=999" role="button" title="stat-cnt-single-campaign.png" alt="stat-cnt-single-campaign.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help me to make this search working properly. Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 16:42:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570815#M198920</guid>
      <dc:creator>surly78</dc:creator>
      <dc:date>2021-10-13T16:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570824#M198926</link>
      <description>&lt;P&gt;It may not make a difference, but I suggest using parentheses to make sure the base search is interpreted correctly.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=mail sourcetype="phish-campaign-logs" (attributes.campaignname="Undelivered Phishing Campaign - FY21Q2 - 062421" OR attributes.campaignname="O365 Re-authentication - FY21Q3")
...&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 17:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570824#M198926</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-10-13T17:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570849#M198939</link>
      <description>&lt;P&gt;Try one of these:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=mail sourcetype="phish-campaign-logs" attributes.campaignname="Undelivered Phishing Campaign - FY21Q2 - 062421"
| spath output=eventtype attributes.eventtype
| stats count(eval(eventtype="Data Submission")) AS Data_Submission, count(eval(eventtype="Email Click")) AS Email_Click, count(eval(eventtype="Email View")) AS Email_View, , count(eval(eventtype="No Action")) AS No_Action, count(eval(eventtype="TM Complete")) AS TM_Complete, count(eval(eventtype="TM Sent")) AS TM_Sent BY attributes.campaignname
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=mail sourcetype="phish-campaign-logs" attributes.campaignname="Undelivered Phishing Campaign - FY21Q2 - 062421"
| spath output=eventtype attributes.eventtype
| chart dc(id) by attributes.campaignname eventtype
| addtotals&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 19:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570849#M198939</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-10-13T19:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570860#M198942</link>
      <description>&lt;P&gt;May not be relevant, but as soon as you do a dedup, you may remove data that should not be removed.&lt;/P&gt;&lt;P&gt;The fact that you are doing a dedup id, implies that there is more than one event per id. Are you sure that the dedup is not removing some events that may have the eventtype you are looking for, or can the 'id' be common to different campaignname? If so, and your data looks like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eventtype=Data Submission, id=1 campaingname=O365 Re-authentication - FY21Q3
eventtype=Data Submission, id=1 campaingname=Undelivered Phishing Campaing - FY21Q2 - 062421&lt;/LI-CODE&gt;&lt;P&gt;then the dedup id will remove the second row. Similarly the second row would be removed in this case too.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eventtype=No Action, id=1 campaingname=Undelivered Phishing Campaing - FY21Q2 - 062421
eventtype=Data Submission, id=1 campaingname=Undelivered Phishing Campaing - FY21Q2 - 062421&lt;/LI-CODE&gt;&lt;P&gt;Also, please note that although it may not be an issue here, the field name eventtype should not be used, as it may conflict with Splunk's event types&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.2/Knowledge/Abouteventtypes" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.2/Knowledge/Abouteventtypes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Choose a different name, just to be sure.&lt;/P&gt;&lt;P&gt;To help you diagnose your issue, try the following search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=mail sourcetype="phish-campaign-logs" attributes.campaignname="Undelivered Phishing Campaign - FY21Q2 - 062421" OR attributes.campaignname="O365 Re-authentication - FY21Q3"
| spath output=eventtype attributes.eventtype
| stats count BY attributes.campaignname eventtype&lt;/LI-CODE&gt;&lt;P&gt;but try it WITH and WITHOUT the dedup id in there before the stats, which should help you understand your data. Also, you can add in 'id' as another 'by' field in the stats to see the numbers. That should help you understand the effect of dedup.&amp;nbsp;&lt;/P&gt;&lt;P&gt;An alternative to&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 21:37:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570860#M198942</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-13T21:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570877#M198946</link>
      <description>&lt;P&gt;I ran your search noted above and you're correct; the dedup is removing events with the same id found in the 2nd campaign.&amp;nbsp; I also should have specified in my original post as to why I'm using dedup in the first place.&amp;nbsp; There are duplicate events in each of the 2 campaigns that I'm trying to filter out, so I'm trying to figure out a way to dedup the events in each campaign without effecting other campaigns. It’s also likely additional campaigns will be added in the future to this search&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 01:02:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570877#M198946</guid>
      <dc:creator>surly78</dc:creator>
      <dc:date>2021-10-14T01:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570882#M198947</link>
      <description>&lt;P&gt;Normally you can use stats values(*) as * by X&lt;/P&gt;&lt;P&gt;to do deduping and X can be whatever grouping you need to get the correct info. values(*) as * will aggregate all fields to their same name, but you may then find multi-value fields that occur, that will depend on your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 00:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/570882#M198947</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-14T00:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting incorrect stats count in my search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/571038#M198981</link>
      <description>&lt;P&gt;This seems to almost work, however, I am able to find duplicates for some of the values in the eventtype field&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 17:58:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-incorrect-stats-count-in-my-search/m-p/571038#M198981</guid>
      <dc:creator>surly78</dc:creator>
      <dc:date>2021-10-14T17:58:30Z</dc:date>
    </item>
  </channel>
</rss>

