<?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: Impossible number of occurrences being returned in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/675248#M231073</link>
    <description>&lt;P&gt;(First off, please post sample data as text block, not screenshot.) &amp;nbsp;You should first convert JSON array Policy{} into multivalue of its JSON element before applying &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Mvexpand" target="_blank" rel="noopener"&gt;mvexpand&lt;/A&gt;. &amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&lt;/A&gt;&amp;nbsp;is very useful here. &amp;nbsp;In 9.0, Splunk added a new command &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fromjson" target="_blank" rel="noopener"&gt;fromjson&lt;/A&gt; which is more convenient for your case. &amp;nbsp;The following uses fromjson:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fromjson _raw
| mvexpand Policies
| fromjson Policies
| stats count by displayName result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your mock data gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;displayName&lt;/TD&gt;&lt;TD&gt;result&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Policy1&lt;/TD&gt;&lt;TD&gt;success&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Policy2&lt;/TD&gt;&lt;TD&gt;failure&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Policy3&lt;/TD&gt;&lt;TD&gt;notApplied&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is an emulation of your mock data you can play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "{\"SigninId\": \"some-id\",
\"Policies\": [
{
\"id\": \"1234\",
\"displayName\": \"Policy1\",
\"result\": \"success\"
},
{
\"id\": \"4353\",
\"displayName\": \"Policy2\",
\"result\": \"failure\"
},
{
\"id\": \"0093\",
\"displayName\": \"Policy3\",
\"result\": \"notApplied\"
}
]"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jan 2024 07:42:55 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-01-24T07:42:55Z</dc:date>
    <item>
      <title>Impossible number of occurrences being returned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/674751#M230970</link>
      <description>&lt;P&gt;Given the sample event below representing a user sign-in, I am trying to create a table that shows each combination of a 'policy' and 'result' and the number of occurrences for that combination. There are only three possible result values for any given policy (success, failure, or notApplied). In essence, I need this table to find out how which policies are not being used by looking at the number of times it was not applied.&lt;/P&gt;&lt;P&gt;i.e.:&lt;/P&gt;&lt;P&gt;Input:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ara_1-1705615939662.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29007iBB026D2BADF21273/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ara_1-1705615939662.png" alt="Ara_1-1705615939662.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Output:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="25px"&gt;&lt;STRONG&gt;displayName&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;STRONG&gt;result&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;Policy1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;success&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;Policy2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;failure&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;Policy3&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;notApplied&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the query I currently have is returning a sum that isn't possible because the sum is exceeding the number of sign-in events. What is wrong with my query?&lt;/P&gt;&lt;PRE&gt;&amp;lt;my_search&amp;gt; | stats count by Policies{}.displayName, ConditionalAccessPolicies{}.result&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 22:22:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/674751#M230970</guid>
      <dc:creator>Ara</dc:creator>
      <dc:date>2024-01-18T22:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Impossible number of occurrences being returned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/674754#M230972</link>
      <description>&lt;P&gt;Because each of those 2 fields has 3 values, you are effectively doing a 3x3 matrics stats, hence the results.&lt;/P&gt;&lt;P&gt;You will need to do something like this to join each of the policy bits of info together&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Policy=mvzip('Policies{}.displayName','Policies{}.result', "##")
| stats count by Policy&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and then finish it with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Policy=split(Policy, "##")
| eval displayName=mvindex(Policy, 0), result=mvindex(Policy, 1)
| table displayName result count&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Jan 2024 23:27:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/674754#M230972</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-01-18T23:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Impossible number of occurrences being returned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/675198#M231055</link>
      <description>&lt;P&gt;Thanks! This looks to be returning the desired info and format. Though I noticed some Policies were missing counts for certain results. The number of different values possible for 'displayName' is showing less than is actually present in the event log. I think this may be an issue with Splunk itself and not the query though.&amp;nbsp;&lt;BR /&gt;Would you happen to know if it's possible for the number of values to have a max or limit in Splunk?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 16:09:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/675198#M231055</guid>
      <dc:creator>Ara</dc:creator>
      <dc:date>2024-01-23T16:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Impossible number of occurrences being returned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/675248#M231073</link>
      <description>&lt;P&gt;(First off, please post sample data as text block, not screenshot.) &amp;nbsp;You should first convert JSON array Policy{} into multivalue of its JSON element before applying &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Mvexpand" target="_blank" rel="noopener"&gt;mvexpand&lt;/A&gt;. &amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&lt;/A&gt;&amp;nbsp;is very useful here. &amp;nbsp;In 9.0, Splunk added a new command &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fromjson" target="_blank" rel="noopener"&gt;fromjson&lt;/A&gt; which is more convenient for your case. &amp;nbsp;The following uses fromjson:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fromjson _raw
| mvexpand Policies
| fromjson Policies
| stats count by displayName result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your mock data gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;displayName&lt;/TD&gt;&lt;TD&gt;result&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Policy1&lt;/TD&gt;&lt;TD&gt;success&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Policy2&lt;/TD&gt;&lt;TD&gt;failure&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Policy3&lt;/TD&gt;&lt;TD&gt;notApplied&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is an emulation of your mock data you can play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "{\"SigninId\": \"some-id\",
\"Policies\": [
{
\"id\": \"1234\",
\"displayName\": \"Policy1\",
\"result\": \"success\"
},
{
\"id\": \"4353\",
\"displayName\": \"Policy2\",
\"result\": \"failure\"
},
{
\"id\": \"0093\",
\"displayName\": \"Policy3\",
\"result\": \"notApplied\"
}
]"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 07:42:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Impossible-number-of-occurrences-being-returned/m-p/675248#M231073</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-01-24T07:42:55Z</dc:date>
    </item>
  </channel>
</rss>

