<?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: Differentiate JSON event with multiple fields with the same name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545586#M154575</link>
    <description>&lt;P&gt;Works perfectly, thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 26 Mar 2021 12:59:59 GMT</pubDate>
    <dc:creator>mlovasco</dc:creator>
    <dc:date>2021-03-26T12:59:59Z</dc:date>
    <item>
      <title>Differentiate JSON event with multiple fields with the same name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545511#M154530</link>
      <description>&lt;P&gt;Hello - I have JSON events that have multiple items nested inside them.&amp;nbsp; Each item has fields with the same name.&amp;nbsp; I'm trying to report with stats and timechart on specifically "lastvalue_raw" for each "sensor" however when trying a few different things my query still chooses the first "lastvalue_raw" for any of the sensors.&amp;nbsp; The JSON event could have any number of nested items within it depending on the type of sensor.&amp;nbsp; Below is an example event:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "prtg-version":  "21.1.65.1767",
    "treesize":  2,
    "sensor":  [
                   {
                       "device":  "Colo Palo Alto FW1",
                       "device_raw":  "Colo Palo Alto FW1",
                       "objid":  8219,
                       "objid_raw":  8219,
                       "sensor":  "Comcast (1Gbit/s - Circuit ID)",
                       "sensor_raw":  "Comcast (1Gbit/s - Circuit ID)",
                       "status":  "Unusual",
                       "status_raw":  10,
                       "lastvalue":  "37 Mbit/s",
                       "lastvalue_raw":  4637266.8945
                   },
                   {
                       "device":  "Colo Palo Alto FW1",
                       "device_raw":  "Colo Palo Alto FW1",
                       "objid":  33904,
                       "objid_raw":  33904,
                       "sensor":  "Verizon Business (1Gbit/s - Circuit ID)",
                       "sensor_raw":  "Verizon Business (1Gbit/s - Circuit ID)",
                       "status":  "Up",
                       "status_raw":  3,
                       "lastvalue":  "163 Mbit/s",
                       "lastvalue_raw":  20343218.0333
                   }
               ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is an example of a query I have tried to separate them:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=prtg_test sourcetype=_json 
| spath 
| rename "sensor{}.lastvalue_raw" AS lastvalue, "sensor{}.sensor" AS sensor 
| timechart span=1m latest(lastvalue) by sensor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 12:59:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545511#M154530</guid>
      <dc:creator>mlovasco</dc:creator>
      <dc:date>2021-03-26T12:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate JSON event with multiple fields with the same name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545517#M154534</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223809"&gt;@mlovasco&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Fields &lt;STRONG&gt;lastvalue&lt;/STRONG&gt; and &lt;STRONG&gt;sensor&lt;/STRONG&gt; are multivalue fields. You need to expand them before using timechart/stats command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=prtg_test sourcetype=_json 
| spath 
| rename "sensor{}.lastvalue_raw" AS lastvalue, "sensor{}.sensor" AS sensor 
| eval mzip=mvzip(sensor, lastvalue, "&amp;amp;") 
| mvexpand mzip 
| eval mzip=split(mzip, "&amp;amp;"), sensor=mvindex(mzip, 0), lastvalue=mvindex(mzip, 1) 
| timechart span=1m latest(lastvalue) by sensor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, a like would be appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 06:05:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545517#M154534</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-03-26T06:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate JSON event with multiple fields with the same name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545586#M154575</link>
      <description>&lt;P&gt;Works perfectly, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 12:59:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Differentiate-JSON-event-with-multiple-fields-with-the-same-name/m-p/545586#M154575</guid>
      <dc:creator>mlovasco</dc:creator>
      <dc:date>2021-03-26T12:59:59Z</dc:date>
    </item>
  </channel>
</rss>

