<?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 parse the following JSON data? in Monitoring Splunk</title>
    <link>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380289#M6469</link>
    <description>&lt;P&gt;Hello @ips_mandar,&lt;/P&gt;

&lt;P&gt;Your sample event does not consist of strict JSON data because of the non-JSON prefix and suffix.&lt;/P&gt;

&lt;P&gt;I suggest you extract the JSON data as a new field and then run spath on this field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourbasesearch
| rex field=_raw "(?&amp;lt;json_data&amp;gt;\{.+\})"
| spath input=json_data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The regex above is defined very broadly. Your sample event is full of strange symbols. So you might want to improve the regular expression.&lt;/P&gt;

&lt;P&gt;Ideally, you would index pure JSON data in Splunk and set the sourcetype to json. This way, the JSON data gets parsed automatically.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Dec 2018 10:32:35 GMT</pubDate>
    <dc:creator>whrg</dc:creator>
    <dc:date>2018-12-24T10:32:35Z</dc:date>
    <item>
      <title>How do you parse the following JSON data?</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380288#M6468</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to parse below json data .Below is one sample event-&lt;BR /&gt;
    Obj&amp;#1;&amp;#4;&amp;#20;abco.codec&amp;#8;null&amp;#22;avro.schema�&amp;#6;{"type":"record","name":"Eventtable","namespace":"abc.cdf.ghi","fields":[{"name":"SequenceNumber","type":"long"},{"name":"Offset","type":"string"},{"name":"EnqueuedTimeUtc","type":"string"},{"name":"SystemProperties","type":{"type":"map","values":["long","double","string","bytes"]}},{"name":"Properties","type":{"type":"map","values":["long","double","string","bytes","null"]}},{"name":"Body","type":["null","bytes"]}]}O��&amp;#7;��&amp;#14;D��&amp;#21;�=XTPO��&amp;#7;��&amp;#14;D��&amp;#21;�=XTP&lt;/P&gt;

&lt;P&gt;I tried &lt;CODE&gt;spath&lt;/CODE&gt; but unable to get success. Can anyone help me to parse this json data&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 09:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380288#M6468</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2018-12-24T09:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse the following JSON data?</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380289#M6469</link>
      <description>&lt;P&gt;Hello @ips_mandar,&lt;/P&gt;

&lt;P&gt;Your sample event does not consist of strict JSON data because of the non-JSON prefix and suffix.&lt;/P&gt;

&lt;P&gt;I suggest you extract the JSON data as a new field and then run spath on this field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourbasesearch
| rex field=_raw "(?&amp;lt;json_data&amp;gt;\{.+\})"
| spath input=json_data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The regex above is defined very broadly. Your sample event is full of strange symbols. So you might want to improve the regular expression.&lt;/P&gt;

&lt;P&gt;Ideally, you would index pure JSON data in Splunk and set the sourcetype to json. This way, the JSON data gets parsed automatically.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 10:32:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380289#M6469</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-24T10:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse the following JSON data?</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380290#M6470</link>
      <description>&lt;P&gt;thanks @whrg&lt;BR /&gt;
it is working at search time..&lt;BR /&gt;
also to work at indextime if I remove all strange symbols before and after json data then simple spath command also might work.&lt;BR /&gt;
Can you please help me to remove all strange symbols before indexing so it can parse the json data at indextime&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 11:16:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380290#M6470</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2018-12-24T11:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse the following JSON data?</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380291#M6471</link>
      <description>&lt;P&gt;Perhaps you could modify the script which produces the log files.  Modify the script that it only produces pure JSON without these headers and footers.&lt;/P&gt;

&lt;P&gt;If that's not feasible, check out this thread: &lt;A href="https://answers.splunk.com/answers/637492/remove-first-part-of-string-before-creating-a-json.html"&gt;Remove first part of string before creating a JSON source type&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;So I would suggest you put something like this in your props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/your/logfile]
SEDCMD-remove_header = s/^.*?\{/{/1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Dec 2018 10:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/How-do-you-parse-the-following-JSON-data/m-p/380291#M6471</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-25T10:53:02Z</dc:date>
    </item>
  </channel>
</rss>

