<?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 Extract values from nested JSON with same name fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547269#M91097</link>
    <description>&lt;P&gt;Hi people,&lt;/P&gt;&lt;P&gt;First of all I'm still newbie with Splunk, but I'm trying to extract fields from a JSON sent by the Admin Report API from Google and I'm having trouble.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample JSON:&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;{"kind": "admin#reports#activity", "id": {"time": "2021-04-08T19:21:27.595Z", "uniqueQualifier": "-0987654321", "applicationName": "chat", "customerId": "C0123456A"}, "etag": "\"giant/string\"", "actor": {"callerType": "USER", "email": "mail@acme.com", "profileId": "1234567890"}, "events": [{"type": "user_action", "name": "message_posted", "parameters": [{"name": "room_id", "value": "ABCDEFGH"}, {"name": "timestamp_ms", "value": "1617909687595199"}, {"name": "actor", "value": "mail@acme.com"}, {"name": "message_id", "value": "ZYXWVUTS"}, {"name": "retention_state", "value": "PERMANENT"}, {"name": "room_name", "value": ""}]}]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is to create some counts/dashboards with fields from "parameters" along with others, but they all have the same name in this nest.&lt;/P&gt;&lt;P&gt;This is what I came with, but all the "name" and "value" strings are grouped:&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;| spath path=events{}. output=events
| mvexpand events
| rename events as _raw
| extract
| rename parameters{}.name as pname, parameters{}.value as pvalue
| table _time pname pvalue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I don't know if this can be done with the search parameters only (sorry If I'm talking nonsense).&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 21:13:42 GMT</pubDate>
    <dc:creator>bsdd04</dc:creator>
    <dc:date>2021-04-08T21:13:42Z</dc:date>
    <item>
      <title>Extract values from nested JSON with same name fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547269#M91097</link>
      <description>&lt;P&gt;Hi people,&lt;/P&gt;&lt;P&gt;First of all I'm still newbie with Splunk, but I'm trying to extract fields from a JSON sent by the Admin Report API from Google and I'm having trouble.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample JSON:&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;{"kind": "admin#reports#activity", "id": {"time": "2021-04-08T19:21:27.595Z", "uniqueQualifier": "-0987654321", "applicationName": "chat", "customerId": "C0123456A"}, "etag": "\"giant/string\"", "actor": {"callerType": "USER", "email": "mail@acme.com", "profileId": "1234567890"}, "events": [{"type": "user_action", "name": "message_posted", "parameters": [{"name": "room_id", "value": "ABCDEFGH"}, {"name": "timestamp_ms", "value": "1617909687595199"}, {"name": "actor", "value": "mail@acme.com"}, {"name": "message_id", "value": "ZYXWVUTS"}, {"name": "retention_state", "value": "PERMANENT"}, {"name": "room_name", "value": ""}]}]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is to create some counts/dashboards with fields from "parameters" along with others, but they all have the same name in this nest.&lt;/P&gt;&lt;P&gt;This is what I came with, but all the "name" and "value" strings are grouped:&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;| spath path=events{}. output=events
| mvexpand events
| rename events as _raw
| extract
| rename parameters{}.name as pname, parameters{}.value as pvalue
| table _time pname pvalue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I don't know if this can be done with the search parameters only (sorry If I'm talking nonsense).&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 21:13:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547269#M91097</guid>
      <dc:creator>bsdd04</dc:creator>
      <dc:date>2021-04-08T21:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract values from nested JSON with same name fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547271#M91098</link>
      <description>&lt;P&gt;Perhaps this will help as far as extracting fields and values&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{\"kind\": \"admin#reports#activity\", \"id\": {\"time\": \"2021-04-08T19:21:27.595Z\", \"uniqueQualifier\": \"-0987654321\", \"applicationName\": \"chat\", \"customerId\": \"C0123456A\"}, \"etag\": \"\\\"giant/string\\\"\", \"actor\": {\"callerType\": \"USER\", \"email\": \"mail@acme.com\", \"profileId\": \"1234567890\"}, \"events\": [{\"type\": \"user_action\", \"name\": \"message_posted\", \"parameters\": [{\"name\": \"room_id\", \"value\": \"ABCDEFGH\"}, {\"name\": \"timestamp_ms\", \"value\": \"1617909687595199\"}, {\"name\": \"actor\", \"value\": \"mail@acme.com\"}, {\"name\": \"message_id\", \"value\": \"ZYXWVUTS\"}, {\"name\": \"retention_state\", \"value\": \"PERMANENT\"}, {\"name\": \"room_name\", \"value\": \"\"}]}]}"
| spath path=events{}. output=events
| spath input=events path=parameters{} output=parameters
| mvexpand parameters
| spath input=parameters
| eval {name}=value
| stats values(*) as * by events
| fields - parameters name value events&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 21:31:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547271#M91098</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-08T21:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract values from nested JSON with same name fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547428#M91112</link>
      <description>&lt;P&gt;That's perfect! I still need to grasp my understanting of mv and spath commands though...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 18:12:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-values-from-nested-JSON-with-same-name-fields/m-p/547428#M91112</guid>
      <dc:creator>bsdd04</dc:creator>
      <dc:date>2021-04-09T18:12:18Z</dc:date>
    </item>
  </channel>
</rss>

