<?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: Spath for Nested Json in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609778#M212040</link>
    <description>&lt;LI-CODE lang="markup"&gt;| spath output=Recipients path=OperationProperties{}.Value{}.Recipients{}&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 17 Aug 2022 07:26:41 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-08-17T07:26:41Z</dc:date>
    <item>
      <title>Help with Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609767#M212032</link>
      <description>&lt;P&gt;Hi All, Can someone pls assist me in extracting the different &lt;STRONG&gt;Recipients&lt;/STRONG&gt; out this nested Json ?&amp;nbsp; This is from O365 logs.&amp;nbsp; &amp;nbsp; I have followed&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/Extract-nested-json/m-p/496227#M84641" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Getting-Data-In/Extract-nested-json/m-p/496227#M84641&lt;/A&gt;&amp;nbsp; but unable to get it work against my data.&lt;BR /&gt;&lt;BR /&gt;Raw events:&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;OperationProperties: [ [-]
     { [+]
     }
     { [-]
       Name: RuleId
       Value: 3623734839020093442
     }
     { [-]
       Name: RuleName
       Value: ForwardingRule01
      } 
     { [+]
     }
     { [-]
       Name: RuleActions
       Value: [{"ActionType":"Forward","Recipients":["WADRIANL@domain.com","WENDYLIM@domain.com", Forward Flags":"None"}]
     }
   ]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Note, Splunk is able to extract the field &lt;STRONG&gt;OperationProperties{}.Value&lt;/STRONG&gt; as shown below but how to further extract the list of Recipients within it ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_1-1660719516964.png" style="width: 546px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21066iFCD2D5886B921896/image-dimensions/546x366?v=v2" width="546" height="366" role="button" title="neerajs_81_1-1660719516964.png" alt="neerajs_81_1-1660719516964.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I am trying below searches but no luck&amp;nbsp;&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 output=Recipients path=OperationProperties{}.Value.Recipients

OR

| spath output=Recipients path=OperationProperties{}.Value{}.Recipients{}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;i am +ve i am making a mistake in the&amp;nbsp;&lt;STRONG&gt;path&lt;/STRONG&gt; variable above.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 14:42:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609767#M212032</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-17T14:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609777#M212039</link>
      <description>&lt;P&gt;Use single quote around field names containing special characters, e.g.,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath output=Recipients path='OperationProperties{}.Value.Recipients'&lt;/LI-CODE&gt;&lt;P&gt;Recent SPL versions also include a group of JSON functions such as&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/JSONFunctions#json_array_to_mv.28.26lt.3Bjson_array.26gt.3B.2C_.26lt.3BBoolean.26gt.3B.29" target="_blank" rel="noopener"&gt;json_array_to_mv()&lt;/A&gt;, e.g.,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Recipients=json_array_to_mv('OperationProperties{}.Value.Recipients'​)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:23:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609777#M212039</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-08-17T07:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609778#M212040</link>
      <description>&lt;LI-CODE lang="markup"&gt;| spath output=Recipients path=OperationProperties{}.Value{}.Recipients{}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:26:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609778#M212040</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-17T07:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609779#M212041</link>
      <description>&lt;P&gt;Thank you for responding.&amp;nbsp; Neither of the 2 options are working. Don't see my output field Recipients getting created. I also tried&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath output=Recipients path='OperationProperties{}.Value{}.Recipients{}'&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I will play around with the function you suggested.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:30:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609779#M212041</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-17T07:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609781#M212043</link>
      <description>&lt;P&gt;Not totally sure about your data, but this search, which uses your example data extracts Recipients. That field is a string value of the Value field of the RuleActions array element, so I've done this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="{
    \"OperationProperties\": [
        {
            \"Name\": \"RuleId\",
            \"Value\": \"3623734839020093442\"
        },
        {
            \"Name\": \"RuleName\",
            \"Value\": \"ForwardingRule01\"
        },
        {
            \"Name\": \"RuleActions\",
            \"Value\": \"[{\\\"ActionType\\\":\\\"Forward\\\",\\\"Recipients\\\":[\\\"WADRIANL@domain.com\\\",\\\"WENDYLIM@domain.com\\\"], \\\"Forward Flags\\\":\\\"None\\\"}]\"
        }
    ]
}"
| spath
| rename OperationProperties{}.Value as Value, OperationProperties{}.Name as Name
| eval index=mvfind(Name, "RuleActions")
| eval RecipField=mvindex(Value, index)
| spath input=RecipField
| rename {}.Recipients{} as Recipients&lt;/LI-CODE&gt;&lt;P&gt;The mvfind looks for the array offset for the RuleActions in the Name field and then graps the corresponding array element of the Value field and spaths that array. Then it finally grabs the Recipients.&lt;/P&gt;&lt;P&gt;Hope this is useful&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:31:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609781#M212043</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-17T07:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609783#M212045</link>
      <description>&lt;P&gt;Thank you for responding. Even this is not working although it does seem to be correct given that both &lt;STRONG&gt;Value&lt;/STRONG&gt; and &lt;STRONG&gt;Recipients&lt;/STRONG&gt; are nested arrays. Really odd.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609783#M212045</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-17T07:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609785#M212047</link>
      <description>&lt;P&gt;Can you share your raw event rather than the formatted version?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609785#M212047</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-17T07:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609790#M212051</link>
      <description>&lt;P&gt;Not sure why, but this line fails to create a new field RecipField .&amp;nbsp; Checking further.&lt;/P&gt;&lt;PRE&gt;| eval RecipField=mvindex(Value, index)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609790#M212051</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-17T07:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609797#M212054</link>
      <description>&lt;P&gt;Check what comes back from the mvfind - if it's null, it means that the text could not be found in the multivalue extracted data.&lt;/P&gt;&lt;P&gt;Best is to show _raw data, as the pretty printing of JSON will be hiding all the quotes - that nested data is probably not part of the JSON itself, so you will have to parse the whole Value string to JSON to then get the real recipients out and presumably that data will appear as _one_ of the array elements with the RuleActions name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 08:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609797#M212054</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-17T08:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609798#M212055</link>
      <description>&lt;LI-CODE lang="markup"&gt;| spath OperationProperties{} output=OP
| mvexpand OP
| spath input=OP
| where Name="RuleActions"
| spath input=Value
| rename {}.* as *&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 17 Aug 2022 09:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609798#M212055</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-17T09:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609799#M212056</link>
      <description>&lt;P&gt;This didn't work because in the real data one of the OperationProperties has a Name but no Value, which throws out the indexing.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 09:04:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609799#M212056</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-17T09:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609802#M212057</link>
      <description>&lt;P&gt;As clarified by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;, the &lt;STRONG&gt;mvindex&lt;/STRONG&gt; didn't work due to indexing order issue. So If i explicitly use something like below , the RecipField gets created&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval RecipField=mvindex('OperationProperties{}.Value',5)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Value :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_0-1660737823388.png" style="width: 581px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21067i54119774BE5333A8/image-dimensions/581x255?v=v2" width="581" height="255" role="button" title="neerajs_81_0-1660737823388.png" alt="neerajs_81_0-1660737823388.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;i now&amp;nbsp; need to come up with a&amp;nbsp; rex using mode=sed to remove all those spl characters above&amp;nbsp; and make it display those recipient email addresses only&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 12:26:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609802#M212057</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-17T12:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609888#M212079</link>
      <description>&lt;P&gt;Do you mean that the RecipField now contains the full encapsulated JSON.&lt;/P&gt;&lt;P&gt;You would be able to use the&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=RecipField&lt;/LI-CODE&gt;&lt;P&gt;to then get out the array elements of that encapsulated JSON.&lt;/P&gt;&lt;P&gt;An alternative to using a fixed array element offset in the mvindex, you could use this to 'find' the Recipients JSON data from the Value using mvmap, which will return the contents of the Value field if it contains the word Recipients&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| rename OperationProperties{}.Value as Value, OperationProperties{}.Name as Name
| eval RuleActionJSON=mvmap(Value, if(match(Value, "Recipients"), Value, RuleActionJSON))
| spath input=RuleActionJSON 
| rename {}.Recipients{} as Recipients&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 23:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609888#M212079</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-08-17T23:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Spath for Nested Json</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609921#M212094</link>
      <description>&lt;P&gt;Thank you. Awarded you karma points for all your replies.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 07:12:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Spath-for-Nested-Json/m-p/609921#M212094</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-18T07:12:26Z</dc:date>
    </item>
  </channel>
</rss>

