<?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: Issue with consuming JSON output from shell script in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19442#M2756</link>
    <description>&lt;P&gt;Can someone please help me with this issue ?&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2013 18:48:01 GMT</pubDate>
    <dc:creator>harishgopalan</dc:creator>
    <dc:date>2013-07-31T18:48:01Z</dc:date>
    <item>
      <title>Issue with consuming JSON output from shell script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19441#M2755</link>
      <description>&lt;P&gt;Dear Splunk Dev,&lt;/P&gt;

&lt;P&gt;This is a very fundamental question.&lt;/P&gt;

&lt;P&gt;If I've a shell script that produces a JSON type of output such as {k1:v1,k2:v2,:k3:v3} can I consume it as JSON in Splunk when it is indexed ?&lt;/P&gt;

&lt;P&gt;I tried to check this by doing the following in splunk version : Splunk 5.0.4 build 172409.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Created an app called test_demo&lt;/LI&gt;
&lt;LI&gt;Created an index called test_demo&lt;/LI&gt;
&lt;LI&gt;Created a script data input mapped to the shell script location : /opt/splunk/etc/apps/test_demo/bin/scripts/json_test.sh with output going to test_demo and source type as test_demo.&lt;/LI&gt;
&lt;LI&gt;Created a props.conf at location : /opt/splunk/etc/apps/test_demo/local/ with the following content&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;[test_demo]&lt;BR /&gt;
CHARSET = UTF-8&lt;BR /&gt;
NO_BINARY_CHECK = 1&lt;BR /&gt;
TIME_FORMAT = %a %b %d %H:%M:%S %z %Y&lt;BR /&gt;
TIME_PREFIX = "__time":"&lt;BR /&gt;
MAX_TIMESTAMP_LOOKAHEAD = 150&lt;BR /&gt;
SHOULD_LINEMERGE = false&lt;BR /&gt;
TZ = UTC&lt;BR /&gt;
KV_MODE = json&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Now if I run a search using the index i.e index=test_demo, it doesn't recognize the input as {k1:v1,k2:v2,:k3:v3} instead it shows as one single string.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Could you please help me with this issue ?&lt;/P&gt;

&lt;P&gt;Regards&lt;BR /&gt;
Harish&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:28:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19441#M2755</guid>
      <dc:creator>harishgopalan</dc:creator>
      <dc:date>2020-09-28T14:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with consuming JSON output from shell script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19442#M2756</link>
      <description>&lt;P&gt;Can someone please help me with this issue ?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2013 18:48:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19442#M2756</guid>
      <dc:creator>harishgopalan</dc:creator>
      <dc:date>2013-07-31T18:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with consuming JSON output from shell script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19443#M2757</link>
      <description>&lt;P&gt;Splunk will ingest JSON data, validate its syntax and display in a friendly manner. That is a confirmed assertion so I might to check on the syntax of your JSON string. For instance, consider this screenshot of JSON data indexed into Splunk.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/Untitled1005.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Checking on the sample given, this syntax may not be a pure JSON string.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  k1:v1,
  k2:v2,
  :k3:v3
} 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can check your syntax &lt;A href="http://jsonlint.com/"&gt;JSONLint&lt;/A&gt; if you are unsure. In this case Splunk sees the data and shows it like a text string.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/Untitled1007.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;
This would be the same content with the correct syntax. Notice how Splunk recognizes the JSON syntax and it also finds the fields, two alpha and one numeric.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  {
    "k1": "v1",
    "k2": "v2",
    "k3": 3
  }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/Untitled1006_1.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2013 19:37:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19443#M2757</guid>
      <dc:creator>Gilberto_Castil</dc:creator>
      <dc:date>2013-07-31T19:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with consuming JSON output from shell script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19444#M2758</link>
      <description>&lt;P&gt;Got it Gilberto. Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2013 02:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Issue-with-consuming-JSON-output-from-shell-script/m-p/19444#M2758</guid>
      <dc:creator>harishgopalan</dc:creator>
      <dc:date>2013-08-01T02:23:30Z</dc:date>
    </item>
  </channel>
</rss>

