<?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: Need to get the count of number of times a field is used in a request in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224229#M188272</link>
    <description>&lt;P&gt;Sundareshr, Thank you for that. Can you please explain the rex and mvcount used above.&lt;/P&gt;

&lt;P&gt;I also have one more doubt and will be more pleased if you clear that as well. &lt;BR /&gt;
Take the Event1 from the above example. If I am filtering that alone and viewing it in splunk. Then the interesting fields has a field "name". My understanding was that it should display all the name's mentioned in the event. But it only displays the first name. for the above example it only displays Raja. &lt;/P&gt;

&lt;P&gt;Is my understanding wrong?&lt;/P&gt;</description>
    <pubDate>Sat, 13 Aug 2016 04:02:15 GMT</pubDate>
    <dc:creator>ndayanat</dc:creator>
    <dc:date>2016-08-13T04:02:15Z</dc:date>
    <item>
      <title>Need to get the count of number of times a field is used in a request</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224227#M188270</link>
      <description>&lt;P&gt;Need to get the count of number of times a field is used in a request&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    Ex log:
    (This is a XML log, giving details from the middle and not the entire log)

Event 1: 
&amp;lt;students&amp;gt;
&amp;lt;student name="Raja" age="13" class="6" /&amp;gt;
&amp;lt;student name="Nar" age="15" class'"8" /&amp;gt;
&amp;lt;student name="Mag" age="16" class="7" /&amp;gt;
&amp;lt;/students&amp;gt;

Event 2:
&amp;lt;students&amp;gt;
&amp;lt;student name="Rex" age="13" class="6" /&amp;gt;
&amp;lt;student name="Nanny" age="15" class'"8" /&amp;gt;
&amp;lt;/students&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to check how many times the field "Name" is used. As you can see the count varies for each event. How do I get that count?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2016 01:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224227#M188270</guid>
      <dc:creator>ndayanat</dc:creator>
      <dc:date>2016-08-13T01:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get the count of number of times a field is used in a request</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224228#M188271</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "(?&amp;lt;name&amp;gt;name)" | eval occurrences=mvcount(name) | table name occurrences
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2016 02:30:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224228#M188271</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-13T02:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get the count of number of times a field is used in a request</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224229#M188272</link>
      <description>&lt;P&gt;Sundareshr, Thank you for that. Can you please explain the rex and mvcount used above.&lt;/P&gt;

&lt;P&gt;I also have one more doubt and will be more pleased if you clear that as well. &lt;BR /&gt;
Take the Event1 from the above example. If I am filtering that alone and viewing it in splunk. Then the interesting fields has a field "name". My understanding was that it should display all the name's mentioned in the event. But it only displays the first name. for the above example it only displays Raja. &lt;/P&gt;

&lt;P&gt;Is my understanding wrong?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2016 04:02:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224229#M188272</guid>
      <dc:creator>ndayanat</dc:creator>
      <dc:date>2016-08-13T04:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get the count of number of times a field is used in a request</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224230#M188273</link>
      <description>&lt;P&gt;&lt;CODE&gt;rex&lt;/CODE&gt; is SPL's regular expression command. I used that to extract all occurrences of the word "name" in an event. I used &lt;CODE&gt;max_match&lt;/CODE&gt; switch to create a multi-value field with as many matches as &lt;CODE&gt;rex&lt;/CODE&gt; finds&lt;/P&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/sX8wD1/1"&gt;https://regex101.com/r/sX8wD1/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;mvcount&lt;/CODE&gt; is for counting values within multi-value fields. Here's more on that&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.2/Search/Parsemultivaluefields#Evaluate_multivalue_fields"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.2/Search/Parsemultivaluefields#Evaluate_multivalue_fields&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;By default, field extraction will extract one occurrence. To get more than one, you either use &lt;CODE&gt;rex&lt;/CODE&gt; with &lt;CODE&gt;max_match&lt;/CODE&gt; or add &lt;CODE&gt;MV_ADD&lt;/CODE&gt; in your transforms extraction. More on that here&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.2/Admin/Transformsconf"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.2/Admin/Transformsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2016 12:07:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224230#M188273</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-13T12:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get the count of number of times a field is used in a request</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224231#M188274</link>
      <description>&lt;P&gt;This was really helpful. But i have one more doubt here, we have used mvcount to get the count of that field, in case if I want to display the values for that field, what function do we use? &lt;/P&gt;

&lt;P&gt;Ex: In event 1, there is a field called name, and if I check the values it only displays the first name of each event. ie Raja(from event 1) and Rex(from event 2). However, i want to display all the names in this field name. &lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 21:02:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-get-the-count-of-number-of-times-a-field-is-used-in-a/m-p/224231#M188274</guid>
      <dc:creator>ndayanat</dc:creator>
      <dc:date>2017-03-27T21:02:55Z</dc:date>
    </item>
  </channel>
</rss>

