<?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 to parse json which makes up part of the event in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215655#M42440</link>
    <description>&lt;P&gt;@rkeenan - Did one of the answers below help provide a solution your question? If yes, please click “Accept” below the best answer to resolve this post and upvote anything that was helpful. If no, please leave a comment with more feedback. Thanks.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Jan 2017 19:44:08 GMT</pubDate>
    <dc:creator>aaraneta_splunk</dc:creator>
    <dc:date>2017-01-21T19:44:08Z</dc:date>
    <item>
      <title>How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215649#M42434</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;We have some json being logged via log4j so part of the event is json, part is not.  The log4j portion has the time stamp.  I can use field extractions to get just the json by itself.  The users could then use xmlkv to parse the json but I'm looking for this to be done at index time so the users don't need to do this - any suggestions?  &lt;/P&gt;

&lt;P&gt;Example of logs (all lines are log4j logging json):&lt;BR /&gt;
2017-01-04 00:00:00.981 [log_level] methodName- {"key1":"value1","key2":"value2","key3":"value3"}&lt;BR /&gt;
2017-01-04 00:00:00.984 [log_level] methodName- {"key1":"value1"}&lt;BR /&gt;
2017-01-04 00:00:00.984 [log_level] methodName - {"key1":"value1","key2":"value2"}&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:16:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215649#M42434</guid>
      <dc:creator>rkeenan</dc:creator>
      <dc:date>2020-09-29T12:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215650#M42435</link>
      <description>&lt;P&gt;You can setup automatic key-value pair extraction at search time (index time extraction is costlier, slows indexing process and requires additional space) so that uses have the fields available to them without any inline extractions. Add this to your props.conf/transforms.conf on search heads.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[YourSourceType]
TRANSFORMS-kvextract = jsonextract
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[jsonextract]
REGEX = \"(?&amp;lt;_KEY_1&amp;gt;[A-z0-9]+)\":\"(?&amp;lt;_VAL_1&amp;gt;[^\"]+)\"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:51:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215650#M42435</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-05T20:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215651#M42436</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| &amp;lt;Your Base Search&amp;gt;
| rex field=_raw "\[log_level\] methodName[-|\s]+(?&amp;lt;jsonData&amp;gt;.*)" 
| table _time jsonData _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:53:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215651#M42436</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-05T20:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215652#M42437</link>
      <description>&lt;P&gt;dynamic key names will slow things down even more. Why not indexed_extractions = JSON instead?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 21:22:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215652#M42437</guid>
      <dc:creator>mreynov_splunk</dc:creator>
      <dc:date>2017-01-05T21:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215653#M42438</link>
      <description>&lt;P&gt;It's not pure JSON, pretty sure INDEXED_EXTRACTIONS=json would not work.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 21:33:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215653#M42438</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-05T21:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215654#M42439</link>
      <description>&lt;P&gt;You can use &lt;CODE&gt;spath&lt;/CODE&gt; to extract subfields from json. Try something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt;
| rex "^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d:\d\d\d \[(?P&amp;lt;log_level&amp;gt;\w+\] (?&amp;lt;method&amp;gt;\w+) (?P&amp;lt;my_json&amp;gt;.*)$"
| spath field=my_json path=my_prefix
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will create &lt;CODE&gt;log_level&lt;/CODE&gt;, &lt;CODE&gt;method&lt;/CODE&gt;, &lt;CODE&gt;my_json&lt;/CODE&gt; and the hierarchy of &lt;CODE&gt;my_prefix.*&lt;/CODE&gt; fields (in your cases you'll get &lt;CODE&gt;my_prefix.key_1&lt;/CODE&gt;, &lt;CODE&gt;my_prefix.key_2&lt;/CODE&gt; and &lt;CODE&gt;my_prefix.key_3&lt;/CODE&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:12:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215654#M42439</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2017-01-05T22:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse json which makes up part of the event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215655#M42440</link>
      <description>&lt;P&gt;@rkeenan - Did one of the answers below help provide a solution your question? If yes, please click “Accept” below the best answer to resolve this post and upvote anything that was helpful. If no, please leave a comment with more feedback. Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jan 2017 19:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-json-which-makes-up-part-of-the-event/m-p/215655#M42440</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-01-21T19:44:08Z</dc:date>
    </item>
  </channel>
</rss>

