<?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 How extract dynamic json keys recursively and condition based add data to table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-extract-dynamic-json-keys-recursively-and-condition-based/m-p/374887#M110179</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am new to Splunk and I have been trying to generate report table format using json data, I am able to spath and output the value to the table. But There some object in json which is unpredictable those I want to get by using parent key and append the value based on condition. Below is the sample json event&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "tag": "salt/job/20180322112723081888/ret/minion1",
    "data": {
        "fun_args": ["install.centos7.soft", {
            "test": true
        }],
        "jid": "20180322112723081888",
        "return": {
            "file_|-/etc/resolve.conf_|-/etc/resolve.conf_|-append": {
                "comment": "File /etc/resolve.conf is set to be updated",
                "pchanges": {},
                "name": "/etc/resolve.conf",
                "start_time": "11:27:33.462182",
                "result": null,
                "duration": 3.232,
                "__run_num__": 27,
                "__sls__": "install.centos7.resolve",
                "changes": {
                    "diff": "--- \n\n+++ \n\n@@ -0,0 +1 @@\n\n+-a nameserver 8.8.8.8"
                },
                "__id__": "/etc/resolve.conf"
            },
            "pkg_|-remove_rservices_|-remove_rservices_|-purged": {
                "comment": "All specified packages are already absent",
                "name": "remove_rservices",
                "start_time": "11:27:33.229081",
                "result": true,
                "duration": 0.608,
                "__run_num__": 7,
                "__sls__": "install.centos7.soft",
                "changes": {},
                "__id__": "remove_rservices"
            }
        },
        "retcode": 0,
        "success": true,
        "cmd": "_return",
        "_stamp": "2018-03-22T11:27:33.945590",
        "fun": "state.apply",
        "id": "minion-1",
        "out": "highstate"
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this json I want to extract each object from &lt;STRONG&gt;return&lt;/STRONG&gt; key, there is condition if object key changes don't have vale go for next object or if changes have value append  "&lt;STRONG&gt;sls&lt;/STRONG&gt;"  value in table.&lt;BR /&gt;
Below is the target sample table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;minion              state                                  changes
-----------------------------------------------------------------------------------------
minion-1          install.centos7.soft          install.centos7.resolve
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Changes can be multi value for single minion&lt;/P&gt;

&lt;P&gt;Can anyone please suggest me how I can achieve this&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 22 Mar 2018 18:10:28 GMT</pubDate>
    <dc:creator>pradiprwt</dc:creator>
    <dc:date>2018-03-22T18:10:28Z</dc:date>
    <item>
      <title>How extract dynamic json keys recursively and condition based add data to table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-dynamic-json-keys-recursively-and-condition-based/m-p/374887#M110179</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am new to Splunk and I have been trying to generate report table format using json data, I am able to spath and output the value to the table. But There some object in json which is unpredictable those I want to get by using parent key and append the value based on condition. Below is the sample json event&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "tag": "salt/job/20180322112723081888/ret/minion1",
    "data": {
        "fun_args": ["install.centos7.soft", {
            "test": true
        }],
        "jid": "20180322112723081888",
        "return": {
            "file_|-/etc/resolve.conf_|-/etc/resolve.conf_|-append": {
                "comment": "File /etc/resolve.conf is set to be updated",
                "pchanges": {},
                "name": "/etc/resolve.conf",
                "start_time": "11:27:33.462182",
                "result": null,
                "duration": 3.232,
                "__run_num__": 27,
                "__sls__": "install.centos7.resolve",
                "changes": {
                    "diff": "--- \n\n+++ \n\n@@ -0,0 +1 @@\n\n+-a nameserver 8.8.8.8"
                },
                "__id__": "/etc/resolve.conf"
            },
            "pkg_|-remove_rservices_|-remove_rservices_|-purged": {
                "comment": "All specified packages are already absent",
                "name": "remove_rservices",
                "start_time": "11:27:33.229081",
                "result": true,
                "duration": 0.608,
                "__run_num__": 7,
                "__sls__": "install.centos7.soft",
                "changes": {},
                "__id__": "remove_rservices"
            }
        },
        "retcode": 0,
        "success": true,
        "cmd": "_return",
        "_stamp": "2018-03-22T11:27:33.945590",
        "fun": "state.apply",
        "id": "minion-1",
        "out": "highstate"
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this json I want to extract each object from &lt;STRONG&gt;return&lt;/STRONG&gt; key, there is condition if object key changes don't have vale go for next object or if changes have value append  "&lt;STRONG&gt;sls&lt;/STRONG&gt;"  value in table.&lt;BR /&gt;
Below is the target sample table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;minion              state                                  changes
-----------------------------------------------------------------------------------------
minion-1          install.centos7.soft          install.centos7.resolve
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Changes can be multi value for single minion&lt;/P&gt;

&lt;P&gt;Can anyone please suggest me how I can achieve this&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 18:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-dynamic-json-keys-recursively-and-condition-based/m-p/374887#M110179</guid>
      <dc:creator>pradiprwt</dc:creator>
      <dc:date>2018-03-22T18:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: How extract dynamic json keys recursively and condition based add data to table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-dynamic-json-keys-recursively-and-condition-based/m-p/374888#M110180</link>
      <description>&lt;P&gt;Did you ever find an answer for your question?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 13:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-dynamic-json-keys-recursively-and-condition-based/m-p/374888#M110180</guid>
      <dc:creator>jagadeeshm</dc:creator>
      <dc:date>2019-05-29T13:27:07Z</dc:date>
    </item>
  </channel>
</rss>

