<?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 extract fields from an extracted JSON ingested string in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271633#M52150</link>
    <description>&lt;P&gt;Perhaps it's just a typo, but the REGEX string doesn't match the regex used in the SPL query.&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2016 12:26:12 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-05-27T12:26:12Z</dc:date>
    <item>
      <title>How to extract fields from an extracted JSON ingested string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271631#M52148</link>
      <description>&lt;P&gt;I have DNS log format as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;14&amp;gt;May 25 23:59:19 COL02 Windows: {"Level":"4","Channel":"DNS Server","Version":"","Computer":"DC01.ntadmin.local","EventID":"55555","ExecutionThreadID":"","Keywords":"0x80000000000000","ProviderName":"DNS Server","Message":"25/05/2016 11:58:26 PM 0820 PACKET  0000000002F797A0 UDP Snd 172.30.235.30   697d R Q [8385 A DR NXDOMAIN] A      (4)wpad(7)ntadmin(5)local(0)","Opcode":"","TimeCreated":"2016-05-25T13:58:50.000000000Z","EventData":"25/05/2016 11:58:26 PM 0820 PACKET  0000000002F797A0 UDP Snd 172.30.235.30   697d R Q [8385 A DR NXDOMAIN] A      (4)wpad(7)ntadmin(5)local(0)","ExecutionProcessID":"","Task":"0","SecurityUserID":"","EventRecordID":"86253"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I use the following in props.conf and transforms.conf:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[windows]
KV_MODE = JSON
TRANSFORMS-extractJSON = extract-json
TRANSFORMS-win_sourcetype = windows_dns
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract-json]
SOURCE_KEY = _raw
DEST_KEY = _raw
REGEX = ^([^{]+)({.+})$
FORMAT = $2

[windows_dns]
DEST_KEY = MetaData:Sourcetype
REGEX = 55555
FORMAT = sourcetype::windows_dns
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to extract the JSON string to get the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;5/26/16
1:25:40.000 PM  
{ [-] 
    Channel:  DNS Server 
    Computer:  DC01.ntadmin.local 
    EventData:  25/05/2016 11:58:26 PM 0820 PACKET 0000000002F797A0 UDP Snd 172.30.235.30 697d R Q [8385 A DR NXDOMAIN] A (4)wpad(7)ntadmin(5)local(0)
    EventID:  55555 
    EventRecordID:  86253 
    ExecutionProcessID: 
    ExecutionThreadID: 
    Keywords:  0x80000000000000 
    Level:  4 
    Message:  25/05/2016 11:58:26 PM 0820 PACKET 0000000002F797A0 UDP Snd 172.30.235.30 697d R Q [8385 A DR NXDOMAIN] A (4)wpad(7)ntadmin(5)local(0)
    Opcode: 
    ProviderName:  DNS Server 
    SecurityUserID: 
    Task:  0 
    TimeCreated:  2016-05-26T03:21:09.000000000Z 
    Version: 
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which extracts the relevant fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Channel
Computer
EventData 
EventID
EventRecordID
ExecutionProcessID
ExecutionThreadID
Keywords
Level
Message
Opcode
ProviderName
SecurityUserID
Task
TimeCreated
Version
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I now want to further extract fields from the &lt;CODE&gt;EventData&lt;/CODE&gt; field using the following transform:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_EventData]
CLEAN_KEYS = 0
REGEX = ^(?\d\d\/\d\d\/\d\d\d\d)\s(?\d+:\d\d:\d\d\s\w\w)\s(?\d+)\s(?\w+)\s+(?\S+)\s(?\w+)\s(?\w+)\s(?\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(?\S+)\s(?\w*)\s(?\w*)\s\[(?.\S+)\s(?[\w\s]{1,4})\s(?\S+)]\s(?\S+)\s+\(\d+\)(?\S+)$
SOURCE_KEY = EventData
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It doesn't work. I have tested the REGEX using SPL :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=windows_dns  | rex field=EventData "^(?\d\d\/\d\d\/\d\d\d\d)\s(?\d+:\d\d:\d\d\s\w\w)\s(?\d+)\s(?\w+)\s+(?\S+)\s(?\w+)\s(?\w+)\s(?\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(?\S+)\s(?\w*)\s(?\w*)\s\[(?.\S+)\s(?[\w\s]{1,4})\s(?\S+)]\s(?\S+)\s+\(\d+\)(?\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That extracts the relevant EventData fields. I cannot get this to work automatically.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 02:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271631#M52148</guid>
      <dc:creator>jonnim</dc:creator>
      <dc:date>2016-05-27T02:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from an extracted JSON ingested string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271632#M52149</link>
      <description>&lt;P&gt;I know its a bit difficult, but I recommend ingesting json data as json and then following steps outlined in the spath documentation:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;See this answer where I recently learned how to do this on json events for a real world example:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/401942/how-to-parse-my-json-data-with-spath-and-table-the.html"&gt;https://answers.splunk.com/answers/401942/how-to-parse-my-json-data-with-spath-and-table-the.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 12:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271632#M52149</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-27T12:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from an extracted JSON ingested string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271633#M52150</link>
      <description>&lt;P&gt;Perhaps it's just a typo, but the REGEX string doesn't match the regex used in the SPL query.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 12:26:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271633#M52150</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-05-27T12:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from an extracted JSON ingested string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271634#M52151</link>
      <description>&lt;P&gt;You need to update props.conf from this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; TRANSFORMS-extractJSON = extract-json
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; TRANSFORMS-extractJSON = extract-json, extract_EventData
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 23:11:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271634#M52151</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-27T23:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from an extracted JSON ingested string</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271635#M52152</link>
      <description>&lt;P&gt;Just a typo left out the filed names as I was trying something else. Here is the updated SPL. &lt;/P&gt;

&lt;P&gt;rex field=EventData "^(?\d\d\/\d\d\/\d\d\d\d)\s(?\d+:\d\d:\d\d\s\w\w)\s(?\d+)\s(?\w+)\s+(?\S+)\s(?\w+)\s(?\w+)\s(?\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(?\S+)\s(?\w*)\s(?\w*)\s[(?.\S+)\s(?[\w\s]{1,4})\s(?\S+)]\s(?\S+)\s+(\d+)(?\S+)$" &lt;/P&gt;

&lt;P&gt;Woodcock- the &lt;/P&gt;

&lt;P&gt;TRANSFORMS-extractJSON = extract-json, extract_EventData&lt;/P&gt;

&lt;P&gt;Doesn't work - It does not seem to find the EventData filed to extract .. As mentioned before it works during a search but does nit auto extract.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:48:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-an-extracted-JSON-ingested-string/m-p/271635#M52152</guid>
      <dc:creator>jonnim</dc:creator>
      <dc:date>2020-09-29T09:48:30Z</dc:date>
    </item>
  </channel>
</rss>

