<?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: I'm trying to count the number of times a particular mvfield value occurs. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188874#M54428</link>
    <description>&lt;P&gt;Make sure you're actually extracting fields from those JSON events.&lt;/P&gt;</description>
    <pubDate>Sat, 16 May 2015 20:12:27 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2015-05-16T20:12:27Z</dc:date>
    <item>
      <title>I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188864#M54418</link>
      <description>&lt;P&gt;Event data set is as follows:&lt;BR /&gt;
{&lt;BR /&gt;
"actions":["CREATE","DELETE", "MODIFY"],&lt;BR /&gt;
"topic":"image",&lt;BR /&gt;
"event_time":"2015-05-14T00:39:52Z",&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;I have tried the following:&lt;BR /&gt;
&lt;CODE&gt;source_type=&amp;amp;lt;source&amp;amp;gt; | mvexpand actions | stats count(eval(actions=="CREATE")) as "Number of File Creations"&lt;/CODE&gt; &lt;BR /&gt;
but it doesn't work. What am I doing wrong? Any help would be much appreciated! &lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2015 20:48:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188864#M54418</guid>
      <dc:creator>snandaku</dc:creator>
      <dc:date>2015-05-14T20:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188865#M54419</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source_type=source | eval lenmatch=length("CREATE") | eval len=length(actions) | eval copy=actions| rex field=copy mode=sed "s/CREATE//g" | eval lencopy=len(copy) | eval numValues= (len - lencopy) / lenmatch
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 May 2015 21:39:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188865#M54419</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-14T21:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188866#M54420</link>
      <description>&lt;P&gt;If your &lt;CODE&gt;actions&lt;/CODE&gt; field is correctly extracted as an mv field then you can just search on it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=foo actions=CREATE | stats count as "Number of File Creations"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 May 2015 21:41:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188866#M54420</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-05-14T21:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188867#M54421</link>
      <description>&lt;P&gt;I suppose it could be condensed to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source_type=source | eval len=length(actions) | eval copy=actions| rex field=copy mode=sed "s/CREATE//g" | eval numValues= (len - len(copy)) / 6
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 May 2015 21:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188867#M54421</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-14T21:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188868#M54422</link>
      <description>&lt;P&gt;If &lt;CODE&gt;actions&lt;/CODE&gt; is a multivalue field as specified in the question then treating it as a huge string is not worth bonus karma points &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2015 21:46:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188868#M54422</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-05-14T21:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188869#M54423</link>
      <description>&lt;P&gt;Thanks Martin. Could you please explain what you mean by "if your actions field is correctly extracted as an mv field"? What's the correct way to extract an mv field?  &lt;/P&gt;

&lt;P&gt;While the above expression didn't work for me, I used something similar and successfully got the count of all events containing a CREATE action. This is what worked: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=foo CREATE | stats count as "Number of File Creations"&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;For some reason it didn't like the &lt;CODE&gt;actions=CREATE&lt;/CODE&gt;. Any idea why? &lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 08:44:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188869#M54423</guid>
      <dc:creator>snandaku</dc:creator>
      <dc:date>2015-05-15T08:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188870#M54424</link>
      <description>&lt;P&gt;Thanks for your reply woodcock! I tried this out but it didn't work for me. Perhaps what's missing is the &lt;CODE&gt;stats count&lt;/CODE&gt; portion? &lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 08:45:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188870#M54424</guid>
      <dc:creator>snandaku</dc:creator>
      <dc:date>2015-05-15T08:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188871#M54425</link>
      <description>&lt;P&gt;Searching for the term &lt;CODE&gt;CREATE&lt;/CODE&gt; will work &lt;EM&gt;as long as no other fields contain that term&lt;/EM&gt;.&lt;/P&gt;

&lt;P&gt;What happens when you run this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=foo | table _time action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you get a column &lt;CODE&gt;action&lt;/CODE&gt;? Does each row contain multiple values underneath each other or one long string?&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 09:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188871#M54425</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-05-15T09:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188872#M54426</link>
      <description>&lt;P&gt;He means this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=foo | table _time actions
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 May 2015 13:41:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188872#M54426</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-15T13:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188873#M54427</link>
      <description>&lt;P&gt;When I try &lt;CODE&gt;sourcetype=foo | table _time actions&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I get a column &lt;CODE&gt;_time&lt;/CODE&gt; populated with timestamps and an empty column &lt;CODE&gt;actions&lt;/CODE&gt; (just blank). &lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2015 19:54:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188873#M54427</guid>
      <dc:creator>snandaku</dc:creator>
      <dc:date>2015-05-16T19:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188874#M54428</link>
      <description>&lt;P&gt;Make sure you're actually extracting fields from those JSON events.&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2015 20:12:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188874#M54428</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-05-16T20:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: I'm trying to count the number of times a particular mvfield value occurs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188875#M54429</link>
      <description>&lt;P&gt;That was exactly the problem, thank you so much Martin! I used the interactive field extractor to extract the actions field, and it works now. &lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2015 22:21:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-m-trying-to-count-the-number-of-times-a-particular-mvfield/m-p/188875#M54429</guid>
      <dc:creator>snandaku</dc:creator>
      <dc:date>2015-05-16T22:21:32Z</dc:date>
    </item>
  </channel>
</rss>

