<?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: extract JSON from a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247337#M73788</link>
    <description>&lt;P&gt;One more step, now it pulls the message out (man, I would have never gotten this far!)&lt;/P&gt;

&lt;P&gt;The other fields are still MIA though &lt;/P&gt;

&lt;P&gt;ssidName, securityPassphrase fields &lt;/P&gt;</description>
    <pubDate>Fri, 26 Aug 2016 00:06:58 GMT</pubDate>
    <dc:creator>dbcase</dc:creator>
    <dc:date>2016-08-26T00:06:58Z</dc:date>
    <item>
      <title>extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247326#M73777</link>
      <description>&lt;P&gt;Hi,  I have data that looks like this&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1767iD8F010C61D2124AF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I'd like to extract the json out of the message field.  I see the spath command and I think that is what I need but I don't quite get how I can use it to see the json fields in the message field.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 22:34:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247326#M73777</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T22:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247327#M73778</link>
      <description>&lt;P&gt;my (failed) search attempt&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=pds2 sourcetype=ucontrol_logs|spath input=message|rename externalRefId AS ID externalRefId.message AS msg|table ID msg
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 22:54:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247327#M73778</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T22:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247328#M73779</link>
      <description>&lt;P&gt;Another failed search attempt&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=pds2 sourcetype=ucontrol_logs|mvexpand message | spath input=message|table externalRefId
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:08:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247328#M73779</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T23:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247329#M73780</link>
      <description>&lt;P&gt;Better look at the message/json field&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'externalRefId':'exr654321','message':'RMA service return 202','serverResponseTimeMs':'136'}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247329#M73780</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T23:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247330#M73781</link>
      <description>&lt;P&gt;another search query.  It looks like spath simply isnt doing anything &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=pds2 sourcetype=ucontrol_logs|spath input=message|stats list(*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;No fields within the message field have been parsed...  Odd..... my head hurts and there is a bloody spot on the wall.......&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:32:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247330#M73781</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T23:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247331#M73782</link>
      <description>&lt;P&gt;Can you try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=pds2 sourcetype=ucontrol_logs|mvexpand message | eval message=replace(message,"'","\"") | spath input=message
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247331#M73782</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-25T23:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247332#M73783</link>
      <description>&lt;P&gt;Well I'll be........   Works like a champ!!!!    So what is that replace command doing that makes it work?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247332#M73783</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T23:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247333#M73784</link>
      <description>&lt;P&gt;except one piece.....  it doesn't extract the message from the json&lt;BR /&gt;
the ones it does extract are&lt;BR /&gt;
list(externalRefId)&lt;BR /&gt;
list(serverResponseTimeMs)&lt;/P&gt;

&lt;P&gt;but this one is missing&lt;BR /&gt;
message":"RMA service return 202"&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:57:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247333#M73784</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T23:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247334#M73785</link>
      <description>&lt;P&gt;something tells me that the message field name and the message field within the JSON are butting heads&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 23:58:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247334#M73785</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-25T23:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247335#M73786</link>
      <description>&lt;P&gt;Could be. The replace in the first query was replacing single quotes with double quotes. Lets add another replace in that to replace message field inside the json data to inner_message.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=pds2 sourcetype=ucontrol_logs|mvexpand message | eval message=replace(replace(message,"'message'","'inner_message'"),"'","\"") | spath input=message
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:02:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247335#M73786</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-26T00:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247336#M73787</link>
      <description>&lt;P&gt;Hmmmm, one other thing the more I look at it&lt;/P&gt;

&lt;P&gt;Here is another json message in the data &lt;CODE&gt;{"externalRefId":"exr654321","message":"input: {"wifiNetwork":{"ssidName":"YOCTO_2.1S9","securityPassphrase":"xxxxxxx"}}"}&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and ssidName, securityPassphrase fields aren't being extracted......   argh&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:03:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247336#M73787</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-26T00:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247337#M73788</link>
      <description>&lt;P&gt;One more step, now it pulls the message out (man, I would have never gotten this far!)&lt;/P&gt;

&lt;P&gt;The other fields are still MIA though &lt;/P&gt;

&lt;P&gt;ssidName, securityPassphrase fields &lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:06:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247337#M73788</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-26T00:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247338#M73789</link>
      <description>&lt;P&gt;It's again json inside json which is causing propblems.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247338#M73789</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-26T00:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247339#M73790</link>
      <description>&lt;P&gt;so the best way to fix is to tell the developer, "HEY!  Don't do that?"  Because, I can do that as he sits upstairs &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;   Plus it would be a bit of fun.... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:10:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247339#M73790</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-26T00:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247340#M73791</link>
      <description>&lt;P&gt;Actually yes.. if possible. Having developer do logging in standard format will avoid all these surprises&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:28:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247340#M73791</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-26T00:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247341#M73792</link>
      <description>&lt;P&gt;I was hoping you would say that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;    If you want to change your comment to an Answer I'll go ahead and accept.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 00:38:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247341#M73792</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-26T00:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: extract JSON from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247342#M73793</link>
      <description>&lt;P&gt;This is not a complete answer but it &lt;EM&gt;DEFINITELY&lt;/EM&gt; will help if you add this just before your &lt;CODE&gt;spath&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=message mode=sed "s/'/\"/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You need to figure out what is/isn't valid &lt;CODE&gt;JSON&lt;/CODE&gt; and then use &lt;CODE&gt;rex&lt;/CODE&gt; to adjust &lt;CODE&gt;message&lt;/CODE&gt; to conformant.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 02:21:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-JSON-from-a-field/m-p/247342#M73793</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-08-26T02:21:10Z</dc:date>
    </item>
  </channel>
</rss>

