<?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: Can I create a field transformation using a JSON source key? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80287#M16529</link>
    <description>&lt;P&gt;I was wrong. KV_MODE = json solved it. No need for the| kv reload=t trick&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jun 2018 08:23:30 GMT</pubDate>
    <dc:creator>mikaelbje</dc:creator>
    <dc:date>2018-06-25T08:23:30Z</dc:date>
    <item>
      <title>Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80280#M16522</link>
      <description>&lt;P&gt;I don't seem to be able to set up a field transformation using a Source Key that comes from a JSON event field.&lt;/P&gt;

&lt;P&gt;I have events like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  "time": "2013-06-23T13:55:37+00:00",
  "handler": "UsersController#index"
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I'd like to extract "UsersController" and "index" from the "handler" field. I have props.conf configured with KV_MODE=json&lt;/P&gt;

&lt;P&gt;I added this transform via the GUI:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[controller_action_transform]
CLEAN_KEYS = 1
MV_ADD = 0
REGEX = (?&amp;lt;controller&amp;gt;.*)#(?&amp;lt;action&amp;gt;.*)
SOURCE_KEY = handler
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and this field extraction:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[json]
REPORT-controller_action_extraction = controller_action_transform
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;however, when I do a query like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=json | table handler controller action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I &lt;STRONG&gt;do&lt;/STRONG&gt; get results for "handler" but &lt;STRONG&gt;don't&lt;/STRONG&gt; get anything for "controller" or "action":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| handler               | controller | action |
-----------------------------------------------
| UsersController#index |            |        |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I change the transform SOURCE_KEY to "_raw" then I &lt;STRONG&gt;do&lt;/STRONG&gt; get results for controller &amp;amp; action (though not exactly correct).&lt;/P&gt;

&lt;P&gt;Also, I &lt;STRONG&gt;can&lt;/STRONG&gt; do an inline "rex" field extraction using the "handler" field and get the correct results.  That is, this works just fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=json | rex field=handler "(?&amp;lt;controller&amp;gt;.*)#(?&amp;lt;action&amp;gt;.*)" | table handler controller action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I doing something wrong with the transform?  Are JSON-extracted fields not available for use in transforms or something?&lt;/P&gt;

&lt;P&gt;(NOTE:  The above is just some sample data I created for testing this out.  The real logs that I need to use this on have more data and nested keys and so forth, so a workaround that involves &lt;EM&gt;not&lt;/EM&gt; using the extracted JSON fields would be pretty non-ideal.)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80280#M16522</guid>
      <dc:creator>Jordan_Brough</dc:creator>
      <dc:date>2020-09-28T14:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80281#M16523</link>
      <description>&lt;P&gt;I got an answer via Splunk Support.&lt;/P&gt;

&lt;P&gt;They said:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;I was able to repro. And this is a bug.&lt;BR /&gt;&lt;BR /&gt;
If not using the SOURCE_KEY then extractions are working.&lt;BR /&gt;&lt;BR /&gt;
When referring a field that was extracted using KV_MODE = json, it is not working.  &lt;/P&gt;

&lt;P&gt;I was able to find an already existing issue for that bug.&lt;BR /&gt;&lt;BR /&gt;
It's SPL-61046 and will probably fix in the next major release. (not maintenance release)  &lt;/P&gt;

&lt;P&gt;But there is a workaround to get it working.&lt;BR /&gt;&lt;BR /&gt;
Use the search like:&lt;BR /&gt;&lt;BR /&gt;
sourcetype=json | kv reload=t | table handler controller action &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I've confirmed that the workaround does solve the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:47:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80281#M16523</guid>
      <dc:creator>Jordan_Brough</dc:creator>
      <dc:date>2020-09-28T14:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80282#M16524</link>
      <description>&lt;P&gt;I was just curious if the referenced SPL-61046 issue was ever resolved? I am trying to do something very similar to the OP and having the same issue. I'm able to get around it by using a regex match on the _raw data, but it would be nice to be able to define the SOURCE_KEY for the JSON data.&lt;/P&gt;

&lt;P&gt;(Also, if there is somewhere that I can view details about the referenced SPL issue, please let me know)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:59:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80282#M16524</guid>
      <dc:creator>apringle</dc:creator>
      <dc:date>2020-09-29T06:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80283#M16525</link>
      <description>&lt;P&gt;3 years on I am still seeing this issue.&lt;/P&gt;

&lt;P&gt;Does anyone know at what point JSON fields are extracted?&lt;/P&gt;

&lt;P&gt;It appears to be after custom transforms.conf configs.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 03:48:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80283#M16525</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2016-08-17T03:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80284#M16526</link>
      <description>&lt;P&gt;Got the same issue, doing the transformation on the _raw seems to be the only solution. But is is not perfect as the escaped character in the JSON value are not displayed correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 00:46:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80284#M16526</guid>
      <dc:creator>regiteric</dc:creator>
      <dc:date>2017-01-05T00:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80285#M16527</link>
      <description>&lt;P&gt;I ping'ed my splunk support rep today and was told:&lt;/P&gt;

&lt;P&gt;"The bug was closed with "cannot reproduce" this past October. The original issue was reported for 4.1.3 and 5.0.1.&lt;/P&gt;

&lt;P&gt;That said, Splunk is particular about the JSON. Extraneous and/or incorrect delimiters will cause extraction to fail. Additionally, you should set KV_MODE=none if you are using INDEXED_EXTRACTIONS=json, otherwise data will be duplicated."&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:20:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80285#M16527</guid>
      <dc:creator>vliggio</dc:creator>
      <dc:date>2020-09-29T12:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80286#M16528</link>
      <description>&lt;P&gt;I'm also trying to get this working. The only way I got it working was using the | kv reload=t trick. I tried both with KV_MODE = json and with the default. Data is ingested using the HTTP Event Collector.&lt;/P&gt;

&lt;P&gt;Splunk 7.1.0. SPL-61046 should be reopened IMHO&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 08:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80286#M16528</guid>
      <dc:creator>mikaelbje</dc:creator>
      <dc:date>2018-06-25T08:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a field transformation using a JSON source key?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80287#M16529</link>
      <description>&lt;P&gt;I was wrong. KV_MODE = json solved it. No need for the| kv reload=t trick&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 08:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-create-a-field-transformation-using-a-JSON-source-key/m-p/80287#M16529</guid>
      <dc:creator>mikaelbje</dc:creator>
      <dc:date>2018-06-25T08:23:30Z</dc:date>
    </item>
  </channel>
</rss>

