<?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: Why is my nested JSON event not formatted correctly? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352622#M64621</link>
    <description>&lt;P&gt;Something like this works for me (based on sample value for message field, everything except the last line is to generate sample data).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval message="{\"invalidPublication\":\"Publication is valid for indexing at Elasticsearch and will be updated, but has warnings.\",\"authors\":[{\"lastName\":\"foo\",\"initials\":\"fb\",\"firstName\":\"bar\",\"authorResourceID\":99999}],\"title\":\"Some Title\",\"warningReasons\":[\"Invalid value for 'publicationDate' field [Sat Apr 01 2006 00:00:00 GMT-0500 (EST)], year not found in citation - dateComponents: [{\\\"year\\\":\\\"2008\\\",\\\"month\\\":\\\"6\\\",\\\"day\\\":\\\"2\\\"}].]\"]}" | table message 
| spath input=message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you confirm what's the actual field name under which your json data appears?&lt;/P&gt;</description>
    <pubDate>Mon, 13 Mar 2017 19:00:35 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-03-13T19:00:35Z</dc:date>
    <item>
      <title>Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352617#M64616</link>
      <description>&lt;P&gt;Can Splunk be configured to allow for interpreting JSON objects with multiple-levels of depth?&lt;/P&gt;

&lt;P&gt;Here's an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  
    level:  warn 
    message:  {"invalidPublication":"Publication is valid for indexing at Elasticsearch and will be updated, but has warnings.","authors":[{"lastName":"foo","initials":"fb","firstName":"bar","authorResourceID":99999}],"title":"Some Title","warningReasons":["Invalid value for 'publicationDate' field [Sat Apr 01 2006 00:00:00 GMT-0500 (EST)], year not found in citation - dateComponents: [{\"year\":\"2008\",\"month\":\"6\",\"day\":\"2\"}].]"]} 
    pid:  2888 
    sourceHostname:  somehostname.somewhere.com
    timestamp:  2017-03-13 09:55:40 
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the above example, I would like the “messages” field to be interpreted by Splunk so that I can expand/collapse each section inside the message. Right now, it just displays nested JSON as a single string. Is this possible? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 14:59:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352617#M64616</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2017-03-13T14:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352618#M64617</link>
      <description>&lt;P&gt;Have a look at spath command. Passing a field that contains json to this command will parse the json and extract fields.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 15:11:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352618#M64617</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-13T15:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352619#M64618</link>
      <description>&lt;P&gt;I checked out spath: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Maybe I'm missing something fundamental, but all that seems to do is extract the nested JSON into another field containing a single string of text. That doesn't help. Here's what I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=test path=message{}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I had hoped it would parse the JSON nested within  'message', but it's not doing that... &lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 16:14:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352619#M64618</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2017-03-13T16:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352620#M64619</link>
      <description>&lt;P&gt;Can you try like this. Use the exact field name in input from  your current output.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath input=message{}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Mar 2017 16:32:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352620#M64619</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-13T16:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352621#M64620</link>
      <description>&lt;P&gt;Tried that, but no change... doesn't appear to do anything. &lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 17:50:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352621#M64620</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2017-03-13T17:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352622#M64621</link>
      <description>&lt;P&gt;Something like this works for me (based on sample value for message field, everything except the last line is to generate sample data).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval message="{\"invalidPublication\":\"Publication is valid for indexing at Elasticsearch and will be updated, but has warnings.\",\"authors\":[{\"lastName\":\"foo\",\"initials\":\"fb\",\"firstName\":\"bar\",\"authorResourceID\":99999}],\"title\":\"Some Title\",\"warningReasons\":[\"Invalid value for 'publicationDate' field [Sat Apr 01 2006 00:00:00 GMT-0500 (EST)], year not found in citation - dateComponents: [{\\\"year\\\":\\\"2008\\\",\\\"month\\\":\\\"6\\\",\\\"day\\\":\\\"2\\\"}].]\"]}" | table message 
| spath input=message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you confirm what's the actual field name under which your json data appears?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 19:00:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352622#M64621</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-13T19:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352623#M64622</link>
      <description>&lt;P&gt;@Branden... While the message JSON structure seems valid, outer JSON seems to be missing proper formatting and commas after each Key Value pairs. Is that how the data looks or is it typo while keying in example here?&lt;/P&gt;

&lt;P&gt;Following data for me loaded successfully as json sourcetype and Splunk was itself able to extract all required field including inner jSON like &lt;STRONG&gt;message.authors{}.authorResourceID&lt;/STRONG&gt;, &lt;STRONG&gt;message.warningReasons{}&lt;/STRONG&gt; and &lt;STRONG&gt;message.invalidPublication&lt;/STRONG&gt; etc.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "level": "warn",
    "message": {
        "invalidPublication": "Publication is valid for indexing at Elasticsearch and will be updated, but has warnings.",
        "authors": [ {
            "lastName": "foo",
            "initials": "fb",
            "firstName": "bar", 
            "authorResourceID": 99999 } ],
        "title": "Some Title",
        "warningReasons": [ "Invalid value for 'publicationDate' field [Sat Apr 01 2006 00:00:00 GMT-0500 (EST)], year not found in citation - dateComponents: [{\"year\":\"2008\",\"month\":\"6\",\"day\":\"2\"}].]" ]
    }, 
     "pid":  "2888", 
     "sourceHostname":  "somehostname.somewhere.com",
     "timestamp":  "2017-03-13 09:55:40" 
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Needless to say, spath is also able to extract the same.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 19:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352623#M64622</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-13T19:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352624#M64623</link>
      <description>&lt;P&gt;It was a copy/paste error. I should have included the raw data in my post, sorry for the confusion. I believe I'm good now, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 19:31:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352624#M64623</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2017-03-13T19:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my nested JSON event not formatted correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352625#M64624</link>
      <description>&lt;P&gt;@Branden, I see that you have voted both Answers by @somesoni2 and me. Please accepted one of these which has helped you or else provide your own answer and accept so that the question is marked as solved.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 04:11:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-nested-JSON-event-not-formatted-correctly/m-p/352625#M64624</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-14T04:11:09Z</dc:date>
    </item>
  </channel>
</rss>

