<?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: EventStats count Function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179336#M51623</link>
    <description>&lt;P&gt;In this case, tom's use of stats count and the first eval are just to setup a dummy event for testing. He's suggesting that you use the following rex and eval&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jan 2015 13:42:59 GMT</pubDate>
    <dc:creator>acharlieh</dc:creator>
    <dc:date>2015-01-08T13:42:59Z</dc:date>
    <item>
      <title>EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179330#M51617</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I'm looking to use the eventstats function to count the amount of times the word Error occurs in my event.&lt;/P&gt;

&lt;P&gt;Can anyone help as it doesn't appear to work ?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 12:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179330#M51617</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T12:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179331#M51618</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;if you want to count the amount of times a word exists in a single event, i do not think eventstats can do it. You can use the stats commands for example to tell you how much events out of all your events contain the word "error".&lt;/P&gt;

&lt;P&gt;But you can get what you want with a little combination of regex and eval. In the following run everywhere example, i counted the word hello in the field "text":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval text= "hello world hello my friends and so on hello." | rex field=text max_match=0 "(?&amp;lt;list&amp;gt;hello)" | eval amount=mvcount(list)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For your usecase you can change the field of the rex command to "_raw" (wich is also the default) and it should work.&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:21:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179331#M51618</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-01-08T13:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179332#M51619</link>
      <description>&lt;P&gt;Hi Tom,&lt;BR /&gt;
We cannot use the stats as we want to table it later on, so we would need to use some sort of other combination.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:26:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179332#M51619</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T13:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179333#M51620</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;       ...  "error"| eventstats count  as number_events_error | table number_events_error
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:28:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179333#M51620</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-01-08T13:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179334#M51621</link>
      <description>&lt;P&gt;Hi fdi01,&lt;BR /&gt;
We've tried this but it's not really working as we do other stuff above.  Any other ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:36:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179334#M51621</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-01-08T13:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179335#M51622</link>
      <description>&lt;P&gt;Can you maybe post some sampledata and your search string? Because i do currently not understand why the solution should not be applicable.&lt;/P&gt;

&lt;P&gt;If you mean because i used the stats command first, this is just to let my example run everywhere. You can also do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd | rex  max_match=0 "(?&amp;lt;list&amp;gt;size)" | eval amount=mvcount(list) | table _raw amount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which counts the word "size" per event in your splunkd logs.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:39:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179335#M51622</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-01-08T13:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179336#M51623</link>
      <description>&lt;P&gt;In this case, tom's use of stats count and the first eval are just to setup a dummy event for testing. He's suggesting that you use the following rex and eval&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179336#M51623</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-01-08T13:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179337#M51624</link>
      <description>&lt;P&gt;Correct, i edited it while you were writing this xD&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:45:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179337#M51624</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-01-08T13:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: EventStats count Function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179338#M51625</link>
      <description>&lt;P&gt;Tom's suggestion doesn't use &lt;CODE&gt;stats&lt;/CODE&gt;. Starting a search with &lt;CODE&gt;| stats count&lt;/CODE&gt; is just a way to create a sample without any real data. Replace Tom's &lt;CODE&gt;| stats count&lt;/CODE&gt; with your actual search string, and remove his &lt;CODE&gt;eval text=&lt;/CODE&gt; phrase, since your data already exists. The important part in his answer is the &lt;CODE&gt;rex&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your search... | rex field=_raw max_match=0 "(?&amp;lt;list&amp;gt;hello)" | eval amount=mvcount(list)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EventStats-count-Function/m-p/179338#M51625</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-01-08T13:51:37Z</dc:date>
    </item>
  </channel>
</rss>

