<?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 do I access nested JSON? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-access-nested-JSON/m-p/402637#M116507</link>
    <description>&lt;P&gt;I have message that contains nested JSON inside which contains a &lt;CODE&gt;message&lt;/CODE&gt; field that contains a &lt;CODE&gt;Java exception&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{xxxx: "some-fields-here",
    message:  {"logRecordType":"X",
"timestamp":"1533748762718","threadId":"42",,"message":"Background operation retry gave up
org.apache.zookeeper.KeeperException$SessionExpiredException: KeeperErrorCode = Session expired
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:127)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkBackgroundRetry(CuratorFrameworkImpl.java:728)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:516)
    at org.apache.curator.framework.imps.GetChildrenBuilderImpl$2.processResult(GetChildrenBuilderImpl.java:166)
    at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:615)
    at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:519)"} 

more-json-fields
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I access the nested &lt;CODE&gt;message&lt;/CODE&gt; field? tried different variations of using &lt;CODE&gt;spath&lt;/CODE&gt; but was never able to get the nested message, only the top-level message.&lt;BR /&gt;
Ideally, I'd want to replace &lt;CODE&gt;\n&lt;/CODE&gt; with &lt;CODE&gt;;&lt;/CODE&gt; so that it wouldn't mess up my output downstream.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Aug 2018 01:42:42 GMT</pubDate>
    <dc:creator>tolikuznets</dc:creator>
    <dc:date>2018-08-15T01:42:42Z</dc:date>
    <item>
      <title>How do I access nested JSON?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-access-nested-JSON/m-p/402637#M116507</link>
      <description>&lt;P&gt;I have message that contains nested JSON inside which contains a &lt;CODE&gt;message&lt;/CODE&gt; field that contains a &lt;CODE&gt;Java exception&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{xxxx: "some-fields-here",
    message:  {"logRecordType":"X",
"timestamp":"1533748762718","threadId":"42",,"message":"Background operation retry gave up
org.apache.zookeeper.KeeperException$SessionExpiredException: KeeperErrorCode = Session expired
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:127)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkBackgroundRetry(CuratorFrameworkImpl.java:728)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:516)
    at org.apache.curator.framework.imps.GetChildrenBuilderImpl$2.processResult(GetChildrenBuilderImpl.java:166)
    at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:615)
    at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:519)"} 

more-json-fields
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I access the nested &lt;CODE&gt;message&lt;/CODE&gt; field? tried different variations of using &lt;CODE&gt;spath&lt;/CODE&gt; but was never able to get the nested message, only the top-level message.&lt;BR /&gt;
Ideally, I'd want to replace &lt;CODE&gt;\n&lt;/CODE&gt; with &lt;CODE&gt;;&lt;/CODE&gt; so that it wouldn't mess up my output downstream.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 01:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-access-nested-JSON/m-p/402637#M116507</guid>
      <dc:creator>tolikuznets</dc:creator>
      <dc:date>2018-08-15T01:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I access nested JSON?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-access-nested-JSON/m-p/402638#M116508</link>
      <description>&lt;P&gt;@tolikuznets , try the following command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourCurrentSearch&amp;gt;
| rex "\"message\":\"(?&amp;lt;message&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search based on your sample data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="{xxxx: \"some-fields-here\", message: {\"logRecordType\":\"X\", \"timestamp\":\"1533748762718\",\"threadId\":\"42\",,\"message\":\"Background operation retry gave up org.apache.zookeeper.KeeperException$SessionExpiredException: KeeperErrorCode = Session expired at org.apache.zookeeper.KeeperException.create(KeeperException.java:127) at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkBackgroundRetry(CuratorFrameworkImpl.java:728) at org.apache.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:516) at org.apache.curator.framework.imps.GetChildrenBuilderImpl$2.processResult(GetChildrenBuilderImpl.java:166) at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:615) at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:519)\"} }"
| rex "\"message\":\"(?&amp;lt;message&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Aug 2018 06:59:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-access-nested-JSON/m-p/402638#M116508</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-15T06:59:55Z</dc:date>
    </item>
  </channel>
</rss>

