<?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 to &amp;quot;group by&amp;quot; in JSON in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460332#M129877</link>
    <description>&lt;P&gt;@anooshac&lt;/P&gt;

&lt;P&gt;If you try my  &lt;STRONG&gt;Sample Search:&lt;/STRONG&gt; then it's giving you same result.  Can you please share your sample search if possible?  Are you running this search on single event or multiple event. If multiple then is it possible to have same NAME in multiple event?&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2020 05:40:41 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2020-02-04T05:40:41Z</dc:date>
    <item>
      <title>How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460322#M129867</link>
      <description>&lt;P&gt;Hi all I have a json file like this,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
 "NUM" : "#1",
 "TIME" : "1/27/2020  12:49:13",
 "STATUS" : "PASS",
 "DURATION" : "144",
"COMPONENTS":
[
  {
    "NAME" : "a",
    "ACCEPTEDCHANGESETS":
       [
"abc",  
"xyz",  
"efg",
       ],
    "NAME" : "a",
    "REJECTEDCHANGESETS":
      [
"pqr",
      ],
    "NAME" : "b",
    "ACCEPTEDCHANGESETS":
       [
"uop",
"ghf",
"yui"
]
}
]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I find the count of "ACCEPTEDCHANGESETS" by "NAME"?&lt;BR /&gt;
Previously I had asked the same type of question and I tried referring that answer but I am not able to get a proper answer. &lt;BR /&gt;
Can anyone please help me with this!!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 09:44:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460322#M129867</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-03T09:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460323#M129868</link>
      <description>&lt;P&gt;@anooshac &lt;/P&gt;

&lt;P&gt;I think your provided JSON is invalid. Validated on &lt;A href="https://jsonlint.com/"&gt;https://jsonlint.com/&lt;/A&gt;.  For  quick help can you please share &lt;CODE&gt;_raw&lt;/CODE&gt; event in code sample block ( see 101010 button) ?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 09:49:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460323#M129868</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-03T09:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460324#M129869</link>
      <description>&lt;P&gt;Hi @kamlesh_vaghela , sorry i missed out some brackets in that file.&lt;BR /&gt;
{&lt;BR /&gt;
    "NUM": "#1",&lt;BR /&gt;
    "TIME": "1/27/2020 12:49:13",&lt;BR /&gt;
    "STATUS": "PASS",&lt;BR /&gt;
    "DURATION": "144",&lt;BR /&gt;
    "COMPONENTS": [{&lt;BR /&gt;
            "NAME": "a",&lt;BR /&gt;
            "ACCEPTEDCHANGESETS": [&lt;BR /&gt;
                "abc",&lt;BR /&gt;
                "xyz",&lt;BR /&gt;
                "efg"&lt;BR /&gt;
            ],&lt;BR /&gt;
            "REJECTEDCHANGESETS": [&lt;BR /&gt;
                "pqr"&lt;BR /&gt;
            ]&lt;BR /&gt;
        },&lt;BR /&gt;
        {&lt;BR /&gt;
            "NAME": "b",&lt;BR /&gt;
            "ACCEPTEDCHANGESETS": [&lt;BR /&gt;
                "uop",&lt;BR /&gt;
                "ghf",&lt;BR /&gt;
                "yui"&lt;BR /&gt;
                  ]&lt;BR /&gt;
        }&lt;BR /&gt;
    ]&lt;BR /&gt;
}&lt;BR /&gt;
This is valid json file. How can i get those results?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 11:30:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460324#M129869</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-03T11:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460325#M129870</link>
      <description>&lt;P&gt;If you have KV_MODE = JSON and your json is valid, you should have a field called "COMPONENTS{}.NAME" in your fields list. Then you can do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex  sourcetype=yoursourcetype| stats count by COMPONENTS{}.NAME
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 11:47:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460325#M129870</guid>
      <dc:creator>jbrocks</dc:creator>
      <dc:date>2020-02-03T11:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460326#M129871</link>
      <description>&lt;P&gt;@anooshac&lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | spath path=COMPONENTS{} output=data | mvexpand data | eval _raw=data| extract
| stats count(ACCEPTEDCHANGESETS{}) as Count by NAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"NUM\": \"#1\",\"TIME\": \"1/27/2020 12:49:13\",\"STATUS\": \"PASS\",\"DURATION\": \"144\",\"COMPONENTS\": [{\"NAME\": \"a\",\"ACCEPTEDCHANGESETS\": [\"abc\",\"xyz\",\"efg\"],\"REJECTEDCHANGESETS\": [\"pqr\"]},{\"NAME\": \"b\",\"ACCEPTEDCHANGESETS\": [\"uop\",\"ghf\",\"yui\"]}]}" 
| extract 
| spath path=COMPONENTS{} output=data | mvexpand data | eval _raw=data| extract
| stats count(ACCEPTEDCHANGESETS{}) as Count by NAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 12:48:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460326#M129871</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-03T12:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460327#M129872</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;|makeresults
|eval _raw="{\"NUM\":\"#1\",\"TIME\":\"1/27/2020 12:49:13\",\"STATUS\":\"PASS\",\"DURATION\":\"144\",\"COMPONENTS\":[{\"NAME\":\"a\",\"ACCEPTEDCHANGESETS\":[\"abc\",\"xyz\",\"efg\"],\"REJECTEDCHANGESETS\":[\"pqr\"]},{\"NAME\":\"b\",\"ACCEPTEDCHANGESETS\":[\"uop\",\"ghf\",\"yui\"]}]}"
| spath path=COMPONENTS{} output=components
| stats count by components
| spath input=components
| rename *{} as *
| table NAME ACCEPTEDCHANGESETS REJECTEDCHANGESETS
| eventstats count(ACCEPTEDCHANGESETS) by NAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, folks.&lt;BR /&gt;
how about this?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 13:09:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460327#M129872</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-03T13:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460328#M129873</link>
      <description>&lt;P&gt;Hi @kamlesh_vaghela , thanks a lot for the answer,i tried this and i'm getting overall count of the ACCEPTEDCHANGESETS. For every NAME i'm getting the count as same. What will be the problem here?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 03:41:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460328#M129873</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-04T03:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460329#M129874</link>
      <description>&lt;P&gt;@anooshac &lt;/P&gt;

&lt;P&gt;With &lt;CODE&gt;NAME&lt;/CODE&gt; = &lt;CODE&gt;a&lt;/CODE&gt; associated &lt;CODE&gt;ACCEPTEDCHANGESETS&lt;/CODE&gt; are &lt;CODE&gt;abc&lt;/CODE&gt;, &lt;CODE&gt;xyz&lt;/CODE&gt; and &lt;CODE&gt;efg' that's Y it's showing&lt;/CODE&gt;3&lt;CODE&gt;, and for&lt;/CODE&gt;NAME&lt;CODE&gt;=&lt;/CODE&gt;b`  also. Can you please share what is your expected output from your shared sample event?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 04:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460329#M129874</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-04T04:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460330#M129875</link>
      <description>&lt;P&gt;Hi @jbrocks , thanks a lot for the answer, i'm getting overall count of ACCEPTEDCHANGESETS for each NAME. What is problem here?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 04:20:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460330#M129875</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-04T04:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460331#M129876</link>
      <description>&lt;P&gt;Hello @kamlesh_vaghela , i am not able to put a screenshot here so i'll be sharing the output table which is expected.&lt;/P&gt;

&lt;P&gt;NAME  count(ACCEPTEDCHANGESETS)&lt;BR /&gt;
a                                  3&lt;BR /&gt;
b                                  3&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 05:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460331#M129876</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-04T05:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460332#M129877</link>
      <description>&lt;P&gt;@anooshac&lt;/P&gt;

&lt;P&gt;If you try my  &lt;STRONG&gt;Sample Search:&lt;/STRONG&gt; then it's giving you same result.  Can you please share your sample search if possible?  Are you running this search on single event or multiple event. If multiple then is it possible to have same NAME in multiple event?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 05:40:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460332#M129877</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-04T05:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460333#M129878</link>
      <description>&lt;P&gt;hi @kamlesh_vaghela , i'm really sorry there were some mistakes in data that's why i was getting wrong answer. Thanks a lot for the help. My problem is resolved now!!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 05:59:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460333#M129878</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-04T05:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to "group by" in JSON</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460334#M129879</link>
      <description>&lt;P&gt;Hi, @to4kawa , thanks a lot for the answer, i'm getting the results properly by your query as well as @kamlesh_vaghela s query. Thank you so much for the help!!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 06:01:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-quot-group-by-quot-in-JSON/m-p/460334#M129879</guid>
      <dc:creator>anooshac</dc:creator>
      <dc:date>2020-02-04T06:01:29Z</dc:date>
    </item>
  </channel>
</rss>

