<?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 multi-level nested JSON to table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/multi-level-nested-JSON-to-table/m-p/645447#M223480</link>
    <description>&lt;P&gt;There are numerous questions/answers about extracting nested JSON data, but none of those answers seem to apply to what I am attempting to do.&lt;/P&gt;&lt;P&gt;Given the following JSON data as indexed by Splunk:&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;  "disks": {&lt;BR /&gt;    "nvme0n1": {&lt;BR /&gt;      "model": "PC401 NVMe SK hynix 512GB",&lt;BR /&gt;      "serial": "123",&lt;BR /&gt;      "size": "476.94 GiB",&lt;BR /&gt;      "size_bytes": 512110190592,&lt;BR /&gt;      "type": "ssd",&lt;BR /&gt;    },&lt;BR /&gt;    "sda": {&lt;BR /&gt;      "model": "SK hynix SC401 S",&lt;BR /&gt;      "serial": "456",&lt;BR /&gt;      "size": "953.87 GiB",&lt;BR /&gt;      "size_bytes": 1024209543168,&lt;BR /&gt;      "type": "ssd",&lt;BR /&gt;      "vendor": "ATA",&lt;BR /&gt;    },&lt;BR /&gt;    "sdb": {&lt;BR /&gt;      "model": "SD/MMC CRW",&lt;BR /&gt;      "serial": "789",&lt;BR /&gt;      "size": "0 bytes",&lt;BR /&gt;      "size_bytes": 0,&lt;BR /&gt;      "type": "hdd",&lt;BR /&gt;      "vendor": "Generic-"&lt;BR /&gt;    },&lt;BR /&gt;  }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;I want to produce a table like this:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;             host     disk                      model  serial        size  type&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;myhost.example.org  nvme0n1  PC401 NVMe SK hynix 512GB     123  476.94 GiB   ssd&lt;BR /&gt;myhost.example.org      sda           SK hynix SC401 S     456  953.87 GiB   ssd&lt;BR /&gt;myhost.example.org      sdb                 SD/MMC CRW     789     0 bytes   hdd&lt;BR /&gt;--------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;I can go after an individual disk, like so:&lt;/P&gt;&lt;PRE&gt;search … |&lt;BR /&gt;dedup host |&lt;BR /&gt;spath output=disk "disks.sda" |&lt;BR /&gt;mvexpand disk |&lt;BR /&gt;spath input=disk |&lt;BR /&gt;table host model serial size type&lt;/PRE&gt;&lt;P&gt;…but how to perform this step for each disk in the disks array eludes me. Does anyone have any solutions?&lt;/P&gt;&lt;P&gt;A related question: where is SPL documented to such a degree where one could reasonably understand how to perform this type of extraction? Splunk documents the individual commands, but doesn’t really explain how to tie them together to create more complex actions, and the &lt;A href="https://www.splunk.com/en_us/form/exploring-splunk-search-processing-language-spl-primer-and-cookbook.html" target="_self"&gt;Exploring Splunk: Search Processing Language (SPL) Primer and Cookbook&lt;/A&gt; doesn’t even come close to explaining how to perform a complex action like this. Are there others tutorials/primers?&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2023 21:31:44 GMT</pubDate>
    <dc:creator>qralston</dc:creator>
    <dc:date>2023-06-01T21:31:44Z</dc:date>
    <item>
      <title>multi-level nested JSON to table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multi-level-nested-JSON-to-table/m-p/645447#M223480</link>
      <description>&lt;P&gt;There are numerous questions/answers about extracting nested JSON data, but none of those answers seem to apply to what I am attempting to do.&lt;/P&gt;&lt;P&gt;Given the following JSON data as indexed by Splunk:&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;  "disks": {&lt;BR /&gt;    "nvme0n1": {&lt;BR /&gt;      "model": "PC401 NVMe SK hynix 512GB",&lt;BR /&gt;      "serial": "123",&lt;BR /&gt;      "size": "476.94 GiB",&lt;BR /&gt;      "size_bytes": 512110190592,&lt;BR /&gt;      "type": "ssd",&lt;BR /&gt;    },&lt;BR /&gt;    "sda": {&lt;BR /&gt;      "model": "SK hynix SC401 S",&lt;BR /&gt;      "serial": "456",&lt;BR /&gt;      "size": "953.87 GiB",&lt;BR /&gt;      "size_bytes": 1024209543168,&lt;BR /&gt;      "type": "ssd",&lt;BR /&gt;      "vendor": "ATA",&lt;BR /&gt;    },&lt;BR /&gt;    "sdb": {&lt;BR /&gt;      "model": "SD/MMC CRW",&lt;BR /&gt;      "serial": "789",&lt;BR /&gt;      "size": "0 bytes",&lt;BR /&gt;      "size_bytes": 0,&lt;BR /&gt;      "type": "hdd",&lt;BR /&gt;      "vendor": "Generic-"&lt;BR /&gt;    },&lt;BR /&gt;  }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;I want to produce a table like this:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;             host     disk                      model  serial        size  type&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;myhost.example.org  nvme0n1  PC401 NVMe SK hynix 512GB     123  476.94 GiB   ssd&lt;BR /&gt;myhost.example.org      sda           SK hynix SC401 S     456  953.87 GiB   ssd&lt;BR /&gt;myhost.example.org      sdb                 SD/MMC CRW     789     0 bytes   hdd&lt;BR /&gt;--------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;I can go after an individual disk, like so:&lt;/P&gt;&lt;PRE&gt;search … |&lt;BR /&gt;dedup host |&lt;BR /&gt;spath output=disk "disks.sda" |&lt;BR /&gt;mvexpand disk |&lt;BR /&gt;spath input=disk |&lt;BR /&gt;table host model serial size type&lt;/PRE&gt;&lt;P&gt;…but how to perform this step for each disk in the disks array eludes me. Does anyone have any solutions?&lt;/P&gt;&lt;P&gt;A related question: where is SPL documented to such a degree where one could reasonably understand how to perform this type of extraction? Splunk documents the individual commands, but doesn’t really explain how to tie them together to create more complex actions, and the &lt;A href="https://www.splunk.com/en_us/form/exploring-splunk-search-processing-language-spl-primer-and-cookbook.html" target="_self"&gt;Exploring Splunk: Search Processing Language (SPL) Primer and Cookbook&lt;/A&gt; doesn’t even come close to explaining how to perform a complex action like this. Are there others tutorials/primers?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 21:31:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multi-level-nested-JSON-to-table/m-p/645447#M223480</guid>
      <dc:creator>qralston</dc:creator>
      <dc:date>2023-06-01T21:31:44Z</dc:date>
    </item>
  </channel>
</rss>

