<?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: expand json array to multiple events, then search constraints on the results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479654#M134439</link>
    <description>&lt;P&gt;this returns no results in the stats table. &lt;/P&gt;</description>
    <pubDate>Tue, 28 Apr 2020 16:49:17 GMT</pubDate>
    <dc:creator>zachsisinst</dc:creator>
    <dc:date>2020-04-28T16:49:17Z</dc:date>
    <item>
      <title>expand json array to multiple events, then search constraints on the results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479650#M134435</link>
      <description>&lt;P&gt;Hello, I've gone through a hundred of these types of posts and nothing is working for me. Here is the nested json array that I would like to split into a table of individual events, based on the &lt;CODE&gt;computer.hardware.storage.device.partition{}&lt;/CODE&gt;  and &lt;CODE&gt;computer.general.name&lt;/CODE&gt;. Once I have these split into individual events, I would like to only put the 'boot' device event in the table. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "computer": {
        "general": {
            "name": "woohoo-l3"
        },
        "hardware": {
            "storage": {
                "device": {
                    "partition": [
                        {
                            "name": "Macintosh HD (Boot Partition)",
                            "type": "boot",
                            "filevault_status": "Encrypted",
                            "filevault_percent": "100",
                        },
                        {
                            "name": "Recovery",
                            "type": "other",
                            "filevault_status": "Not Encrypted",
                            "filevault_percent": "0",
                        }
                    ]
                }
            }
        }
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have come up with the following search but it does not do what I want. I've been messing with this all day and I'm stuck. Any help would be greatly appreciated! &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sec-inventory sourcetype="jamf-computers" "c02z912nlvdl" 
| spath
| rename computer.hardware.storage.device{}.partition.filevault_status as filevault_status 
| rename computer.hardware.storage.device.partition{}.type as partitiontype
| rename computer.general.name as computername 
| eval zipped=mvzip(filevault_status, partitiontype)
| mvexpand zipped
| eval zipped=split(zipped, ",")
| eval filevault_status=mvindex(zipped, 0)
| eval type=mvindex(zipped, 1)
| fillnull value="null" 
| table computername, partitiontype, filevault_status
| search partitiontype="boot" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The table should look like &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8728i0D2610A8AB15FB54/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 04:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479650#M134435</guid>
      <dc:creator>zachsisinst</dc:creator>
      <dc:date>2020-04-23T04:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: expand json array to multiple events, then search constraints on the results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479651#M134436</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Please try the following and check whether your JSON data is a valid one. &lt;BR /&gt;
Finally, add your filter.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval temp=" {
     \"computer\": {
         \"general\": {
             \"name\": \"woohoo-l3\"
                                     },
         \"hardware\": {
             \"storage\": {
                 \"device\": {
                     \"partition\": [
                         {
                             \"name\": \"Macintosh HD (Boot Partition)\",
                             \"type\": \"boot\",
                             \"filevault_status\": \"Encrypted\",
                             \"filevault_percent\": \"100\"
                                                     },
                         {
                             \"name\": \"Recovery\",
                             \"type\": \"other\",
                             \"filevault_status\": \"Not Encrypted\",
                             \"filevault_percent\": \"0\"
                                                     }
                     ]
                 }
             }
         }
     }
 }" 
| spath input=temp 
| rename computer.hardware.storage.device.partition{}.filevault_status as filevault_status 
| rename computer.hardware.storage.device.partition{}.type as partitiontype 
| rename computer.general.name as computername 
| fields computername partitiontype filevault_status 
| eval temp=mvzip(partitiontype,filevault_status) 
| table computername temp 
| mvexpand temp 
| eval value=split(temp,",") 
| eval partitiontype=mvindex(value,0),filevault_status=mvindex(value,1) 
| table computername partitiontype filevault_status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 05:13:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479651#M134436</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2020-04-23T05:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: expand json array to multiple events, then search constraints on the results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479652#M134437</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; index=sec-inventory sourcetype="jamf-computers" "c02z912nlvdl" 
| spath computer.hardware.storage.device.partition{} output=partition
| spath computer.general.name output=computername
| stats values(computername) as computername by partition
| spath input=partition
| fields - partition
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is enough.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 09:09:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479652#M134437</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-23T09:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: expand json array to multiple events, then search constraints on the results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479653#M134438</link>
      <description>&lt;P&gt;I can't seem to get this to work still. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sec-inventory sourcetype="jamf-computers" 
| spath 
| rename computer.hardware.storage.device.partition{}.filevault_status as filevault_status 
| rename computer.hardware.storage.device.partition{}.type as partitiontype 
| rename computer.general.name as computername 
| fields computername partitiontype filevault_status 
| eval temp=mvzip(partitiontype,filevault_status) 
| table computername temp 
| mvexpand temp 
| eval value=split(temp,",") 
| eval partitiontype=mvindex(value,0),filevault_status=mvindex(value,1) 
| table computername partitiontype filevault_status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Apr 2020 16:47:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479653#M134438</guid>
      <dc:creator>zachsisinst</dc:creator>
      <dc:date>2020-04-28T16:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: expand json array to multiple events, then search constraints on the results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479654#M134439</link>
      <description>&lt;P&gt;this returns no results in the stats table. &lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 16:49:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/expand-json-array-to-multiple-events-then-search-constraints-on/m-p/479654#M134439</guid>
      <dc:creator>zachsisinst</dc:creator>
      <dc:date>2020-04-28T16:49:17Z</dc:date>
    </item>
  </channel>
</rss>

