<?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 Spath key with period in it in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427932#M122483</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am dealing with a key that has a period in it. I am trying to figure out how to use spath to extract it but I haven't had any luck. Here is an example of what the data would look like:&lt;/P&gt;

&lt;P&gt;Event:&lt;/P&gt;

&lt;P&gt;apples: {&lt;BR /&gt;
   granny.smith: {&lt;BR /&gt;
      color: "green",&lt;BR /&gt;
      crunchy: "true"&lt;BR /&gt;
   }&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;In this case I would like to extract "granny.smith" as a field but I am unable to.&lt;/P&gt;

&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jan 2019 00:46:38 GMT</pubDate>
    <dc:creator>mrstrozy</dc:creator>
    <dc:date>2019-01-25T00:46:38Z</dc:date>
    <item>
      <title>Spath key with period in it</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427932#M122483</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am dealing with a key that has a period in it. I am trying to figure out how to use spath to extract it but I haven't had any luck. Here is an example of what the data would look like:&lt;/P&gt;

&lt;P&gt;Event:&lt;/P&gt;

&lt;P&gt;apples: {&lt;BR /&gt;
   granny.smith: {&lt;BR /&gt;
      color: "green",&lt;BR /&gt;
      crunchy: "true"&lt;BR /&gt;
   }&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;In this case I would like to extract "granny.smith" as a field but I am unable to.&lt;/P&gt;

&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 00:46:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427932#M122483</guid>
      <dc:creator>mrstrozy</dc:creator>
      <dc:date>2019-01-25T00:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Spath key with period in it</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427933#M122484</link>
      <description>&lt;P&gt;@mrstrozy do you need &lt;CODE&gt;granny.smith&lt;/CODE&gt; as a field? It will have a nested JSON in it. Actual fields would be &lt;CODE&gt;granny.smith.color&lt;/CODE&gt; with value &lt;CODE&gt;green&lt;/CODE&gt; as per your data. This should work out of the box. Following is an example based on sample data provided:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="{
    \"apples\": {
        \"granny.smith\": {
                \"color\": \"green\",
                \"crunchy\": \"true\"
            }
        }
    }"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 02:45:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427933#M122484</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-25T02:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Spath key with period in it</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427934#M122485</link>
      <description>&lt;P&gt;First of all, I don't think the formatting is correct. Your field of &lt;CODE&gt;granny.smith&lt;/CODE&gt; should certainly be wrapped by quotes to be read properly (try double quotes). I would recommend using any sort of coding library to help do this for you. But, even if the event data was printed in a proper format, you'd need to extract your fields somehow.&lt;/P&gt;

&lt;P&gt;I would recommend either of two solutions, presuming your event data is completely in JSON format:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Create a custom &lt;EM&gt;sourcetype&lt;/EM&gt; props stanza and specify for KV mode to JSON:&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[sourcetype] &lt;BR /&gt;
KV_MODE = json&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;UL&gt;
&lt;LI&gt;Preferred format as this search extraction will extract for fields from the JSON data consistently reducing need to append to every search query manually&lt;/LI&gt;
&lt;LI&gt;Reference: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Exampleconfigurationsusingfieldtransforms"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Exampleconfigurationsusingfieldtransforms&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;OL&gt;
&lt;LI&gt;Use &lt;EM&gt;spath&lt;/EM&gt; command within your search&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;*SPL* | spath&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;UL&gt;
&lt;LI&gt;This command will pull from the &lt;EM&gt;_raw&lt;/EM&gt; field by default, but you can specify any other field&lt;/LI&gt;
&lt;LI&gt;Reference: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Either way, once you have those fields, how you can reference these fields thereafter, you'll need to use &lt;EM&gt;single quotes&lt;/EM&gt; for any sort of calculated field manipulation. In your case, if if the fields were indeed extracted and you wanted to search against it, here's an SPL query sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main 'granny.apple.color' != "green"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Give that a shot.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 08:51:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Spath-key-with-period-in-it/m-p/427934#M122485</guid>
      <dc:creator>hcanivel_splunk</dc:creator>
      <dc:date>2019-01-29T08:51:41Z</dc:date>
    </item>
  </channel>
</rss>

