<?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 log JSON to Splunk and optimize for spath? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328160#M60907</link>
    <description>&lt;P&gt;@thomasreggi which "Logging best practices" are you referring too? Can you add detail/link? Is this with respect to the application generating above JSON or Splunk? I think Splunk has no issues with field names in upper case or lower case. Field names should ideally not start with digits or special characters.&lt;/P&gt;

&lt;P&gt;Also for the JSON itself to be valid for &lt;CODE&gt;spath&lt;/CODE&gt; to work automatically, you should have field names also in double quotes as in your first sample JSON. Following is the run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"TIME\":\"2018-01-26 08:17:22.387\",\"UUID\":\"13hiuh312-213e-134j-sdasj-dsadqweq\",\"FILE\":\"main\",\"FN\":\"load\",\"PERSON\":{\"NAME\": \"thomas reggi\", \"AGE\":\"30\"}}"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 Jan 2018 17:23:08 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-01-26T17:23:08Z</dc:date>
    <item>
      <title>How to log JSON to Splunk and optimize for spath?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328158#M60905</link>
      <description>&lt;P&gt;I am looking to reformat my log output. Right now it's pretty messy and does not follow Splunks parsing format.&lt;/P&gt;

&lt;P&gt;What I would like to do is only log a JSON object a string, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"time":"2018-01-26 08:17:22.387","uuid":"13hiuh312-213e-134j-sdasj-dsadqweq","file":"main","fn":"load","message":"Hello World"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or with a nested "Person" JSON object.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"time":"2018-01-26 08:17:22.387","uuid":"13hiuh312-213e-134j-sdasj-dsadqweq","file":"main","fn":"load","person":{"name": "thomas reggi", "age":"30"}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I found in the &lt;A href="http://dev.splunk.com/view/logging/SP-CAAAFCK"&gt;"Logging best practices"&lt;/A&gt; Page that it fields should be all caps and quoted in a totally different format. So I am interested in making the following change.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TIME="2018-01-26 08:17:22.387", UUID="13hiuh312-213e-134j-sdasj-dsadqweq", FILE="main", FN="load", MESSAGE="Hello World"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TIME="2018-01-26 08:17:22.387", UUID="13hiuh312-213e-134j-sdasj-dsadqweq", FILE="main", FN="load", PERSON={"name":"thomas reggi","age":"30"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am curious if I need to have the PERSON JSON object at the enclosed in quotes, and if this is valid.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 15:59:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328158#M60905</guid>
      <dc:creator>thomasreggi</dc:creator>
      <dc:date>2018-01-26T15:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to log JSON to Splunk and optimize for spath?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328159#M60906</link>
      <description>&lt;P&gt;hey i do not think it is a best pratice, rather it would make your search terrible when you want to search for something&lt;BR /&gt;
Try this run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval raw="{\"time\":\"2018-01-26 08:17:22.387\",\"uuid\":\"13hiuh312-213e-134j-sdasj-dsadqweq\",\"file\":\"main\",\"fn\":\"load\",\"person\":{\"name\": \"thomas reggi\", \"age\":\"30\"}}" | spath input=raw | search fn=load | eval ss="\"load\""  | eval test="load" | search test="load"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;suppose if &lt;CODE&gt;fn="load"&lt;/CODE&gt; then you can not write &lt;CODE&gt;|search fn=load&lt;/CODE&gt;..if &lt;CODE&gt;fn=load&lt;/CODE&gt; then you can write both &lt;CODE&gt;fn=load OR fn="load"&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 16:56:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328159#M60906</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-26T16:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to log JSON to Splunk and optimize for spath?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328160#M60907</link>
      <description>&lt;P&gt;@thomasreggi which "Logging best practices" are you referring too? Can you add detail/link? Is this with respect to the application generating above JSON or Splunk? I think Splunk has no issues with field names in upper case or lower case. Field names should ideally not start with digits or special characters.&lt;/P&gt;

&lt;P&gt;Also for the JSON itself to be valid for &lt;CODE&gt;spath&lt;/CODE&gt; to work automatically, you should have field names also in double quotes as in your first sample JSON. Following is the run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"TIME\":\"2018-01-26 08:17:22.387\",\"UUID\":\"13hiuh312-213e-134j-sdasj-dsadqweq\",\"FILE\":\"main\",\"FN\":\"load\",\"PERSON\":{\"NAME\": \"thomas reggi\", \"AGE\":\"30\"}}"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:23:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328160#M60907</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-26T17:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to log JSON to Splunk and optimize for spath?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328161#M60908</link>
      <description>&lt;P&gt;&lt;A href="http://dev.splunk.com/view/logging/SP-CAAAFCK"&gt;http://dev.splunk.com/view/logging/SP-CAAAFCK&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 21:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-JSON-to-Splunk-and-optimize-for-spath/m-p/328161#M60908</guid>
      <dc:creator>thomasreggi</dc:creator>
      <dc:date>2018-01-26T21:24:20Z</dc:date>
    </item>
  </channel>
</rss>

