<?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: JSON parsing error in the universal forwarder in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333943#M61757</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/45400"&gt;@vegerlandecs&lt;/a&gt; Hi, I have a usecase just opposite of you.&lt;BR /&gt;
My use case is:&lt;/P&gt;

&lt;P&gt;I am using splunk universal forwarder to forward logs. And I am able to send the logs to Splunk. I would like to parse the logs by breaking them into multiple lines as below&lt;/P&gt;

&lt;P&gt;Now I am getting my log as&lt;BR /&gt;
{ [-]&lt;BR /&gt;
log: {someinformation of appication here {msg"a":"1","b":"2","c":"3","d":"4"&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;I want my log to be appear as&lt;BR /&gt;
so i want to extract the field so that it should appear as below in the splunk ui&lt;/P&gt;

&lt;P&gt;{ [-]&lt;BR /&gt;
log: {someinformation of appication here {msg-"a":"1","b":"2","c":"3","d":"4"}&lt;BR /&gt;
}&lt;BR /&gt;
msg-{&lt;BR /&gt;
a:1&lt;BR /&gt;
b:2&lt;BR /&gt;
c:3&lt;BR /&gt;
d:4&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;I am adding below lines in props.conf&lt;/P&gt;

&lt;P&gt;[Sourcetype]&lt;BR /&gt;
CHARSET=UTF-8&lt;BR /&gt;
SHOULD_LINEMERGE=false&lt;BR /&gt;
NO_BINARY_CHECK = true&lt;/P&gt;

&lt;H1&gt;remove docker json wrapper, then remove escapes from the quotes in the log message.&lt;/H1&gt;

&lt;P&gt;SEDCMD-1_unjsonify = s/{"log":"(?:\u[0-9]+)?(.?)\n","stream./\1/g&lt;BR /&gt;
SEDCMD-2_unescapequotes = s/\"/"/g&lt;/P&gt;

&lt;H1&gt;another exprimental version of the sed.&lt;/H1&gt;

&lt;H1&gt;SEDCMD-1_unjsonify = s/{"log":"(?:\u[0-9]+)?(.)\n","stream.?([\n\r])/\1\2/g&lt;/H1&gt;

&lt;P&gt;category = Custom&lt;BR /&gt;
disabled = false&lt;BR /&gt;
pulldown_type = true&lt;BR /&gt;
TRUNCATE=150000&lt;BR /&gt;
TZ=UTC&lt;/P&gt;

&lt;P&gt;Can we do on forwarder side?. &lt;BR /&gt;
Any help is appreciated.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:07:22 GMT</pubDate>
    <dc:creator>vj5</dc:creator>
    <dc:date>2020-09-29T20:07:22Z</dc:date>
    <item>
      <title>JSON parsing error in the universal forwarder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333941#M61755</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm getting errors with parsing of json files in the universal forwarder.&lt;BR /&gt;
I'm generating json outputs - a new file is generated every time a run a routine. Output has the below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[
    {
    "datetime":"2017-10-25 14:33:16+01:00",
    "user":"",
    "category":"ST",
    "type":"ABC",
    "frontend":"3.0",
    "backend":"",
    "r_version":"",
    "b_version":"",
    "status":"R",
    "next_planned_r_version":"",
    "next_planned_b_version":"",
    "comment":""
  }
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk forwarder gives me the following log entries in &lt;EM&gt;splunkd.log&lt;/EM&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10-25-2017 14:33:16.273 +0100 ERROR JsonLineBreaker - JSON StreamId:16742053991537090041 had parsing error:Unexpected character: ':' - data_source="/root/status-update/environment_health_status_50.json", data_host="hostxyz", data_sourcetype="_json"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The line above repeats about the same number of lines with ":" in the output. Then lines below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10-25-2017 14:33:16.273 +0100 ERROR JsonLineBreaker - JSON StreamId:16742053991537090041 had parsing error:Unexpected character: '}' - data_source="/root/status-update/environment_health_status_50.json", data_host="hostxyz", data_sourcetype="_json"
10-25-2017 14:33:16.273 +0100 ERROR JsonLineBreaker - JSON StreamId:16742053991537090041 had parsing error:Unexpected character: ']' - data_source="/root/status-update/environment_health_status_50.json", data_host="hostxyz", data_sourcetype="_json"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried universal forwarders versions 7.0 and 6.5.3.&lt;/P&gt;

&lt;P&gt;I've been trying to isolated the root cause but had no luck with that - even without changing anything. Sometimes it goes fine, but mostly it doesn't. If I stop splunk, erase fishbucket and start it again, it will ingest all files just fine. However, when I run my test afterwards that is creating new files, it will fail. (or not, as I explained).&lt;/P&gt;

&lt;P&gt;monitor in inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///root/status-update/environment_health_status_*.json]
index=dev_test
sourcetype=_json
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;_json stanza on the forwarder by using btool:&lt;BR /&gt;
 &lt;EM&gt;PS:&lt;/EM&gt; I haven't made any config in props.conf, only inputs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   [_json]
    ANNOTATE_PUNCT = True
    AUTO_KV_JSON = true
    BREAK_ONLY_BEFORE =
    BREAK_ONLY_BEFORE_DATE = True
    CHARSET = UTF-8
    DATETIME_CONFIG = /etc/datetime.xml
    HEADER_MODE =
    INDEXED_EXTRACTIONS = json
    KV_MODE = none
    LEARN_MODEL = true
    LEARN_SOURCETYPE = true
    LINE_BREAKER_LOOKBEHIND = 100
    MATCH_LIMIT = 100000
    MAX_DAYS_AGO = 2000
    MAX_DAYS_HENCE = 2
    MAX_DIFF_SECS_AGO = 3600
    MAX_DIFF_SECS_HENCE = 604800
    MAX_EVENTS = 256
    MAX_TIMESTAMP_LOOKAHEAD = 128
    MUST_BREAK_AFTER =
    MUST_NOT_BREAK_AFTER =
    MUST_NOT_BREAK_BEFORE =
    SEGMENTATION = indexing
    SEGMENTATION-all = full
    SEGMENTATION-inner = inner
    SEGMENTATION-outer = outer
    SEGMENTATION-raw = none
    SEGMENTATION-standard = standard
    SHOULD_LINEMERGE = True
    TRANSFORMS =
    TRUNCATE = 10000
    category = Structured
    description = JavaScript Object Notation format. For more information, visit &lt;A href="http://json.org/" target="test_blank"&gt;http://json.org/&lt;/A&gt;
    detect_trailing_nulls = false
    maxDist = 100
    priority =
    pulldown_type = true
    sourcetype =
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:08:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333941#M61755</guid>
      <dc:creator>vegerlandecs</dc:creator>
      <dc:date>2017-10-25T14:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: JSON parsing error in the universal forwarder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333942#M61756</link>
      <description>&lt;P&gt;I finally found what was wrong. The output was being generated like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;echo '[' &amp;gt; $OUTPUT_FILENAME
echo '  ' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "datetime":"'$(date --rfc-3339=seconds)'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "user": "'$username'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "environment_category": "'$environment_category'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "release_type": "'$release_type'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "environment_frontend": "'$environment_frontend'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "environment_backend": "'$environment_backend'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "release_version": "'$release_version'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "branch_version": "'$branch_version'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "status": "'$status'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "next_planned_release_version": "'$next_planned_release_version'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "next_planned_branch_version": "'$next_planned_branch_version'",' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '    "comment": "'$comment'"' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo '  ' &amp;gt;&amp;gt; $OUTPUT_FILENAME
echo ']' &amp;gt;&amp;gt; $OUTPUT_FILENAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Replaced with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;echo ' "datetime":"'$(date --rfc-3339=seconds)'", "user":"'$username'", "environment_category":"'$environment_category'", "release_type":"'$release_type'", "environment_frontend": "'$environment_frontend'", "environment_backend": "'$environment_backend'", "release_version": "'$release_version'", "branch_version": "'$branch_version'", "status": "'$status'", "next_planned_release_version": "'$next_planned_release_version'", "next_planned_branch_version": "'$next_planned_branch_version'", "comment": "'$comment'"' &amp;gt;&amp;gt; $OUTPUT_FILENAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not looking good for humans now, but apparently Splunk didn't like the line breaking (possibly didn't care about square brackets )&lt;BR /&gt;
Now, why json files were indexed fine after restarting Splunk but not the following files during runtime, the question remains.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 11:59:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333942#M61756</guid>
      <dc:creator>vegerlandecs</dc:creator>
      <dc:date>2017-10-27T11:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: JSON parsing error in the universal forwarder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333943#M61757</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/45400"&gt;@vegerlandecs&lt;/a&gt; Hi, I have a usecase just opposite of you.&lt;BR /&gt;
My use case is:&lt;/P&gt;

&lt;P&gt;I am using splunk universal forwarder to forward logs. And I am able to send the logs to Splunk. I would like to parse the logs by breaking them into multiple lines as below&lt;/P&gt;

&lt;P&gt;Now I am getting my log as&lt;BR /&gt;
{ [-]&lt;BR /&gt;
log: {someinformation of appication here {msg"a":"1","b":"2","c":"3","d":"4"&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;I want my log to be appear as&lt;BR /&gt;
so i want to extract the field so that it should appear as below in the splunk ui&lt;/P&gt;

&lt;P&gt;{ [-]&lt;BR /&gt;
log: {someinformation of appication here {msg-"a":"1","b":"2","c":"3","d":"4"}&lt;BR /&gt;
}&lt;BR /&gt;
msg-{&lt;BR /&gt;
a:1&lt;BR /&gt;
b:2&lt;BR /&gt;
c:3&lt;BR /&gt;
d:4&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;I am adding below lines in props.conf&lt;/P&gt;

&lt;P&gt;[Sourcetype]&lt;BR /&gt;
CHARSET=UTF-8&lt;BR /&gt;
SHOULD_LINEMERGE=false&lt;BR /&gt;
NO_BINARY_CHECK = true&lt;/P&gt;

&lt;H1&gt;remove docker json wrapper, then remove escapes from the quotes in the log message.&lt;/H1&gt;

&lt;P&gt;SEDCMD-1_unjsonify = s/{"log":"(?:\u[0-9]+)?(.?)\n","stream./\1/g&lt;BR /&gt;
SEDCMD-2_unescapequotes = s/\"/"/g&lt;/P&gt;

&lt;H1&gt;another exprimental version of the sed.&lt;/H1&gt;

&lt;H1&gt;SEDCMD-1_unjsonify = s/{"log":"(?:\u[0-9]+)?(.)\n","stream.?([\n\r])/\1\2/g&lt;/H1&gt;

&lt;P&gt;category = Custom&lt;BR /&gt;
disabled = false&lt;BR /&gt;
pulldown_type = true&lt;BR /&gt;
TRUNCATE=150000&lt;BR /&gt;
TZ=UTC&lt;/P&gt;

&lt;P&gt;Can we do on forwarder side?. &lt;BR /&gt;
Any help is appreciated.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:07:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/333943#M61757</guid>
      <dc:creator>vj5</dc:creator>
      <dc:date>2020-09-29T20:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: JSON parsing error in the universal forwarder</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/522187#M88179</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/110360"&gt;@vj5&lt;/a&gt;&amp;nbsp; SEDCMD is the kind of option that is not processed by universal forwarders. ref:&amp;nbsp;&lt;A href="https://wiki.splunk.com/Community:HowIndexingWorks" target="_blank"&gt;https://wiki.splunk.com/Community:HowIndexingWorks&lt;/A&gt;, very last image shows as it's part of the typing processor - which only enterprise installations (HF and IDX) will have.&lt;/P&gt;&lt;P&gt;Also, Splunk uses&amp;nbsp;&lt;SPAN&gt;PCRE notation, so \u is not supported.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From the snippets it isn't very clear to me what are you trying to SED, but consider this replacement regex as a start:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SEDCMD-1_unjsonify = s/log:\s+?{.*?{(.*?)}/\1/g&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 08:31:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-parsing-error-in-the-universal-forwarder/m-p/522187#M88179</guid>
      <dc:creator>vegerlandecs</dc:creator>
      <dc:date>2020-09-30T08:31:07Z</dc:date>
    </item>
  </channel>
</rss>

