<?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 additional JSON objects from within my extracted JSON? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260066#M49928</link>
    <description>&lt;P&gt;You can use a regex to extract these fields values if they are not already extracted. Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex field=orderDetails "\w+:(?&amp;lt;acct&amp;gt;[^,]+),\s?\w+(?&amp;lt;name&amp;gt;[^,]+),\s?\w+(?&amp;lt;ip&amp;gt;[^\"]+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Oct 2016 15:59:43 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-10-19T15:59:43Z</dc:date>
    <item>
      <title>How to extract additional JSON objects from within my extracted JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260063#M49925</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I was wondering how to go about extracting additional objects within my extracted JSON.  For example here is a sample of one of my events I'm working with.  Each of these key/value pairs are being extracted into their own fields.  I would like to pull out additional fields by grabbing specific elements from the extracted fields.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "oderNumber": 23994,
    "orderDelay": 120,
    "orderedDate": "2016/03/01 18:47:22",
    "processedDate": "",
    "orderDetails": "Account:11111, AccountName:1111-xxx, OrderIpAddress:1.1.1.1",
    "orderProcessor": "user",
    "orderErrors": "",
    "acknowledgedErrors": "",
    "orderId": {
        "value": 97655
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For example; from the &lt;STRONG&gt;orderDetails&lt;/STRONG&gt; field I would like to extract &lt;STRONG&gt;Account, AccountName and OrderIpAddress&lt;/STRONG&gt; into its own fields.  How can I accomplish this?  &lt;/P&gt;

&lt;P&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 14:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260063#M49925</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-10-19T14:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract additional JSON objects from within my extracted JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260064#M49926</link>
      <description>&lt;P&gt;Are you leveraging indexed_extractions = JSON or using another method?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/Data/Extractfieldsfromfileswithstructureddata"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.0/Data/Extractfieldsfromfileswithstructureddata&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 15:08:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260064#M49926</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2016-10-19T15:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract additional JSON objects from within my extracted JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260065#M49927</link>
      <description>&lt;P&gt;Correct - based on the example data that I pasted each of the key/val pairs are extracted into their own field.  The issue is that I want to further extract key/values from an extracted field.&lt;/P&gt;

&lt;P&gt;example: &lt;BR /&gt;
"orderDetails": "Account:11111, AccountName:1111-xxx, OrderIpAddress:1.1.1.1",&lt;/P&gt;

&lt;P&gt;This is extracted as &lt;BR /&gt;
orderDetails = Account:11111, AccountName:1111-xxx, OrderIpAddress:1.1.1.1&lt;/P&gt;

&lt;P&gt;I would like to extract account, accountName and OrderIpAddress into its own fields&lt;BR /&gt;
Account = 111111&lt;BR /&gt;
AccountName = 1111-xxxx&lt;BR /&gt;
OrderIpAddress = 1.1.1.1&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 15:56:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260065#M49927</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-10-19T15:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract additional JSON objects from within my extracted JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260066#M49928</link>
      <description>&lt;P&gt;You can use a regex to extract these fields values if they are not already extracted. Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex field=orderDetails "\w+:(?&amp;lt;acct&amp;gt;[^,]+),\s?\w+(?&amp;lt;name&amp;gt;[^,]+),\s?\w+(?&amp;lt;ip&amp;gt;[^\"]+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 15:59:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260066#M49928</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-19T15:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract additional JSON objects from within my extracted JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260067#M49929</link>
      <description>&lt;P&gt;I did not have luck using rex with orderDetails, but _raw worked:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw "\"Account\:(?&amp;lt;Account&amp;gt;[^,]+).*Name\:(?&amp;lt;AccountName&amp;gt;[^,]+).*OrderIpAddress\:(?&amp;lt;OrderIpAddress&amp;gt;[^\"]+)"  | Table Account,AccountName,OrderIpAddress,orderDetails
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 16:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260067#M49929</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2016-10-19T16:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract additional JSON objects from within my extracted JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260068#M49930</link>
      <description>&lt;P&gt;See if the following generic option helps.&lt;BR /&gt;
You can ignore everything up to foreach, as this is what I used to replicate your issue in my lab.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count
| eval _raw = "
{
    \"oderNumber\": 23994,
    \"orderDelay\": 120,
    \"orderedDate\": \"2016/03/01 18:47:22\",
    \"processedDate\": \"\",
    \"orderDetails\": \"Account:11111, AccountName:1111-xxx, OrderIpAddress:1.1.1.1\",
    \"orderProcessor\": \"user\",
    \"orderErrors\": \"\",
    \"acknowledgedErrors\": \"\",
    \"orderId\": {
        \"value\": 97655
    }
}
"
| spath
| foreach * [ 
    | eval temp = split('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', ",")
    | eval size = mvcount(temp)
    | mvexpand temp
    | rex field=temp "^(?&amp;lt;key&amp;gt;[^:]+)\s?:\s?(?&amp;lt;value&amp;gt;.+)$"
    | eval {key} = if (size &amp;gt; 1, value, null())
    | fields - key, value, size, temp
]
| stats first(*) as * by _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 16:18:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-additional-JSON-objects-from-within-my-extracted/m-p/260068#M49930</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-19T16:18:29Z</dc:date>
    </item>
  </channel>
</rss>

