<?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: Problem with count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72845#M18242</link>
    <description>&lt;P&gt;amazing! thanks for the fast answer.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Sep 2011 01:59:59 GMT</pubDate>
    <dc:creator>MBerikcurtis</dc:creator>
    <dc:date>2011-09-10T01:59:59Z</dc:date>
    <item>
      <title>Problem with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72843#M18240</link>
      <description>&lt;P&gt;I'm using the search to get a count of Windows Event Codes. If I remove &lt;STRONG&gt;stats count by EventCode&lt;/STRONG&gt;, I get the Event Description colum to populate. As soon as I include count, the colum goes blank.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="*Security" | stats count by EventCode  | table EventCode EventCodeDescription count | sort EventCode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2011 22:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72843#M18240</guid>
      <dc:creator>MBerikcurtis</dc:creator>
      <dc:date>2011-09-09T22:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72844#M18241</link>
      <description>&lt;P&gt;Well when you do &lt;CODE&gt;stats count by EventCode&lt;/CODE&gt;,  that says that you're only interested in seeing the number of events for each value of EventCode.   If there's always one EventCodeDescription value for each EventCode value (as indeed there is),  then here's how you would bring the other field along for the ride as well: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`stats count first(EventCodeDescription) by EventCode`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Stats has all kinds of amazing power, but the best thing about it is how transparent it is.  Once you learn that the &lt;CODE&gt;by foo, bar, baz&lt;/CODE&gt; clauses are just saying to analyze unique combinations of foo,bar and baz,  and once you learn the core set of statistical operations, you'll know what the result rows will look like just by reading the search. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Note that these other two pages are essential references as well.  If you use Splunk a lot they will quickly become your main reference pages in the search language: &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2011 23:30:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72844#M18241</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-09-09T23:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72845#M18242</link>
      <description>&lt;P&gt;amazing! thanks for the fast answer.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2011 01:59:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72845#M18242</guid>
      <dc:creator>MBerikcurtis</dc:creator>
      <dc:date>2011-09-10T01:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72846#M18243</link>
      <description>&lt;P&gt;I have implemented what you sudgested and am now using:&lt;/P&gt;

&lt;P&gt;sourcetype="*Security" &lt;BR /&gt;
| stats count first(EventCodeDescription) by EventCode &lt;BR /&gt;
| table EventCode EventCodeDescription count &lt;BR /&gt;
| sort EventCode&lt;/P&gt;

&lt;P&gt;but still nothing is shown in the EventCodeDescription column.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2011 18:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72846#M18243</guid>
      <dc:creator>MBerikcurtis</dc:creator>
      <dc:date>2011-09-12T18:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72847#M18244</link>
      <description>&lt;P&gt;I agree with Nick's assessment, but would recommend a slightly different solution.&lt;/P&gt;

&lt;P&gt;Rather than using Stats, if you are only interested in CALCULATING a count rather than DISPLAYING it, &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.3/SearchReference/Eventstats"&gt;Eventstats&lt;/A&gt; would be a better command to use. It keep the fields not specified in that particular pipe, yet will still calculate the count.&lt;/P&gt;

&lt;P&gt;I think you'll then want your query to look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="*Security" | eventstats count as "EventCount" by EventCode  | table EventCode EventCodeDescription EventCount | sort EventCode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2011 18:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72847#M18244</guid>
      <dc:creator>acdevlin</dc:creator>
      <dc:date>2011-09-12T18:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72848#M18245</link>
      <description>&lt;P&gt;I have implemented the solution posted by acdevlin and it works! I have added dedup so that the search reads&lt;/P&gt;

&lt;P&gt;sourcetype="*Security" | eventstats count as "EventCount" by EventCode  | table EventCode EventCodeDescription EventCount | sort EventCode | dedup EventCode&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2011 19:00:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-count/m-p/72848#M18245</guid>
      <dc:creator>MBerikcurtis</dc:creator>
      <dc:date>2011-09-12T19:00:09Z</dc:date>
    </item>
  </channel>
</rss>

