<?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: Log with JSON and analyze with spath in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100629#M25995</link>
    <description>&lt;P&gt;Removed underscores, still same problem.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2012 16:39:53 GMT</pubDate>
    <dc:creator>opticsplanet</dc:creator>
    <dc:date>2012-07-17T16:39:53Z</dc:date>
    <item>
      <title>Log with JSON and analyze with spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100627#M25993</link>
      <description>&lt;P&gt;So, I've read an article about Logging best practices: &lt;A href="http://dev.splunk.com/view/SP-CAAADP6"&gt;http://dev.splunk.com/view/SP-CAAADP6&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;One of the recommendations is to write JSON data and use spath to analyze it. I tried that, and I am not getting any results. Here is the event I'm trying to parse:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"utma":"23106789.409091805.1340981149.1340981149.1340981149.1","__utmb":"23106789.4.9.1340982149854","__utmc":"23106789","__utmz":"23106789.1340981149.1.1.utmgclid=CL_38obY87ACFdFsTAodxH1OuQ|utmccn=(not set)|utmcmd=(not set)|utmctr=vortexoptics.com"}&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;. . . | spath - gives me no additional fields.&lt;BR /&gt;
. . . | spath output=var path=utma - gives me an empty var variable on the output.&lt;/P&gt;

&lt;P&gt;What am I missing here?&lt;/P&gt;

&lt;P&gt;EDIT: Updated the event to not contain double underscores for variable names, on a suggestion that those are hidden. Still same result.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2012 00:38:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100627#M25993</guid>
      <dc:creator>opticsplanet</dc:creator>
      <dc:date>2012-07-17T00:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Log with JSON and analyze with spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100628#M25994</link>
      <description>&lt;P&gt;I think your problem is that field names beginning with an underscore (&lt;CODE&gt;_&lt;/CODE&gt;) character in Splunk are hidden from display by default. You actually could use:&lt;/P&gt;

&lt;P&gt;... | spath | eval u=___utma&lt;/P&gt;

&lt;P&gt;to copy the value to a displayed/visible field, or otherwise manipulate it.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2012 01:31:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100628#M25994</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-07-17T01:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Log with JSON and analyze with spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100629#M25995</link>
      <description>&lt;P&gt;Removed underscores, still same problem.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2012 16:39:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100629#M25995</guid>
      <dc:creator>opticsplanet</dc:creator>
      <dc:date>2012-07-17T16:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Log with JSON and analyze with spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100630#M25996</link>
      <description>&lt;P&gt;Ok, figured out the issue. Splunk won't parse out JSON unless the WHOLE event is a JSON object. Or probably starts with JSON code. Otherwise - spath will not work.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 22:34:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100630#M25996</guid>
      <dc:creator>opticsplanet</dc:creator>
      <dc:date>2012-07-26T22:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Log with JSON and analyze with spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100631#M25997</link>
      <description>&lt;P&gt;It can actually, just has to be a field. In your case, you might try spath input=_raw. which is the default, not sure why it's not working&lt;/P&gt;

&lt;P&gt;e.g.&lt;BR /&gt;
Event:&lt;BR /&gt;&lt;BR /&gt;
    blah=monkeys json_field={"foo":"5022","bar":"d062"} quack=typewriter&lt;BR /&gt;&lt;BR /&gt;
    search monkeys | spath input=json_field&lt;BR /&gt;&lt;BR /&gt;
Will give you foo=5022 and bar=d062&lt;/P&gt;

&lt;P&gt;So you could write a regex like&lt;BR /&gt;&lt;BR /&gt;
    &lt;CODE&gt;rex field=_raw "(?&amp;lt;json_field&amp;gt;{.+})"&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
^might need {.+}&lt;BR /&gt;&lt;BR /&gt;
Which should throw everything from the first { to the last } into field json_field&lt;/P&gt;

&lt;P&gt;good luck&lt;/P&gt;

&lt;P&gt;edit: &lt;A href="http://splunk-base.splunk.com/answers/61235/kv_modejson-with-combined-json-textual-loglines"&gt;http://splunk-base.splunk.com/answers/61235/kv_modejson-with-combined-json-textual-loglines&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;
same thing&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2012 21:37:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100631#M25997</guid>
      <dc:creator>afirth</dc:creator>
      <dc:date>2012-10-17T21:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Log with JSON and analyze with spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100632#M25998</link>
      <description>&lt;P&gt;Actually, &lt;CODE&gt;spath&lt;/CODE&gt; should work on a partial event. You need to extract the part of the event that is JSON into a field (you can use &lt;CODE&gt;rex&lt;/CODE&gt;) and then ask &lt;CODE&gt;spath&lt;/CODE&gt; to parse the field.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;yoursearchhere&lt;BR /&gt;
| rex "(?&amp;lt;json_input&amp;gt;regex to create new field)"&lt;BR /&gt;
| spath input=json_input&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;might work, especially if you were only showing a partial event in your question.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 08:22:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Log-with-JSON-and-analyze-with-spath/m-p/100632#M25998</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-02-12T08:22:15Z</dc:date>
    </item>
  </channel>
</rss>

