<?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: extracting fields from horrible json events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179996#M51815</link>
    <description>&lt;P&gt;ok. Then extract the fields individually.  &lt;/P&gt;

&lt;P&gt;E.g: &lt;BR /&gt;
batch_id\/\":\/\"(?[^\/]+)  ==&amp;gt; will get the value of batch_id and store in the same name.&lt;BR /&gt;
success_total\/\":(?[\d]+)  ==&amp;gt; Will get the value of success_total and store in the same name&lt;/P&gt;

&lt;P&gt;You can be use inline extraction from Splunk field extraction utility and store them. So that you don't need to write these extraction in the search query..&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:05:51 GMT</pubDate>
    <dc:creator>jayannah</dc:creator>
    <dc:date>2020-09-28T18:05:51Z</dc:date>
    <item>
      <title>extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179993#M51812</link>
      <description>&lt;P&gt;So I have some ugly things to deal with.  We will eventually fix the logging, but until that time I am left holding the bag dealing and reporting on this stuff.&lt;/P&gt;

&lt;P&gt;I have example events like the following.  What I need to do is extract each of the "json" elements. However these events are not valid son due to the escape characters in the json.  Splunk's new field extractor took away the ability to identify multiple values and intelligently try and create a regex to match, so that option is gone.  Seeing that a regex for each of these extractions is probably a bit easier to develop than landing someone on Mars, I come to the community for help.&lt;/P&gt;

&lt;P&gt;Ultimately I would like to be able to search for all the events like the following example and click "table" view and have columns for each "json" element.&lt;BR /&gt;
2014-10-29T19:20:36+00:00 DEBUG (7): ERP_SERVICE_CALL:POST:RESPONSE: "{\/"status\/":\/"success\/",\/"code\/":400,\/"data\/":{\/"batch_id\/":\/"M-1331\/",\/"order_total\/":4,\/"success_total\/":0,\/"orders\/":[{\/"order_id\/":\/"1272749\/",\/"status\/":\/"error\/",\/"message\/":\/"order_id: 1272749 \/\/nCode: INVALID_KEY_OR_REF\/\/nDetails: Invalid item reference key. Item value provided: ASB-000219 \/\/nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) \/\/n[no stack trace]\/",\/"customer_internal_id\/":\/"16873\/",\/"customer_id\/":1301051},{\/"order_id\/":\/"1272750\/",\/"status\/":\/"error\/",\/"message\/":\/"order_id: 1272750 \/\/nCode: INVALID_KEY_OR_REF\/\/nDetails: Invalid item reference key. Item value provided: ASB-000219 \/\/nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) \/\/n[no stack trace]\/",\/"customer_internal_id\/":\/"16873\/",\/"customer_id\/":1301051},{\/"order_id\/":\/"1272751\/",\/"status\/":\/"error\/",\/"message\/":\/"order_id: 1272751 \/\/nCode: INVALID_KEY_OR_REF\/\/nDetails: Invalid item reference key. Item value provided: ASB-000219 \/\/nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) \/\/n[no stack trace]\/",\/"customer_internal_id\/":\/"16873\/",\/"customer_id\/":1301051},{\/"order_id\/":\/"1272752\/",\/"status\/":\/"error\/",\/"message\/":\/"order_id: 1272752 \/\/nCode: INVALID_KEY_OR_REF\/\/nDetails: Invalid item reference key. Item value provided: ASB-000219 \/\/nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) \/\/n[no stack trace]\/",\/"customer_internal_id\/":\/"16873\/",\/"customer_id\/":1301051}]}}"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179993#M51812</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2020-09-28T17:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179994#M51813</link>
      <description>&lt;P&gt;Hi, the  JSON syntax is invalid. Please validate your JSON data using any utility available, such as &lt;A href="http://jsonlint.com/"&gt;http://jsonlint.com/&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;So option for you is to extract the required fields using regex or splunk field extraction utility.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 02:48:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179994#M51813</guid>
      <dc:creator>jayannah</dc:creator>
      <dc:date>2014-11-05T02:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179995#M51814</link>
      <description>&lt;P&gt;Uh, I specifically called out it was not valid json.  I need to extract it anyhow, hense the issue.  I cannot change the event.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 02:51:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179995#M51814</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2014-11-05T02:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179996#M51815</link>
      <description>&lt;P&gt;ok. Then extract the fields individually.  &lt;/P&gt;

&lt;P&gt;E.g: &lt;BR /&gt;
batch_id\/\":\/\"(?[^\/]+)  ==&amp;gt; will get the value of batch_id and store in the same name.&lt;BR /&gt;
success_total\/\":(?[\d]+)  ==&amp;gt; Will get the value of success_total and store in the same name&lt;/P&gt;

&lt;P&gt;You can be use inline extraction from Splunk field extraction utility and store them. So that you don't need to write these extraction in the search query..&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:05:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179996#M51815</guid>
      <dc:creator>jayannah</dc:creator>
      <dc:date>2020-09-28T18:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179997#M51816</link>
      <description>&lt;P&gt;Those extractions do not work with those events, editing the regex finds nothing&lt;BR /&gt;
batch_id/":/"(?[^/]+)&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:11:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179997#M51816</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2014-11-05T03:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179998#M51817</link>
      <description>&lt;P&gt;Some problem with editor when saving the rex..&lt;/P&gt;

&lt;P&gt;I saved the rex for you at&lt;BR /&gt;
 &lt;A href="http://regex101.com/r/xI6tN4/1"&gt;http://regex101.com/r/xI6tN4/1&lt;/A&gt; &lt;BR /&gt;
&lt;A href="http://regex101.com/r/pR4kY5/1"&gt;http://regex101.com/r/pR4kY5/1&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://regex101.com/r/pR4kY5/2"&gt;http://regex101.com/r/pR4kY5/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You can use Splunk field extraction utility...&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:18:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179998#M51817</guid>
      <dc:creator>jayannah</dc:creator>
      <dc:date>2014-11-05T03:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179999#M51818</link>
      <description>&lt;P&gt;I am not well versed with json format or what fields to extract. I loaded the sample event you posted to a lookup and broke it almost in to key values. Couldn't proceed due to my lack of knowledge with json. Hope this helps.&lt;/P&gt;

&lt;P&gt;|inputlookup json.csv|rex field=System1 mode=sed "s/[-|.|\"|\/]//g"|makemv delim="," System1|mvexpand System1&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Raghav&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:30:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/179999#M51818</guid>
      <dc:creator>Raghav2384</dc:creator>
      <dc:date>2014-11-05T03:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180000#M51819</link>
      <description>&lt;P&gt;must be a SPlunk bug, I can see your extraction in regex101, but splunk fails to parse that regex to find matches.  Still trying to figure out how Splunk can extract these.&lt;/P&gt;

&lt;P&gt;batch_id\/\":\/\"(?[^\/]+)&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:32:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180000#M51819</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2014-11-05T03:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180001#M51820</link>
      <description>&lt;P&gt;I guess I am not sure how to implement this.  This is a regular indexed event, not a lookup.  I need to parse in real time the elements in the data.  I tried to edit your command in a search argument replacing System1 with _raw, as that is the event data, and nothing extracted for me.&lt;BR /&gt;
|rex field=System1 mode=sed "s/[-|.|"|/]//g"|makemv delim="," System1|mvexpand System1&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180001#M51820</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2014-11-05T03:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180002#M51821</link>
      <description>&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/123iD2979A919DA728FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180002#M51821</guid>
      <dc:creator>Raghav2384</dc:creator>
      <dc:date>2014-11-05T03:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180003#M51822</link>
      <description>&lt;P&gt;Right, instead of |inputlookup, it would be your base search and System1 would be _raw. I just posted a pic as editor doesn't let me type the exact rex.Hope this help&lt;BR /&gt;
Pardon me if i am going tangents.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180003#M51822</guid>
      <dc:creator>Raghav2384</dc:creator>
      <dc:date>2014-11-05T03:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180004#M51823</link>
      <description>&lt;P&gt;Sorry, this still does not work. I get this error when tacking that onto my search string&lt;BR /&gt;
Error in 'SearchParser': Missing a search command before '/'. Error at position '88' of search query 'search index=test3 eventtype=NETSUITE_RESPONSE_ERR...{snipped} {errorcontext = "s/[-|.|"|/]//g"|make}'.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180004#M51823</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2020-09-28T18:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180005#M51824</link>
      <description>&lt;P&gt;Do you mind posting the search?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2014 03:48:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180005#M51824</guid>
      <dc:creator>Raghav2384</dc:creator>
      <dc:date>2014-11-05T03:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180006#M51825</link>
      <description>&lt;P&gt;I saw the missing \'s from your image, and added those, however it still did not extract correctly.  The only thing extracted was&lt;BR /&gt;
20141101T16:01:16+00:00 DEBUG (7): ERP_SERVICE_CALL:POST:RESPONSE: {\status:\success\&lt;/P&gt;

&lt;P&gt;for every event&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:05:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180006#M51825</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2020-09-28T18:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: extracting fields from horrible json events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180007#M51826</link>
      <description>&lt;P&gt;Sure,&lt;/P&gt;

&lt;P&gt;index=test3 eventtype=NETSUITE_RESPONSE_ERROR NOT "restletwrapper)\"|rex field=_raw mode=sed "s/[-|.|\"|\/]//g"|makemv delim="," _raw|mvexpand _raw&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:06:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extracting-fields-from-horrible-json-events/m-p/180007#M51826</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2020-09-28T18:06:00Z</dc:date>
    </item>
  </channel>
</rss>

