<?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 Extracting specific JSON field where duplicate exists within array in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331290#M61382</link>
    <description>&lt;P&gt;I have a JSON feed that I'm trying to parse fields in and the event contains fields with identical names but are different based on the "measurementType" field. What search can I run to pull the specific data based on the measurementType? For example, if I do a search spath consumption{}.wNow it will return both 405.878 and -2980.273. I want to be able to pull each out separately. Thank you&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3728i01BBB8FA01A8001E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2017 21:30:02 GMT</pubDate>
    <dc:creator>greatapoc</dc:creator>
    <dc:date>2017-10-23T21:30:02Z</dc:date>
    <item>
      <title>Extracting specific JSON field where duplicate exists within array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331290#M61382</link>
      <description>&lt;P&gt;I have a JSON feed that I'm trying to parse fields in and the event contains fields with identical names but are different based on the "measurementType" field. What search can I run to pull the specific data based on the measurementType? For example, if I do a search spath consumption{}.wNow it will return both 405.878 and -2980.273. I want to be able to pull each out separately. Thank you&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3728i01BBB8FA01A8001E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 21:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331290#M61382</guid>
      <dc:creator>greatapoc</dc:creator>
      <dc:date>2017-10-23T21:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting specific JSON field where duplicate exists within array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331291#M61383</link>
      <description>&lt;P&gt;There is no direct way, since its an array of json objects,  and each field is multivalue field.   You would probably want wNow value along with other values in the same array right?&lt;/P&gt;

&lt;P&gt;Need to break each json object as individual json event and following search helps do that.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;your search |  rex mode=sed "s/^\{\"\w+\"\:\s*\[//g" &lt;BR /&gt;
|  rex mode=sed "s/\]\}$//g" &lt;BR /&gt;
|  rex mode=sed "s/\},\{/}\n{/g" &lt;BR /&gt;
|  multikv noheader=t&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;first line above removes this text from the event &lt;CODE&gt;"{"consumption": [&lt;/CODE&gt;&lt;BR /&gt;
second line removes &lt;CODE&gt;]}&lt;/CODE&gt;&lt;BR /&gt;
third line inserts new line char between each json object in json array.&lt;BR /&gt;
fourth one breaks each line in to separate event.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 00:03:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331291#M61383</guid>
      <dc:creator>kyaparla</dc:creator>
      <dc:date>2017-10-24T00:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting specific JSON field where duplicate exists within array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331292#M61384</link>
      <description>&lt;P&gt;You can create fields at search time with &lt;CODE&gt;eval&lt;/CODE&gt; based on the value of a field by using curly braces.&lt;/P&gt;

&lt;P&gt;So something like this might solve your problem.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval consumption.{measurementType}.wNow = 'consumption.wNow' | table consumption*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Oct 2017 00:57:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-specific-JSON-field-where-duplicate-exists-within/m-p/331292#M61384</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-10-24T00:57:36Z</dc:date>
    </item>
  </channel>
</rss>

