<?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: Restructure existing Fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Restructure-existing-Fields/m-p/138290#M28435</link>
    <description>&lt;P&gt;This isn't pretty, I'm not sure where you're trying to go with this, and I'm not sure if this is what you had in mind, but...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count | eval _raw = "{\"Foo1\": {\"Bar1\": {\"Key1\": \"Value1a\", \"Key2\": \"Value2a\", \"KeyN\": \"ValueNa\"}}, \"FooN\": {\"BarN\": {\"Key1\": \"Value1b\", \"Key2\": \"Value2b\", \"KeyN\": \"ValueNb\"}}}"
| spath | foreach *.*.*
  [ eval F = mvappend(F, "&amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;")
  | eval B = mvappend(B, "&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;")
  | eval &amp;lt;&amp;lt;MATCHSEG3&amp;gt;&amp;gt; = mvappend('&amp;lt;&amp;lt;MATCHSEG3&amp;gt;&amp;gt;', '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| eval F = mvdedup(F) | eval B = mvdedup(B) | table F B Key*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;yields this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;F     B     Key1     Key2     KeyN
Foo1  Bar1  Value1a  Value2a  ValueNa
FooN  BarN  Value1b  Value2b  ValueNb
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 17 Feb 2015 21:19:09 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2015-02-17T21:19:09Z</dc:date>
    <item>
      <title>Restructure existing Fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Restructure-existing-Fields/m-p/138289#M28434</link>
      <description>&lt;P&gt;I have available json as following&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
{&lt;BR /&gt;
    "Foo1": {&lt;BR /&gt;
        "Bar1": {&lt;BR /&gt;
            "Key1": "Value1",&lt;BR /&gt;
            "Key2": "Value2",&lt;BR /&gt;
            "KeyN": "ValueN"&lt;BR /&gt;
        }&lt;BR /&gt;
    },&lt;BR /&gt;
    "FooN": {&lt;BR /&gt;
        "BarN": {&lt;BR /&gt;
            "Key1": "Value1",&lt;BR /&gt;
            "Key2": "Value2",&lt;BR /&gt;
            "KeyN": "ValueN"&lt;BR /&gt;
        }&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;BR /&gt;
  &lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;If I run this through spath , I get fields like Foo1.Bar1.Key1 with their values.&lt;/P&gt;

&lt;P&gt;How can I split that field name on '.'  to extract individual Fields like &lt;BR /&gt;
 - new field 'F' will have value from Foo1 ... FooN&lt;BR /&gt;
 - new field 'B' will have value from Bar1 ... BarN&lt;BR /&gt;
 - new fields 'Key1' ... 'KeyN' will have values from 'Value1' ... 'ValueN' &lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 00:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Restructure-existing-Fields/m-p/138289#M28434</guid>
      <dc:creator>abhisawa</dc:creator>
      <dc:date>2015-02-17T00:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Restructure existing Fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Restructure-existing-Fields/m-p/138290#M28435</link>
      <description>&lt;P&gt;This isn't pretty, I'm not sure where you're trying to go with this, and I'm not sure if this is what you had in mind, but...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count | eval _raw = "{\"Foo1\": {\"Bar1\": {\"Key1\": \"Value1a\", \"Key2\": \"Value2a\", \"KeyN\": \"ValueNa\"}}, \"FooN\": {\"BarN\": {\"Key1\": \"Value1b\", \"Key2\": \"Value2b\", \"KeyN\": \"ValueNb\"}}}"
| spath | foreach *.*.*
  [ eval F = mvappend(F, "&amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;")
  | eval B = mvappend(B, "&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;")
  | eval &amp;lt;&amp;lt;MATCHSEG3&amp;gt;&amp;gt; = mvappend('&amp;lt;&amp;lt;MATCHSEG3&amp;gt;&amp;gt;', '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| eval F = mvdedup(F) | eval B = mvdedup(B) | table F B Key*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;yields this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;F     B     Key1     Key2     KeyN
Foo1  Bar1  Value1a  Value2a  ValueNa
FooN  BarN  Value1b  Value2b  ValueNb
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Feb 2015 21:19:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Restructure-existing-Fields/m-p/138290#M28435</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-02-17T21:19:09Z</dc:date>
    </item>
  </channel>
</rss>

