<?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: Nested JSON issues with Spath in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459321#M79328</link>
    <description>&lt;P&gt;Hey bud!&lt;BR /&gt;
This is under the assumption that you're trying to get the count of logins by distinct source&lt;/P&gt;

&lt;PRE&gt;
index=your_index Workload=your_workload ResultStatus=Succeeded Operation=UserLoggedIn 
| spath
| bucket span=30s _time
| rename Actor{}.ID AS "Email", Actor{}.Type AS "Type"
| eval temp=mvzip(Email,Type)
| mvexpand temp
| eval Email=mvindex(split(temp,","),0)
| stats count(Email) AS logincount BY Email src _time 
| search (logincount &amp;gt;= 3 AND Email=*@*)
| table Email src logincount _time
 &lt;/PRE&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 17:51:01 GMT</pubDate>
    <dc:creator>djrose</dc:creator>
    <dc:date>2019-08-22T17:51:01Z</dc:date>
    <item>
      <title>Nested JSON issues with Spath</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459320#M79327</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
First time poster also fairly new to splunk though I am fluent in Python and decent at sql so apologies if this post is awkward.&lt;/P&gt;

&lt;P&gt;I am dealing with json that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Actor: [   [-] 
    {   [-] 
     ID:     8f71273c-c502-4a39-9607-6b272c9df  
     Type:   0  
    }   
    {   [-] 
     ID:    email@myemail.com   
     Type:   5  
    }   
    {   [-] 
     ID:     1003200038F18F0E   
     Type:   3  
    }   
]   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to dig out the email with spath (first time using this) and i am not getting the results I want.  Also getting weird results (for example there are 3 fields and if I use something like 100 it still returns data.&lt;/P&gt;

&lt;P&gt;Here is my code any help would be super appreciated.&lt;/P&gt;

&lt;P&gt;This code works but does not do what i want (it produces 3 events since it is just taking id).  I just want email and I dont want to use a regex I just want to dig deeper into the json&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mine Workload=AzureActiveDirectory ResultStatus=Succeeded Operation=UserLoggedIn 
| bucket span=30s _time
| stats count dc(src) as mycount by "Actor{}.ID" 
| where mycount&amp;gt;=3 
| sort mycount desc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the code that is not working that I want to work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mine Workload=AzureActiveDirectory ResultStatus=Succeeded Operation=UserLoggedIn 
| bucket span=30s _time 
| spath output=leon path=Actor{}.ID{1}
| stats count dc(src) as mycount by "Actor{}.ID{1}" 
| where mycount&amp;gt;=3 
| sort mycount desc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns no events.&lt;/P&gt;

&lt;P&gt;I have played with various forms of .ID and it never works.  &lt;/P&gt;

&lt;P&gt;Please help!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:43:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459320#M79327</guid>
      <dc:creator>leon_r</dc:creator>
      <dc:date>2019-08-22T14:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Nested JSON issues with Spath</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459321#M79328</link>
      <description>&lt;P&gt;Hey bud!&lt;BR /&gt;
This is under the assumption that you're trying to get the count of logins by distinct source&lt;/P&gt;

&lt;PRE&gt;
index=your_index Workload=your_workload ResultStatus=Succeeded Operation=UserLoggedIn 
| spath
| bucket span=30s _time
| rename Actor{}.ID AS "Email", Actor{}.Type AS "Type"
| eval temp=mvzip(Email,Type)
| mvexpand temp
| eval Email=mvindex(split(temp,","),0)
| stats count(Email) AS logincount BY Email src _time 
| search (logincount &amp;gt;= 3 AND Email=*@*)
| table Email src logincount _time
 &lt;/PRE&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 17:51:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459321#M79328</guid>
      <dc:creator>djrose</dc:creator>
      <dc:date>2019-08-22T17:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Nested JSON issues with Spath</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459322#M79329</link>
      <description>&lt;P&gt;The JSON that you posted is not valid so Splunk will not recognize it as JSON so first fix that (perhaps it is a cut/paste/post mistake on your part).  This parses for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw = "{
    \"Actor\": [{
        \"ID\": \"8 f71273c - c502 - 4 a39 - 9607 - 6 b272c9df\",
        \"Type\": 0
    }, {
        \"ID\": \"email@myemail.com\",
        \"Type\": 5
    }, {
        \"ID\": \"1003200038 F18F0E\",
        \"Type\": 3
    }]
}"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mine Workload=AzureActiveDirectory ResultStatus=Succeeded Operation=UserLoggedIn 
| spath
| eval email=mvindex('Actor{}.ID', 1)
| stats count dc(src) AS mycount BY email
| where mycount&amp;gt;=3 
| sort 0 - mycount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Sep 2019 21:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Nested-JSON-issues-with-Spath/m-p/459322#M79329</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-09-17T21:30:24Z</dc:date>
    </item>
  </channel>
</rss>

