<?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: Pulling new fields out of nested JSON data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548110#M155454</link>
    <description>&lt;P&gt;Oh actually, should there be a command towards the end to "undo" the mvexpand? It looks like I still have separate events for each object..&lt;/P&gt;</description>
    <pubDate>Thu, 15 Apr 2021 22:32:18 GMT</pubDate>
    <dc:creator>joemiller</dc:creator>
    <dc:date>2021-04-15T22:32:18Z</dc:date>
    <item>
      <title>Pulling new fields out of nested JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548077#M155435</link>
      <description>&lt;P&gt;Looking at the example field below (part of a JSON event), I'm trying to figure out how at search time to pair up the corresponding values of properties.appliedConditionalAccessPolicies{}.displayName fields and&amp;nbsp;properties.appliedConditionalAccessPolicies{}.result fields into new field/value pairs for each event (note that there can be multiple pairs per event - two in this example). So for example, in the event below, I would want to add two new field/value pairs to the event:&lt;/P&gt;&lt;P&gt;Require_Duo_MFA=success&lt;BR /&gt;Scammer_Blocked_IP_Addresses=notApplied&lt;/P&gt;&lt;P&gt;Any ideas how to approach that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;appliedConditionalAccessPolicies: [ [-]
       { [-]
         conditionsNotSatisfied: 0
         conditionsSatisfied: 3
         displayName: Require Duo MFA
         enforcedGrantControls: [ [+]
         ]
         enforcedSessionControls: [ [+]
         ]
         id: 11111111-1111-1111-1111-111111111111
         result: success
       }
       { [-]
         conditionsNotSatisfied: 8
         conditionsSatisfied: 3
         displayName: Scammer Blocked IP Addresses
         enforcedGrantControls: [ [+]
         ]
         enforcedSessionControls: [ [+]
         ]
         id: 22222222-2222-2222-2222-222222222222
         result: notApplied
       }
     ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 19:35:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548077#M155435</guid>
      <dc:creator>joemiller</dc:creator>
      <dc:date>2021-04-15T19:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling new fields out of nested JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548091#M155443</link>
      <description>&lt;P&gt;First, extract (spath) the array elements as&amp;nbsp;&lt;SPAN&gt;properties.appliedConditionalAccessPolicies objects, then mvexpand that to give you separate events for each object. Then extract (spath again) the two fields you want. Then replace the spaces in displayName with underscores. The create a new field based on the contents of displayName. Something along these lines.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=properties.appliedConditionalAccessPolicies output=appliedConditionalAccessPolicies 
| mvexpand appliedConditionalAccessPolicies 
| spath input=appliedConditionalAccessPolicies path=displayName output=displayName
| spath input=appliedConditionalAccessPolicies path=result output=result
| eval displayName=replace(displayName," ","_")
| eval {displayName}=result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 20:28:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548091#M155443</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-15T20:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling new fields out of nested JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548107#M155452</link>
      <description>&lt;P&gt;Thank you very much! This is exactly what I was looking for. Worked perfectly. I did have to add a pair of curly brackets to the end of the path parameter in your first line, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=properties.appliedConditionalAccessPolicies{} output=appliedConditionalAccessPolicies &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Anyways, I really appreciate the quick answer and the detailed explanation! Marking this as the answer.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 21:51:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548107#M155452</guid>
      <dc:creator>joemiller</dc:creator>
      <dc:date>2021-04-15T21:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling new fields out of nested JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548110#M155454</link>
      <description>&lt;P&gt;Oh actually, should there be a command towards the end to "undo" the mvexpand? It looks like I still have separate events for each object..&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 22:32:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548110#M155454</guid>
      <dc:creator>joemiller</dc:creator>
      <dc:date>2021-04-15T22:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling new fields out of nested JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548113#M155457</link>
      <description>&lt;P&gt;If you want to collect all the event together at the end, do something like this: before the mvexpand tag each event with a row number&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count as row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Then at the end, gather them back&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats values(*) as * by row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 23:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548113#M155457</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-15T23:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling new fields out of nested JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548116#M155459</link>
      <description>&lt;P&gt;Great, thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 23:28:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pulling-new-fields-out-of-nested-JSON-data/m-p/548116#M155459</guid>
      <dc:creator>joemiller</dc:creator>
      <dc:date>2021-04-15T23:28:58Z</dc:date>
    </item>
  </channel>
</rss>

