<?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: Dashboarding from a JSON array. in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289064#M39239</link>
    <description>&lt;P&gt;@cmisztur, I have updated my answer. See if it fits your needs.&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jul 2017 00:56:41 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-07-08T00:56:41Z</dc:date>
    <item>
      <title>Dashboarding from a JSON array.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289061#M39236</link>
      <description>&lt;P&gt;Below is a sample event ingested over HEC and a query.  What I am interested in is creating a dashboard from miner.gpus{}.  I want to dashboard miner.gpus{}.eth, miner.gpus{}.temp, and miner.gpus{}.fan.  The expected miner.gpus{} count is always 8.  &lt;/P&gt;

&lt;P&gt;Is there an easy way to create a gauge for every index in the array?  Or do I have to manually call out the index using mvindex?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://imgur.com/a/TvLxb"&gt;http://imgur.com/a/TvLxb&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="rigs" rig="$miner$"
| spath output=values miner.gpus{}.eth
| eval value=mvindex(values,0) 
| stats min(value) as minimum, max(value) as maximum, latest(value) as current 
| table current, minimum, maximum



{
                  "rig":  "MINER001",
                  "miner":  {
                                "runningTime":  "675",
                                "id":  0,
                                "DCR":  {
                                            "totalHashrate":  "0",
                                            "shares":  "0",
                                            "rejectedShares":  "0",
                                            "poolSwitches":  "0",
                                            "invalidShares":  "0"
                                        },
                                "version":  "9.5 - ETH",
                                "miner":  "claymore",
                                "pools":  [
                                              "us1.ethermine.org:14444"
                                          ],
                                "error":  null,
                                "gpus":  [
                                             {
                                                 "temp":  "83",
                                                 "dcr":  "off",
                                                 "fan":  "71",
                                                 "eth":  "29890",
                                                 "index":  0
                                             },
                                             {
                                                 "temp":  "73",
                                                 "dcr":  "off",
                                                 "fan":  "57",
                                                 "eth":  "29934",
                                                 "index":  1
                                             },
                                             {
                                                 "temp":  "69",
                                                 "dcr":  "off",
                                                 "fan":  "52",
                                                 "eth":  "29940",
                                                 "index":  2
                                             },
                                             {
                                                 "temp":  "74",
                                                 "dcr":  "off",
                                                 "fan":  "59",
                                                 "eth":  "29816",
                                                 "index":  3
                                             },
                                             {
                                                 "temp":  "76",
                                                 "dcr":  "off",
                                                 "fan":  "61",
                                                 "eth":  "29813",
                                                 "index":  4
                                             },
                                             {
                                                 "temp":  "77",
                                                 "dcr":  "off",
                                                 "fan":  "63",
                                                 "eth":  "29895",
                                                 "index":  5
                                             },
                                             {
                                                 "temp":  "73",
                                                 "dcr":  "off",
                                                 "fan":  "57",
                                                 "eth":  "30204",
                                                 "index":  6
                                             },
                                             {
                                                 "temp":  "62",
                                                 "dcr":  "off",
                                                 "fan":  "31",
                                                 "eth":  "30103",
                                                 "index":  7
                                             }
                                         ],
                                "isRunning":  true,
                                "ETH":  {
                                            "totalHashrate":  "239598",
                                            "shares":  "2383",
                                            "rejectedShares":  "0",
                                            "poolSwitches":  "0",
                                            "invalidShares":  "0"
                                        }
                            },
                  "event_type":  "heartbeat",
                  "uptime":  40860.5487383,
                  "uptimeUnits":  "seconds"
              }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 01:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289061#M39236</guid>
      <dc:creator>cmisztur</dc:creator>
      <dc:date>2017-07-05T01:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboarding from a JSON array.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289062#M39237</link>
      <description>&lt;P&gt;[Updated] Since your miner.gpus{}.eth field always has 8 elements, I have created a loop of 8 using map command. (PS: map command will be expensive and depending on Splunk settings it might restrict number of times a subsearch may run (by default it is 10)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval counterIdx="0 1 2 3 4 5 6 7"
| makemv counterIdx
| mvexpand counterIdx
| table counterIdx
| map search="search source=\"splunk_answers_551950_json_data.json\" host=\"NiketNilay-PC\" sourcetype=\"_json\"
              | rename miner.gpus{}.eth as values
              | eval value=mvindex(values,$counterIdx$)
              | stats min(value) as minimum, max(value) as maximum, latest(value) as current 
              | table current, minimum, maximum"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please see if this works, I have tested with the data you have provided. If the query is running too slow or not returning the desired result we might have to come up with different approach.&lt;/P&gt;

&lt;P&gt;PS: Please take out/mask actual site/port name from jSON Data.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;@cmisztur, if you need only the first value you can directly traverse to the same using 0 as index.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=values miner.gpus{0}.eth
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 11:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289062#M39237</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-05T11:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboarding from a JSON array.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289063#M39238</link>
      <description>&lt;P&gt;I need to traverse all indexes.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:38:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289063#M39238</guid>
      <dc:creator>cmisztur</dc:creator>
      <dc:date>2017-07-06T01:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboarding from a JSON array.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289064#M39239</link>
      <description>&lt;P&gt;@cmisztur, I have updated my answer. See if it fits your needs.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2017 00:56:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Dashboarding-from-a-JSON-array/m-p/289064#M39239</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-08T00:56:41Z</dc:date>
    </item>
  </channel>
</rss>

