<?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 search the count of how many times a keyword appears, not the event count? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177122#M50891</link>
    <description>&lt;P&gt;Hi Martin:&lt;BR /&gt;
    I use the search command you mentioned above, but the result only can see the log event, can't see anything on statistics. &lt;BR /&gt;
Maybe I must count _raw to a field ?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jul 2015 09:55:50 GMT</pubDate>
    <dc:creator>PeterChu</dc:creator>
    <dc:date>2015-07-02T09:55:50Z</dc:date>
    <item>
      <title>How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177116#M50885</link>
      <description>&lt;P&gt;Hi All:&lt;/P&gt;

&lt;P&gt;How do I write a search to find the count of how many times a keyword appears, not the event count? &lt;BR /&gt;
As far as I know, &lt;CODE&gt;|stats count&lt;/CODE&gt; just searches the event count.&lt;/P&gt;

&lt;P&gt;ex:&lt;BR /&gt;
myLog="Helen is a good girl. Helen is beautiful."&lt;/P&gt;

&lt;P&gt;I want to know "Helen" occurs with a count of 2.&lt;/P&gt;

&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 02:59:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177116#M50885</guid>
      <dc:creator>PeterChu</dc:creator>
      <dc:date>2015-06-26T02:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177117#M50886</link>
      <description>&lt;P&gt;What in this?&lt;/P&gt;

&lt;P&gt;・・・・|eval list=split(_raw," Helen is")|eval  count=mvcount(list)-1&lt;/P&gt;

&lt;P&gt;However, also counts "XXXHelen is" and "YYYHelen is".&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 06:23:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177117#M50886</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2015-06-26T06:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177118#M50887</link>
      <description>&lt;P&gt;Hi PeterChu,&lt;/P&gt;

&lt;P&gt;I don't know if there is a better way to do this; but have a look at this run everywhere example to get an idea how it could be done:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 |  eval myLog="Helen is a good girl. Helen is beautiful." 
| rex field=myLog "(?&amp;lt;word&amp;gt;\S+)" max_match=0 
| mvexpand word 
| search word="Helen"
| stats count  
| eval Count=if(count=="2", "Twice", count) 
| table word, Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first line is only to &lt;CODE&gt;create&lt;/CODE&gt; the event, then I use &lt;CODE&gt;rex&lt;/CODE&gt; to get the single words and expand it into single value field called &lt;CODE&gt;word&lt;/CODE&gt;, search for all &lt;CODE&gt;word="Helen"&lt;/CODE&gt;, count them and display the result.&lt;/P&gt;

&lt;P&gt;Hope that helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 07:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177118#M50887</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-26T07:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177119#M50888</link>
      <description>&lt;P&gt;Alternate solution avoiding &lt;CODE&gt;mvexpand&lt;/CODE&gt; so it could be applied to many events at once:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as text | eval text = "Helen is a good girl. Helen is beautiful."
| eval tokens = lower(replace(text, "\W+", " "))
| makemv tokens
| eval matches = mvfilter(match(tokens, "^helen$"))
| eval count = mvcount(matches)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Replace the first line with your search returning a field &lt;CODE&gt;text&lt;/CODE&gt; and it'll produce a &lt;CODE&gt;count&lt;/CODE&gt; for each event.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 09:12:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177119#M50888</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-06-26T09:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177120#M50889</link>
      <description>&lt;P&gt;Hi Martin:&lt;BR /&gt;
    Thanks your help, but I still don't know how to apply my search language to replace text.&lt;BR /&gt;
ex:my search is " sourcetype=test " and the result will be "Helen is a good girl. Helen is beautiful."&lt;BR /&gt;
Can I use the search cmd to replace the log. Maybe it is likely a subsearch?&lt;/P&gt;

&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2015 09:35:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177120#M50889</guid>
      <dc:creator>PeterChu</dc:creator>
      <dc:date>2015-07-02T09:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177121#M50890</link>
      <description>&lt;P&gt;If that's the raw text returned then this should do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=test
| eval tokens = lower(replace(_raw, "\W+", " "))
| makemv tokens
| makemv tokens
| eval matches = mvfilter(match(tokens, "^helen$"))
| eval count = mvcount(matches)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2015 09:37:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177121#M50890</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-07-02T09:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177122#M50891</link>
      <description>&lt;P&gt;Hi Martin:&lt;BR /&gt;
    I use the search command you mentioned above, but the result only can see the log event, can't see anything on statistics. &lt;BR /&gt;
Maybe I must count _raw to a field ?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2015 09:55:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177122#M50891</guid>
      <dc:creator>PeterChu</dc:creator>
      <dc:date>2015-07-02T09:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177123#M50892</link>
      <description>&lt;P&gt;You should see a field &lt;CODE&gt;count&lt;/CODE&gt; in the left bar. Alternatively, add &lt;CODE&gt;| table _raw count&lt;/CODE&gt; to the end to make it show in the Statistics tab.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2015 10:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177123#M50892</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-07-02T10:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search the count of how many times a keyword appears, not the event count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177124#M50893</link>
      <description>&lt;P&gt;Nice , if I add "| table _raw count " I can get count=2&lt;BR /&gt;
Final my search command look like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=test
 | eval tokens = lower(replace(_raw, "\W+", " "))
 | makemv tokens
 | eval matches = mvfilter(match(tokens, "^helen$"))
 | eval count = mvcount(matches)
 | table _raw count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I deeply appreciated your kindness .&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2015 10:13:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-search-the-count-of-how-many-times-a-keyword-appears/m-p/177124#M50893</guid>
      <dc:creator>PeterChu</dc:creator>
      <dc:date>2015-07-02T10:13:10Z</dc:date>
    </item>
  </channel>
</rss>

