<?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: How do you go about formatting a nested JSON that was extracted using the spath command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429105#M122736</link>
    <description>&lt;P&gt;Great answer. I won't be able to test this for a while but I am going to reference it in my future configs.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2018 17:44:24 GMT</pubDate>
    <dc:creator>wsanderstii</dc:creator>
    <dc:date>2018-10-19T17:44:24Z</dc:date>
    <item>
      <title>How do you go about formatting a nested JSON that was extracted using the spath command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429101#M122732</link>
      <description>&lt;P&gt;There all kinds of questions (and not too many answers) about processing nested JSON, either at the source or in search. I have some nested JSON that the &lt;CODE&gt;spath&lt;/CODE&gt; command can extract the fields from, but the display in the Search &amp;amp; Reporting app is still only one JSON level deep. For example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   [-] 
     log:    {"message":"looks like we got no XML document","context":{"status":400,"traceId":"aacb332c-e907-352b-9f8b-a72a55d75cd0","path":"somepath","method":"GET","account_id":1234},"level":200,"level_name":"INFO","channel":"lumen","datetime":{"date":"2018-10-17 20:49:01.839792","timezone_type":3,"timezone":"UTC"},"extra":[]}

     stream:     stdout 
     time:   2018-10-17T20:49:01.841051338Z 
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;spath&lt;/CODE&gt; command successfully extracts the fields in the "log" element, but I'd like to actually see the "log" properly formatted: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "channel": "lumen",
    "context": {
        "account_id": 1234,
        "method": "GET",
        "path": "somepath",
        "status": 400,
 ...etc
      "message": "looks like we got no XML document"
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyway to do this in a search?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 23:12:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429101#M122732</guid>
      <dc:creator>wsanderstii</dc:creator>
      <dc:date>2018-10-17T23:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do you go about formatting a nested JSON that was extracted using the spath command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429102#M122733</link>
      <description>&lt;P&gt;Hi @wsanderstii,&lt;/P&gt;

&lt;P&gt;If you are ingesting this data into Splunk using Splunk Universal Forwarder then can you please try below configuration on your Universal Forwarder?&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yourSourcetype]
INDEXED_EXTRACTIONS = json
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then restart splunk service on splunk universal forwarder.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 09:39:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429102#M122733</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-10-18T09:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do you go about formatting a nested JSON that was extracted using the spath command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429103#M122734</link>
      <description>&lt;P&gt;We do have that set AFAIK. However, a closer look at the raw entry: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"log":"{\"message\":\"\\n\u003c?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?\u003e\\n\u003c!DOCTYPE...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;shows "log" is actually a string and not a JSON. You have to feed it into a formatter without the surrounding quotes.&lt;/P&gt;

&lt;P&gt;That being said, appending "spath input=log" to the query will extract all the fields in the string "log", it just won't pretty print the results.&lt;/P&gt;

&lt;P&gt;I don't think " INDEXED_EXTRACTIONS = json" can account for this without some customization.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 16:18:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429103#M122734</guid>
      <dc:creator>wsanderstii</dc:creator>
      <dc:date>2018-10-18T16:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you go about formatting a nested JSON that was extracted using the spath command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429104#M122735</link>
      <description>&lt;P&gt;Try below configurations on Indexer or Heavy Forwarder whichever comes first from Universal Forwarder and remove &lt;CODE&gt;INDEXED_EXTRACTIONS = json&lt;/CODE&gt; on Universal Forwarder&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yourSourcetype]
SHOULD_LINEMERGE=true
NO_BINARY_CHECK=true
SEDCMD-removeslash=s/(?:\\"|\\\\")/"/g
SEDCMD-removenewline=s/\\\\n//g
TIME_PREFIX="time":\s"
MAX_TIMESTAMP_LOOKAHEAD=30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In above configuration I was not able to parse &lt;CODE&gt;\\n&lt;/CODE&gt; to new line so I have removed that using SEDCMD so you will see long string in &lt;CODE&gt;log.message&lt;/CODE&gt; field without new lines which might look ugly otherwise splunk is extracting all required field which you require based on below sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{ "log":     {\"message\":\"\\n\u003c?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?\u003e\\n\u003c!DOCTYPE\","context":{"status":400,"traceId":"aacb332c-e907-352b-9f8b-a72a55d75cd0","path":"somepath","method":"GET","account_id":1234},"level":200,"level_name":"INFO","channel":"lumen","datetime":{"date":"2018-10-17 20:49:01.839792","timezone_type":3,"timezone":"UTC"},"extra":[]}, "stream": "stdout", "time": "2018-10-17T20:49:01.841051338Z" }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Oct 2018 14:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429104#M122735</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-10-19T14:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do you go about formatting a nested JSON that was extracted using the spath command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429105#M122736</link>
      <description>&lt;P&gt;Great answer. I won't be able to test this for a while but I am going to reference it in my future configs.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 17:44:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429105#M122736</guid>
      <dc:creator>wsanderstii</dc:creator>
      <dc:date>2018-10-19T17:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do you go about formatting a nested JSON that was extracted using the spath command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429106#M122737</link>
      <description>&lt;P&gt;I have converted my comment to answer if it will work for you then you can accept it as answer.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 17:46:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-go-about-formatting-a-nested-JSON-that-was-extracted/m-p/429106#M122737</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-10-19T17:46:55Z</dc:date>
    </item>
  </channel>
</rss>

