<?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: Using stats count by to query the number of policies in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643533#M222922</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/256806"&gt;@soulmaker24&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The&amp;nbsp;auth.policies{} field is array, so in this case, results in a multi value field.&amp;nbsp; For stats command to group by that field it needs to be a single value which can be done use the mvexpand command, like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;type="request"
| mvexpand auth.policies{}
| stats count BY auth.policies{}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Also, for next time, showing the event is really useful, it is more useful if you add it with syntax highlighting turned off - basically the _raw event.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2023 01:56:06 GMT</pubDate>
    <dc:creator>yeahnah</dc:creator>
    <dc:date>2023-05-17T01:56:06Z</dc:date>
    <item>
      <title>Using stats count by to query the number of policies?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643517#M222915</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to figured out how I could list a report by showing the total number of policies in my query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the sample Event below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{ [-]
  auth : { [-]
    display_name: sample-name
    policies: [ [-]
      default
      admin
    ]
  }
  type: request
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, when I am using a search query below, I got a result of number of display_name.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;type="request" | stats count by auth.display_name&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;However,&amp;nbsp; what I need is to show me the result count of the policies which in this case the default and admin. I am using the query below but it does not give me any result.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;type="request" | stats count by auth.policies&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Would someone be able to guide me what is the correct syntax to use to get the result I want?&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 13:45:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643517#M222915</guid>
      <dc:creator>soulmaker24</dc:creator>
      <dc:date>2023-05-17T13:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats count by to query the number of policies</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643533#M222922</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/256806"&gt;@soulmaker24&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The&amp;nbsp;auth.policies{} field is array, so in this case, results in a multi value field.&amp;nbsp; For stats command to group by that field it needs to be a single value which can be done use the mvexpand command, like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;type="request"
| mvexpand auth.policies{}
| stats count BY auth.policies{}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Also, for next time, showing the event is really useful, it is more useful if you add it with syntax highlighting turned off - basically the _raw event.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 01:56:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643533#M222922</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-05-17T01:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats count by to query the number of policies</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643536#M222923</link>
      <description>&lt;P&gt;Thank you, I did realise I am missing the {} at the end. Appreciate your help on this one.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 01:20:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-count-by-to-query-the-number-of-policies/m-p/643536#M222923</guid>
      <dc:creator>soulmaker24</dc:creator>
      <dc:date>2023-05-17T01:20:43Z</dc:date>
    </item>
  </channel>
</rss>

