<?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: json data extraction further into fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419787#M73968</link>
    <description>&lt;P&gt;Done. Also the suggestion from @tsaikumar009 is also correct. If there is any possibility for you to change the sourcetype to _json that would be better solution.&lt;/P&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 05:50:04 GMT</pubDate>
    <dc:creator>sdchakraborty</dc:creator>
    <dc:date>2019-03-08T05:50:04Z</dc:date>
    <item>
      <title>json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419781#M73962</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;My base search has a field "msg" , that contain below json data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"level":50,"time":1550758285865,"msg":"validate fail {\"isPP\":true,\"name\":\"ValidationError\",\"details\":[{\"message\":\"\\\" ghdsg to kjsd \\\" udnd nsbd at sndj 4 \\",\"path\":[],\"type\":\"hdyn.min\",\"context\":{\"jdhn\":4,\"value\":[{\"id\":0,\"name\":\"Thdaj JHD KJJ \",\"email\":\"abc@xyz.com\",\"phone\":\"1\",\"title\":\"GSTb SK Issue - KJDK JHDJ hours\",\"isSy\":true}],\"label\":\"ghdsg to kjsd\"}}],\"_object\":[{\"id\":0,\"name\":\"Thdaj JHD KJJ \",\"email\":\"abc@xyz.com\",\"phone\":\"1\",\"title\":\"ajsdj  Insdkssue - YTSV working hours\",\"isActive\":SG}],\"isFF\":true,\"isGtsver\":false,\"data\":null,\"output\":{\"statusCode\":400,\"jdjkdjk\":{\"statusCode\":400,\"error\":\"Bad Request\",\"message\":\"\\\"jdjnis jds kdskd \\\" udnd nsbd at sndj 4 items\",\"validation\":{\"source\":\"yejdhi\",\"keys\":[\"\"]}},\"headers\":{}}}","pid":87487,"hostname":"ip-55423-762-232-636.dsdf.jds.ksndkd.ksmd","v":1}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Our requirement is that extracting above &lt;STRONG&gt;json data&lt;/STRONG&gt; into field which are &lt;STRONG&gt;same as Key&lt;/STRONG&gt; in json.&lt;BR /&gt;
eg. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;msg&lt;/CODE&gt;--&amp;gt; &lt;CODE&gt;validate fail&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;isPP&lt;/CODE&gt;--&amp;gt; &lt;CODE&gt;true&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;name&lt;/CODE&gt;--&amp;gt; &lt;CODE&gt;ValidationError&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;statusCode&lt;/CODE&gt;--&amp;gt; &lt;CODE&gt;400&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;hostname&lt;/CODE&gt; --&amp;gt; &lt;CODE&gt;ip-55423-762-232-636.dsdf.jds.ksndkd.ksmd&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;my search query is like below, but it didn't work:&lt;BR /&gt;
host="ITEM-s73365" index="tms_app" sourcetype="tms_transport_app" | spath| rename msg.name as messageName ,msg.details as msgDetails| eval msgDetails = trim(msgDetails,"\")| table _time messageName msgDetails&lt;/P&gt;

&lt;P&gt;Could you please suggest?&lt;BR /&gt;
Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:32:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419781#M73962</guid>
      <dc:creator>dhirendra761</dc:creator>
      <dc:date>2020-09-29T23:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419782#M73963</link>
      <description>&lt;P&gt;Your json event is not well formatted, so it's likely that it is the reason for the &lt;CODE&gt;spath&lt;/CODE&gt; not to work as expected.&lt;/P&gt;

&lt;P&gt;Check a json formatter to see what is wrong there. If for some reason your message really is badly formatted, you may use rex to extract the fields or find a way to format it correctly. If I the message is correct then &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=test "\"msg\":\"(?&amp;lt;msg&amp;gt;[^\{]*).*\"isPP\":(?&amp;lt;isPP&amp;gt;[^\,]*).*\"name\":\"(?&amp;lt;name&amp;gt;[^\"]*).*\"statuscode\":\"(?&amp;lt;statuscode&amp;gt;[^\,]*).*\"hostname\":\"(?&amp;lt;hostname&amp;gt;[^\"]*)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2019 10:24:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419782#M73963</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2019-03-02T10:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419783#M73964</link>
      <description>&lt;P&gt;Hi @tiagofbmm ,&lt;/P&gt;

&lt;P&gt;Sorry for late reply and thanks for your answer. I have formatted my data as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;msg:server notice notification failed 
    {"isJoi":true,
    "name":"NotificationError",
    "details":
        [{
            "message":"\"there is an error\" might be 6 letters",
            "path":[],
            "type":"yetrn.hsnk",
            "context":{
                "tshdi":4,
                "value":
                    [{
                        "id":0,
                        "name":"BHE Camel Lakne",
                        "email":"xyz.abc@abc.com",
                        "phone":"1",
                        "title":"This is text message",
                        "isActive":true
                    }],
                "label":"contacts to save"
                }
        }],
    "_object":
        [{
            "id":0,
            "name":"BHE Camel Lakne",
            "email":"xyz.abc@abc.com",
            "phone":"1",
            "title":"This is text message",
            "isActive":true
        }],
    "isBosom":true,
    "isSrsgver":false,
    "data":null,
    "output":
        {
            "statusCode":400,
            "gstaflsoad":
                {
                "statusCode":400,
                "error":"Bad Request",
                "message":"\"there is an error\" might be 6 letters or 5 words",
                "validation":
                    {
                    "source":"thsgmn",
                    "keys":[""]
                    }
                },
            "headers":{}
        }
    }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could you please suggest How to extract in their respective fields.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 14:10:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419783#M73964</guid>
      <dc:creator>dhirendra761</dc:creator>
      <dc:date>2019-03-05T14:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419784#M73965</link>
      <description>&lt;P&gt;please try to onboard this data with _json as the sourcetype , then you will be able to see all the fields as expected.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 15:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419784#M73965</guid>
      <dc:creator>tsaikumar009</dc:creator>
      <dc:date>2019-03-05T15:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419785#M73966</link>
      <description>&lt;P&gt;Hi Dhirendra,&lt;/P&gt;

&lt;P&gt;you can use rex to extract your fields. I am giving you one example hopefully you will be able to extract as per your need.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base_search
| | rex field=msg "\"message\":\"(?&amp;lt;msg&amp;gt;[^\{]*)\",.*\s*\"path\":(?&amp;lt;path&amp;gt;.*),\s*\"type\":\"(?&amp;lt;type&amp;gt;.*)\",\s*\"context\":{\s*\"tshdi\":(?&amp;lt;context_tshdi&amp;gt;.*),"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 18:14:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419785#M73966</guid>
      <dc:creator>sdchakraborty</dc:creator>
      <dc:date>2019-03-05T18:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419786#M73967</link>
      <description>&lt;P&gt;Hi @sdchakraborty Thanks for your answer.  can you please put your comment in Answer section so that I can accept your answer.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Dhirendra&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 10:39:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419786#M73967</guid>
      <dc:creator>dhirendra761</dc:creator>
      <dc:date>2019-03-07T10:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: json data extraction further into fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419787#M73968</link>
      <description>&lt;P&gt;Done. Also the suggestion from @tsaikumar009 is also correct. If there is any possibility for you to change the sourcetype to _json that would be better solution.&lt;/P&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 05:50:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-data-extraction-further-into-fields/m-p/419787#M73968</guid>
      <dc:creator>sdchakraborty</dc:creator>
      <dc:date>2019-03-08T05:50:04Z</dc:date>
    </item>
  </channel>
</rss>

