<?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 extract fields from a JSON map while keeping the relationship? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412949#M73064</link>
    <description>&lt;P&gt;try below in props.conf to extracts fields from JSON data.-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;YourSourcetypeName&amp;gt;]
 KV_MODE=JSON
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Oct 2018 10:27:10 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-10-10T10:27:10Z</dc:date>
    <item>
      <title>How do I extract fields from a JSON map while keeping the relationship?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412948#M73063</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;My stakeholders would like view events in the following JSON map log format, together in one record parsed out into separate fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  "cookie": [{
    "a": 1,
    "b": 1,
    "c": 1
  }, {
    "a": 2,
    "b": 2,
    "c": 2
  }, {
    "a": 3,
    "b": 3,
    "c": 3
  }]
} 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Desired report in Splunk :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;a | b| c (header)
1 1 1
2 2 2
3 3 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to support this in Splunk?&lt;/P&gt;

&lt;P&gt;If there is not an easy way, we can change the log structure.  We wish to keep the information in JSON format, however (structuring log as a long string and regexing is not an option).  &lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 00:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412948#M73063</guid>
      <dc:creator>atjohnso</dc:creator>
      <dc:date>2018-10-10T00:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields from a JSON map while keeping the relationship?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412949#M73064</link>
      <description>&lt;P&gt;try below in props.conf to extracts fields from JSON data.-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;YourSourcetypeName&amp;gt;]
 KV_MODE=JSON
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Oct 2018 10:27:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412949#M73064</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-10-10T10:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields from a JSON map while keeping the relationship?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412950#M73065</link>
      <description>&lt;P&gt;Can you please try below search?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH
| rename cookie{}.* as * 
| eval temp = mvzip(mvzip(c,b),c) 
| stats count by _time temp 
| eval a=mvindex(split(temp,","),0),b=mvindex(split(temp,","),1),c=mvindex(split(temp,","),2) 
| table a b c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{ \"cookie\": [{
\"a\": 1,
\"b\": 1,
\"c\": 1
}, {
\"a\": 2,
\"b\": 2,
\"c\": 2
}, {
\"a\": 3,
\"b\": 3,
\"c\": 3
}]
}" 
| kv 
| rename cookie{}.* as * 
| eval temp = mvzip(mvzip(c,b),c) 
| stats count by _time temp 
| eval a=mvindex(split(temp,","),0),b=mvindex(split(temp,","),1),c=mvindex(split(temp,","),2) 
| table a b c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 15:36:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-extract-fields-from-a-JSON-map-while-keeping-the/m-p/412950#M73065</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-10-10T15:36:41Z</dc:date>
    </item>
  </channel>
</rss>

