<?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 do I get Splunk to extract nested JSON arrays properly? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275623#M83134</link>
    <description>&lt;P&gt;Thanks for your help.  I was finally able to accomplish this using spath &amp;amp; mvexpand.  In case someone else needs this in the future, my search is now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | spath path=systems{} output=x | fields - _raw | fields upTime, type, id, x | mvexpand x | spath input=x | rename admins{} as admins | mvexpand admins | stats count as Count by type, admins
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Feb 2016 17:48:57 GMT</pubDate>
    <dc:creator>lyndac</dc:creator>
    <dc:date>2016-02-09T17:48:57Z</dc:date>
    <item>
      <title>How do I get Splunk to extract nested JSON arrays properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275620#M83131</link>
      <description>&lt;P&gt;I am indexing JSON data.   I need to be able to do stats based "by patches" and "by admin".   I can't get spath or mvexpand to extract the nested arrays properly.  Can anyone help me to figure this out?  &lt;/P&gt;

&lt;P&gt;My props.conf looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ my_json ]
INDEXED_EXTRACTIONS = json
KV_MODE=none
MAX_TIMESTAMP_LOOKAHEAD=30
NO_BINARY_CHECK=true
TIMESTAMP_FIELDS=upTime
TIME_FORMAT=%Y-%m-%d %H:%M:%S
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The data is similar to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  "upTime": "2015-02-08 16:43:23",
  "type": "thetype",
   "id": "123454829",
   "systems": [
      {
          "hostname": "host1",
          "admins": [ "jdoe","lcod", "pamtie"],
          "os": "linux",
          "patches": ["1.2", "2.3", "4.3", "5.4"]
      },
      {
          "hostname": "host2",
          "admins": [ "barry", "patty"],
          "os": "linux",
          "patches": ["2.3", "5.4"]
      }
  ]
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2016 20:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275620#M83131</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-02-08T20:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get Splunk to extract nested JSON arrays properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275621#M83132</link>
      <description>&lt;P&gt;This kind of data is a pain to work with because it requires the uses of mv commands. to extract what you want you need first zip the data you want to pull out.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;…| rename systems{}.hostname as hostname, rename systems{}.patches as patches | eval a mvzip(hostname,patches, "|") | fields _time a | mvexpand a | rex field=a "(?&amp;lt;hostname&amp;gt;[^\|]+)\|(?&amp;lt;patches&amp;gt;[^\|]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need to expand patches just append mvexpand patches to the end.&lt;/P&gt;

&lt;P&gt;I use this method to to extract multilevel deep fields with multiple values.  It does a the limitation of only able to extract two multi valued fields from the data and get very slow with large data sets.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 22:33:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275621#M83132</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2016-02-08T22:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get Splunk to extract nested JSON arrays properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275622#M83133</link>
      <description>&lt;P&gt;Your sample data doesn't look like in proper json format (some keys are not in double quotes) and that should be the reason spath (in search) and &lt;CODE&gt;INDEXED_EXTRACTIONS = json&lt;/CODE&gt; in props.conf is not recognizing array. Check the syntax here &lt;A href="http://pro.jsonlint.com/"&gt;http://pro.jsonlint.com/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 22:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275622#M83133</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-08T22:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get Splunk to extract nested JSON arrays properly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275623#M83134</link>
      <description>&lt;P&gt;Thanks for your help.  I was finally able to accomplish this using spath &amp;amp; mvexpand.  In case someone else needs this in the future, my search is now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | spath path=systems{} output=x | fields - _raw | fields upTime, type, id, x | mvexpand x | spath input=x | rename admins{} as admins | mvexpand admins | stats count as Count by type, admins
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-Splunk-to-extract-nested-JSON-arrays-properly/m-p/275623#M83134</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-02-09T17:48:57Z</dc:date>
    </item>
  </channel>
</rss>

