<?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 JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190753#M37984</link>
    <description>&lt;P&gt;Hi All&lt;/P&gt;

&lt;P&gt;I have 2 questions.&lt;/P&gt;

&lt;P&gt;Question-1:&lt;BR /&gt;
I wanted to write auto extract KVs from JSON portion of the events.&lt;BR /&gt;
Here is the JSON portion of sample event --&amp;gt; "actionId":47533796,"clientIP":"127.0.0.1","actions":["Action1","Action2","Action3"],"user":"alia",...&lt;/P&gt;

&lt;P&gt;I wrote regex  --&amp;gt;  \"([\w]+)\":([^,}]+)&lt;BR /&gt;&lt;BR /&gt;
Here, the complexity is value type is  sometime array of values with comma separator with variable number of members.&lt;BR /&gt;
So for the key "actions", the above regex gives the values as ["Action1",&lt;BR /&gt;
Since "," is also delimiter for separating JSON KVs, the array value also uses "," as delimiter, hence the problem. &lt;BR /&gt;
how can I  auto extract all the KVs from JSON string for the above case? I want to put in transforms.conf for auto extraction of all the KVs from JSON string.......&lt;BR /&gt;
&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;Question-2:&lt;BR /&gt;
If I want to replace the "," only for array value using SED command, how can I do it?&lt;BR /&gt;
E,g: I want to replace comma delimiter with semi-colon only for the values of array type[a,brrrr,c2,d,ehh,.....,w] with [a;brrrr;c2;d;ehh;....;w]&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jun 2014 01:44:08 GMT</pubDate>
    <dc:creator>jayannah</dc:creator>
    <dc:date>2014-06-06T01:44:08Z</dc:date>
    <item>
      <title>JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190753#M37984</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;

&lt;P&gt;I have 2 questions.&lt;/P&gt;

&lt;P&gt;Question-1:&lt;BR /&gt;
I wanted to write auto extract KVs from JSON portion of the events.&lt;BR /&gt;
Here is the JSON portion of sample event --&amp;gt; "actionId":47533796,"clientIP":"127.0.0.1","actions":["Action1","Action2","Action3"],"user":"alia",...&lt;/P&gt;

&lt;P&gt;I wrote regex  --&amp;gt;  \"([\w]+)\":([^,}]+)&lt;BR /&gt;&lt;BR /&gt;
Here, the complexity is value type is  sometime array of values with comma separator with variable number of members.&lt;BR /&gt;
So for the key "actions", the above regex gives the values as ["Action1",&lt;BR /&gt;
Since "," is also delimiter for separating JSON KVs, the array value also uses "," as delimiter, hence the problem. &lt;BR /&gt;
how can I  auto extract all the KVs from JSON string for the above case? I want to put in transforms.conf for auto extraction of all the KVs from JSON string.......&lt;BR /&gt;
&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;Question-2:&lt;BR /&gt;
If I want to replace the "," only for array value using SED command, how can I do it?&lt;BR /&gt;
E,g: I want to replace comma delimiter with semi-colon only for the values of array type[a,brrrr,c2,d,ehh,.....,w] with [a;brrrr;c2;d;ehh;....;w]&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jun 2014 01:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190753#M37984</guid>
      <dc:creator>jayannah</dc:creator>
      <dc:date>2014-06-06T01:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190754#M37985</link>
      <description>&lt;P&gt;Try this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"([\w]+)":(\[[^\]]+\]|[^,}]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It optionally matches a:[b,c,d] or a:b&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jun 2014 13:56:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190754#M37985</guid>
      <dc:creator>charltones</dc:creator>
      <dc:date>2014-06-06T13:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190755#M37986</link>
      <description>&lt;P&gt;Thanks. 1st question is solved.&lt;/P&gt;

&lt;P&gt;Any idea on 2nd question?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jun 2014 15:11:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190755#M37986</guid>
      <dc:creator>jayannah</dc:creator>
      <dc:date>2014-06-06T15:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190756#M37987</link>
      <description>&lt;P&gt;I'm not sure that the second part is do-able with a regex.  Taking a step back though, have you looked at the spath command (which parses JSON from parts of events).  I did this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count | eval jsonpart="{\"actionId\":47533796,\"clientIP\":\"127.0.0.1\",\"actions\":[\"Action1\",\"Action2\",\"Action3\"],\"user\":\"alia\"}" | spath input=jsonpart
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where I mimic an event where one field contains the json.  spath then does a great job of parsing the json bit.  The array comes out as a multi valued field, the other fields are plain fields in the same event.  Perhaps that will help?&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2014 00:33:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190756#M37987</guid>
      <dc:creator>charltones</dc:creator>
      <dc:date>2014-06-07T00:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190757#M37988</link>
      <description>&lt;P&gt;Hi charltones&lt;/P&gt;

&lt;P&gt;Thanks for the response. Yes, I'm very well aware of spath usage and I have implement the above problem in manual search query. My question is related to config for auto extraction of the JSON portion in the transforms.conf, which you have responded earlier. Thanks again.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2014 01:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190757#M37988</guid>
      <dc:creator>jayannah</dc:creator>
      <dc:date>2014-06-07T01:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: JSON field extraction when portion of the log is JSON format and some values are type array with comma delimeter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190758#M37989</link>
      <description>&lt;P&gt;Ah understood, in that case maybe a scripted input would be a better option?&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/Data/Setupcustominputs"&gt;http://docs.splunk.com/Documentation/Splunk/6.0/Data/Setupcustominputs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You could write some python (or other script) to pre-process the input files and splunk would take the script output as its input.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2014 10:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-field-extraction-when-portion-of-the-log-is-JSON-format-and/m-p/190758#M37989</guid>
      <dc:creator>charltones</dc:creator>
      <dc:date>2014-06-07T10:43:45Z</dc:date>
    </item>
  </channel>
</rss>

