<?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: Parse JSON series data into a chart in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357588#M65297</link>
    <description>&lt;P&gt;I was so close and yet so far.  This absolutely solved my issue and since this is the format I get from multiple API calls, it solves a bunch of future issues as well.  Thank you!!&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2017 15:55:15 GMT</pubDate>
    <dc:creator>jercra</dc:creator>
    <dc:date>2017-05-04T15:55:15Z</dc:date>
    <item>
      <title>Parse JSON series data into a chart</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357586#M65295</link>
      <description>&lt;P&gt;I'm trying to parse the following JSON data into a timechart "by label".  The "data" section is a timestamp and a value.  I've managed to get each series into its own event but I can't seem to get anything parse to below the series level;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  "9": {
    "series": [
      {
        "label": "content",
        "data": [
          [
            1493673985000,
            10
          ],
          [
            1493673990000,
            10
          ],
          [
            1493673995000,
            10
          ]
        ]
      },
      {
        "label": "filters",
        "data": [
          [
            1493673985000,
            3
          ],
          [
            1493673990000,
            3
          ],
          [
            1493673995000,
            3
          ]
        ]
      },
      {
        "label": "total",
        "data": [
          [
            1493673985000,
            14
          ],
          [
            1493673990000,
            14
          ],
          [
            1493673995000,
            14
          ]
        ]
      }
    ]
  }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By using &lt;CODE&gt;| spath output=series path="9.series{}"&lt;/CODE&gt; I'm able to get the each series split into an event.  I think I just need to extract label, mvzip it with data{0} and data{1} and then mvexpand that but I can't seem to find the syntax that works for that.  In then I'd like something that allows me to do something like &lt;CODE&gt;| eval _time=timestamp| timechart max(value) by label&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 21:42:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357586#M65295</guid>
      <dc:creator>jercra</dc:creator>
      <dc:date>2017-05-01T21:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Parse JSON series data into a chart</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357587#M65296</link>
      <description>&lt;P&gt;You're right, it was remarkably ugly to extract that nested array.  IMHO, &lt;CODE&gt;path=....data&lt;/CODE&gt; should have copied the whole array of arrays to the output field, and it didn't.  &lt;CODE&gt;path=....data{}{}&lt;/CODE&gt; just dumped them all into a single-dimensional array and lost which was which.  So, here's your code.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval _raw="{ \"9\": {\"series\": [ {\"label\": \"content\" , \"data\": [ [ 1493673985000, 10 ] , [ 1493673990000, 11 ] , [ 1493673995000, 12 ]  ] }, {\"label\": \"filters\" , \"data\": [ [ 1493673985000, 3 ] , [ 1493673990000, 1 ] , [ 1493673995000, 3 ]  ] }, {\"label\": \"total\" , \"data\": [ [ 1493673985000, 14 ] , [ 1493673990000, 14 ] , [ 1493673995000, 17 ]  ] } ] } }" | eval junk="{\"data\": [ [ 1493673985000, 10 ] , [ 1493673990000, 10 ] , [ 1493673995000, 10 ] ] }"
| rename COMMENT as "The above just enters your sample data"

| spath input=_raw output=series path=9.series{}
| table series
| mvexpand series
| spath input=series output=label path=label
| spath input=series output=datatime path=data{}{0}
| spath input=series output=datavalue path=data{}{1}
| eval values=mvzip(datatime,datavalue,"=")
| mvexpand values
| rex field=values "(?&amp;lt;time&amp;gt;[^=]+)=(?&amp;lt;value&amp;gt;\d+)"
| eval _time = time/1000
| table _time label value
| timechart span=5s avg(value) by label
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 May 2017 00:53:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357587#M65296</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-04T00:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Parse JSON series data into a chart</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357588#M65297</link>
      <description>&lt;P&gt;I was so close and yet so far.  This absolutely solved my issue and since this is the format I get from multiple API calls, it solves a bunch of future issues as well.  Thank you!!&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 15:55:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parse-JSON-series-data-into-a-chart/m-p/357588#M65297</guid>
      <dc:creator>jercra</dc:creator>
      <dc:date>2017-05-04T15:55:15Z</dc:date>
    </item>
  </channel>
</rss>

