<?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: Display nested JSON as table in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384567#M69147</link>
    <description>&lt;P&gt;@theiamdude, except for the &lt;EM&gt;ansible_facts&lt;/EM&gt; block, rest of the text does not look like properly formatted in json. &lt;BR /&gt;
What do you get when you run spath? does it show the &lt;EM&gt;ansible_facts&lt;/EM&gt; in the fields section on the left side panel?&lt;/P&gt;</description>
    <pubDate>Wed, 14 Nov 2018 12:41:00 GMT</pubDate>
    <dc:creator>pramit46</dc:creator>
    <dc:date>2018-11-14T12:41:00Z</dc:date>
    <item>
      <title>Display nested JSON as table</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384566#M69146</link>
      <description>&lt;P&gt;I am trying to implement system package tracking in Splunk using Ansible facts collections but I am having some difficulties reading message received.&lt;/P&gt;

&lt;P&gt;The message received is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    {   [-] 
         @timestamp:     2018-11-06T22:07:46.062Z   
         ansible_facts: {   [+] 
        }   
         ansible_facts_modified:     2018-11-06T22:07:46.027218+00:00   
         cluster_host_id:    awx    
         host:   awx    
         host_name:  192.168.1.120  
         inventory_id:   2  
         job_id:     48 
         level:  INFO   
         logger_name:    awx.analytics.system_tracking  
         message:    New fact for inventory Local host 192.168.1.120    
         tower_uuid:    
         type:   splunk 
    }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Most of the information I need is inside the ansible_facts block and I am able to get most of them except 2 areas which have a different structure. The structure is the same for both of those.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "ansible_facts": {
        "packages": {
            "libbz2-1.0": [{
                "version": "1.0.6-5",
                "source": "apt",
                "arch": "amd64",
                "name": "libbz2-1.0"
            }],
            "patch": [{
                "version": "2.7.1-4ubuntu1",
                "source": "apt",
                "arch": "amd64",
                "name": "patch"
            }],
            "gcc-4.8-base": [{
                    "version": "4.8.2-19ubuntu1",
                    "source": "apt",
                    "arch": "amd64",
                    "name": "gcc-4.8-base"
                }
            ]
        }
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Further down, i would like to print any changes of package version through time but at this stage I am trying to print the list of packages and their corresponding versions in table.&lt;/P&gt;

&lt;P&gt;I tried the following search, but it's not returning any results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;spath input=_raw | rename ansible_facts.packages{}.* as *
 | eval values=mvzip(mvzip(mvzip(name,version),release),arch)
 | mvexpand values| eval values = split(values,",")
 | eval name=mvindex(values,0)|eval version=mvindex(values,1) |eval release=mvindex(values,2)|eval arch=mvindex(values,3)
 | table name version release arch
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 05:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384566#M69146</guid>
      <dc:creator>theiamdude</dc:creator>
      <dc:date>2018-11-14T05:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Display nested JSON as table</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384567#M69147</link>
      <description>&lt;P&gt;@theiamdude, except for the &lt;EM&gt;ansible_facts&lt;/EM&gt; block, rest of the text does not look like properly formatted in json. &lt;BR /&gt;
What do you get when you run spath? does it show the &lt;EM&gt;ansible_facts&lt;/EM&gt; in the fields section on the left side panel?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 12:41:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384567#M69147</guid>
      <dc:creator>pramit46</dc:creator>
      <dc:date>2018-11-14T12:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Display nested JSON as table</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384568#M69148</link>
      <description>&lt;P&gt;I am able to some of the value in the fields section.&lt;/P&gt;

&lt;P&gt;I am able to get other value under ansible_facts block (below is not the entire block):&lt;BR /&gt;
    {&lt;BR /&gt;
      "ansible_facts": {&lt;BR /&gt;
        "ansible_distribution": "OracleLinux",&lt;BR /&gt;
        "ansible_distribution_version": "6.9",&lt;BR /&gt;
        "ansible_architecture": "x86_64",&lt;BR /&gt;
        "ansible_os_family": "RedHat",&lt;BR /&gt;
        "ansible_kernel": "3.8.13-118.21.4.el6uek.x86_64",&lt;BR /&gt;
        "facter_processorcount": 2,&lt;BR /&gt;
        "facter_memorysize": "7.80 GB",&lt;BR /&gt;
        "facter_uptime": "34 days",&lt;BR /&gt;
        "ansible_bios_version": "4.4.4OVM",&lt;BR /&gt;
        "ansible_bios_date": "04/18/2018",&lt;BR /&gt;
        "ansible_hostname": "localhost",&lt;BR /&gt;
        "ansible_pkg_mgr": "yum",&lt;BR /&gt;
        "ansible_user_id": "testapp",&lt;BR /&gt;
        "packages": {&lt;BR /&gt;
                 "libbz2-1.0": [{&lt;BR /&gt;
                     "version": "1.0.6-5",&lt;BR /&gt;
                     "source": "apt",&lt;BR /&gt;
                     "arch": "amd64",&lt;BR /&gt;
                     "name": "libbz2-1.0"&lt;BR /&gt;
                 }],&lt;BR /&gt;
                 "patch": [{&lt;BR /&gt;
                     "version": "2.7.1-4ubuntu1",&lt;BR /&gt;
                     "source": "apt",&lt;BR /&gt;
                     "arch": "amd64",&lt;BR /&gt;
                     "name": "patch"&lt;BR /&gt;
                 }],&lt;BR /&gt;
                 "gcc-4.8-base": [{&lt;BR /&gt;
                         "version": "4.8.2-19ubuntu1",&lt;BR /&gt;
                         "source": "apt",&lt;BR /&gt;
                         "arch": "amd64",&lt;BR /&gt;
                         "name": "gcc-4.8-base"&lt;BR /&gt;
                     }&lt;BR /&gt;
                 ]&lt;BR /&gt;
             },&lt;BR /&gt;
        "services": {&lt;BR /&gt;
          "blk-availability": {&lt;BR /&gt;
            "source": "sysv",&lt;BR /&gt;
            "state": "running",&lt;BR /&gt;
            "name": "blk-availability"&lt;BR /&gt;
          },&lt;BR /&gt;
          "lvm2-lvmetad": {&lt;BR /&gt;
            "source": "sysv",&lt;BR /&gt;
            "state": "running",&lt;BR /&gt;
            "name": "lvm2-lvmetad"&lt;BR /&gt;
          },&lt;BR /&gt;
          "acpid": {&lt;BR /&gt;
            "source": "sysv",&lt;BR /&gt;
            "state": "running",&lt;BR /&gt;
            "name": "acpid"&lt;BR /&gt;
          }&lt;BR /&gt;
        }&lt;BR /&gt;
      }&lt;BR /&gt;
    }&lt;/P&gt;

&lt;P&gt;When I run the following search I am able to get it in a table:&lt;BR /&gt;
    index=dev__inf source=AWX_source | spath logger_name | search logger_name="awx.analytics.system_tracking"&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_distribution" output=linux_distribution&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_distribution_version" output=distribution_version&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_architecture" output=architecture&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_os_family" output=os_family&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_kernel" output=kernel&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.facter_processorcount" output=processorcount&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.facter_memorysize" output=memorysize&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_bios_version" output=bios_version&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_bios_date" output=bios_date&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_hostname" output=hostname&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_pkg_mgr" output=pkg_mgr&lt;BR /&gt;
    | spath input=_raw path="ansible_facts.ansible_user_id" output=user_id&lt;BR /&gt;
    | table hostname user_id architecture os_family linux_distribution distribution_version kernel pkg_mgr bios_version bios_date processorcount memorysize&lt;/P&gt;

&lt;TABLE&gt;&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH&gt;hostname&lt;/TH&gt;
&lt;TH&gt;user_id&lt;/TH&gt;
&lt;TH&gt;architecture&lt;/TH&gt;
&lt;TH&gt;os_family&lt;/TH&gt;
&lt;TH&gt;linux_distribution&lt;/TH&gt;
&lt;TH&gt;distribution_version&lt;/TH&gt;
&lt;TH&gt;kernel&lt;/TH&gt;
&lt;TH&gt;pkg_mgr&lt;/TH&gt;
&lt;TH&gt;bios_version&lt;/TH&gt;
&lt;TH&gt;bios_date&lt;/TH&gt;
&lt;TH&gt;processorcount&lt;/TH&gt;
&lt;TH&gt;memorysize&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;localhost&lt;/TD&gt;
&lt;TD&gt;testapp&lt;/TD&gt;
&lt;TD&gt;x86_64&lt;/TD&gt;
&lt;TD&gt;RedHat&lt;/TD&gt;
&lt;TD&gt;OracleLinux&lt;/TD&gt;
&lt;TD&gt;6.9&lt;/TD&gt;
&lt;TD&gt;3.8.13&lt;/TD&gt;
&lt;TD&gt;yum&lt;/TD&gt;
&lt;TD&gt;4.4.4OVM&lt;/TD&gt;
&lt;TD&gt;04/18/2018&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;7.80 GB&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:59:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-nested-JSON-as-table/m-p/384568#M69148</guid>
      <dc:creator>theiamdude</dc:creator>
      <dc:date>2020-09-29T21:59:43Z</dc:date>
    </item>
  </channel>
</rss>

