<?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: Issue with using json token as dropdown token in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518951#M34839</link>
    <description>&lt;P&gt;Edit the source of your dashboard form so it is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Choose stocks&amp;lt;/title&amp;gt;
      &amp;lt;input type="multiselect" token="stocks"&amp;gt;
        &amp;lt;label&amp;gt;Select one or more stock&amp;lt;/label&amp;gt;
        &amp;lt;choice value="All"&amp;gt;All&amp;lt;/choice&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;host="Alpaca:Stock" sourcetype=_json
| spath input=_raw 
| head 1 
| fields - _* 
| foreach *.c [ eval name=split("&amp;amp;lt;&amp;amp;lt;MATCHSTR&amp;amp;gt;&amp;amp;gt;","{") | eval stock=mvappend(stock, mvindex(name,0)) | fields stock ]
| mvexpand stock&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;stock&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;stock&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;delimiter&amp;gt;, &amp;lt;/delimiter&amp;gt;
        &amp;lt;default&amp;gt;All&amp;lt;/default&amp;gt;
        &amp;lt;change&amp;gt;
          &amp;lt;eval token="form.stocks"&amp;gt;case(mvcount('form.stocks')=0,"All",mvcount('form.stocks')&amp;amp;gt;1 AND mvfind('form.stocks',"All")&amp;amp;gt;0,"All",mvcount('form.stocks')&amp;amp;gt;1 AND mvfind('form.stocks',"All")=0,mvfilter('form.stocks'!="All"),1==1,'form.stocks')&amp;lt;/eval&amp;gt;
          &amp;lt;eval token="stocks_choice"&amp;gt;if(mvfind('form.stocks',"All")=0,"*.c",$stocks$)&amp;lt;/eval&amp;gt;
        &amp;lt;/change&amp;gt;
      &amp;lt;/input&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;host="Alpaca:Stock" earliest=-1d@d+510m latest=-1d@d+15h
| fields $stocks_choice$
| timechart span=5m values(*{}.c) as *&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query in the choice section adds your stock names to the dropdown. The delimiter put ", " between each selected stock name. The fields in the dashboard query limits the columns to be only the chosen stocks. All will allow all fields through&lt;/P&gt;&lt;P&gt;There may be other ways to filter the fields but see if this works for you&lt;/P&gt;</description>
    <pubDate>Thu, 10 Sep 2020 20:09:48 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2020-09-10T20:09:48Z</dc:date>
    <item>
      <title>Issue with using json token as dropdown token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518917#M34835</link>
      <description>&lt;P&gt;I am polling the Alpaca stock API and getting the following json payload:&lt;/P&gt;&lt;P&gt;{"APPL":[{"t":1599753600,"o":12.72,"h":12.785,"l":12.72,"c":12.785,"v":524}],"AMZN":[{"t":1599753600,"o":13.99,"h":13.99,"l":13.99,"c":13.99,"v":200}],"GOOG":[{"t":1599753600,"o":33.69,"h":33.82,"l":33.69,"c":33.82,"v":3372}],"XOM":[{"t":1599753600,"o":37.67,"h":37.78,"l":37.66,"c":37.76,"v":10404}]}&lt;/P&gt;&lt;P&gt;Splunk is extracting the following fields for example:&lt;/P&gt;&lt;P&gt;XOM{}.c=37.76&lt;BR /&gt;XOM{}.h=37.78&lt;BR /&gt;XOM{}.l=37.66&lt;BR /&gt;XOM{}.o=37.67&lt;BR /&gt;XOM{}.t=1599753600&lt;BR /&gt;XOM{}.v=10404&lt;/P&gt;&lt;P&gt;I'm trying to timechart the different stocks 'c' values from yesterday where 'c' is the changing close value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;host="Alpaca:Stock" earliest=-1d@d+510m latest=-1d@d+15h&lt;BR /&gt;| timechart span=5m values(*{}.c)&lt;BR /&gt;| rename&amp;nbsp;values(APPL{}.c) as APPL values(AMZN{}.c) as AMZN values(GOOG{}.c) as GOOG values(XOM{}.c) as XOM&lt;/P&gt;&lt;P&gt;I would like to add a dropdown select to choose from the various stocks coming in the payload so the timechart panel only displays the selected stock symbol data. I have been having trouble finding a way to either use the stock symbol in the array path or something like&amp;nbsp;click.name2 as the token. the&amp;nbsp; I've tried spath and not having any luck creating a new field to call as a token.&lt;/P&gt;&lt;P&gt;Any help on this is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 16:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518917#M34835</guid>
      <dc:creator>uhaba</dc:creator>
      <dc:date>2020-09-10T16:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using json token as dropdown token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518924#M34836</link>
      <description>&lt;P&gt;As a basic example, you could populate your dropdown from this sort of query&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval event="{\"APPL\":[{\"t\":1599753600,\"o\":12.72,\"h\":12.785,\"l\":12.72,\"c\":12.785,\"v\":524}],\"AMZN\":[{\"t\":1599753600,\"o\":13.99,\"h\":13.99,\"l\":13.99,\"c\":13.99,\"v\":200}],\"GOOG\":[{\"t\":1599753600,\"o\":33.69,\"h\":33.82,\"l\":33.69,\"c\":33.82,\"v\":3372}],\"XOM\":[{\"t\":1599753600,\"o\":37.67,\"h\":37.78,\"l\":37.66,\"c\":37.76,\"v\":10404}]}\n{\"XYZ\":[{\"t\":1599753600,\"o\":12.72,\"h\":12.785,\"l\":12.72,\"c\":12.785,\"v\":524}],\"ABC\":[{\"t\":1599753600,\"o\":13.99,\"h\":13.99,\"l\":13.99,\"c\":13.99,\"v\":200}],\"ASDF\":[{\"t\":1599753600,\"o\":33.69,\"h\":33.82,\"l\":33.69,\"c\":33.82,\"v\":3372}],\"APPL\":[{\"t\":1599753600,\"o\":37.67,\"h\":37.78,\"l\":37.66,\"c\":37.76,\"v\":10404}]}"
| eval event=split(event,"\n")
| mvexpand event
--- above generates some data in event field
| spath input=event
| head 1
| fields - _*
| foreach *.c [ eval name=split("&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;","{") | eval stock=mvappend(stock, mvindex(name,0)) | fields stock ]&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 10 Sep 2020 17:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518924#M34836</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-09-10T17:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using json token as dropdown token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518939#M34837</link>
      <description>&lt;P&gt;Thanks for that! I'm finding it is coming back as one returned value of all the stock symbols. Should I use mvexpand() maybe? When searching this on it's own, I get the field of stock as a mvfield with all the stock symbols returned to the right.&lt;/P&gt;&lt;P&gt;host="Alpaca:Stock" sourcetype=_json&lt;BR /&gt;| spath input=_raw&lt;BR /&gt;| head 1&lt;BR /&gt;| fields - _*&lt;BR /&gt;| foreach *.c [ eval name=split("&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;","{") | eval stock=mvappend(stock, mvindex(name,0)) | fields stock ]&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 17:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518939#M34837</guid>
      <dc:creator>uhaba</dc:creator>
      <dc:date>2020-09-10T17:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using json token as dropdown token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518944#M34838</link>
      <description>&lt;P&gt;So I got your wonderful solution to populate the dropdown. Just needed to add mvexpand at the end.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;host="Alpaca:Stock" sourcetype=_json
| spath input=_raw 
| head 1 
| fields - _* 
| foreach *.c [ eval name=split("&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;","{") | eval stock=mvappend(stock, mvindex(name,0)) | fields stock ]
| mvexpand stock&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could still really use some help working out how to now map those fields to a token in the results from this search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;host="Alpaca:Stock" earliest=-1d@d+510m latest=-1d@d+15h
| timechart span=5m values(*{}.c) as *&lt;/LI-CODE&gt;&lt;P&gt;The search outputs the stock name, which is matched by * above, as the y values in the timechart table. So I need to somehow match the new dynamically populated token list from the search further up against this output. Generally I've done some key=$foo$ but b/c this is coming in as a mv json payload, the relevant stock name is embedded in the field name and I don't think it'll really work. I tried adding a "*{}.c=$close$" and mapped to close and it didn't work.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 19:02:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518944#M34838</guid>
      <dc:creator>uhaba</dc:creator>
      <dc:date>2020-09-10T19:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using json token as dropdown token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518951#M34839</link>
      <description>&lt;P&gt;Edit the source of your dashboard form so it is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Choose stocks&amp;lt;/title&amp;gt;
      &amp;lt;input type="multiselect" token="stocks"&amp;gt;
        &amp;lt;label&amp;gt;Select one or more stock&amp;lt;/label&amp;gt;
        &amp;lt;choice value="All"&amp;gt;All&amp;lt;/choice&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;host="Alpaca:Stock" sourcetype=_json
| spath input=_raw 
| head 1 
| fields - _* 
| foreach *.c [ eval name=split("&amp;amp;lt;&amp;amp;lt;MATCHSTR&amp;amp;gt;&amp;amp;gt;","{") | eval stock=mvappend(stock, mvindex(name,0)) | fields stock ]
| mvexpand stock&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;stock&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;stock&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;delimiter&amp;gt;, &amp;lt;/delimiter&amp;gt;
        &amp;lt;default&amp;gt;All&amp;lt;/default&amp;gt;
        &amp;lt;change&amp;gt;
          &amp;lt;eval token="form.stocks"&amp;gt;case(mvcount('form.stocks')=0,"All",mvcount('form.stocks')&amp;amp;gt;1 AND mvfind('form.stocks',"All")&amp;amp;gt;0,"All",mvcount('form.stocks')&amp;amp;gt;1 AND mvfind('form.stocks',"All")=0,mvfilter('form.stocks'!="All"),1==1,'form.stocks')&amp;lt;/eval&amp;gt;
          &amp;lt;eval token="stocks_choice"&amp;gt;if(mvfind('form.stocks',"All")=0,"*.c",$stocks$)&amp;lt;/eval&amp;gt;
        &amp;lt;/change&amp;gt;
      &amp;lt;/input&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;host="Alpaca:Stock" earliest=-1d@d+510m latest=-1d@d+15h
| fields $stocks_choice$
| timechart span=5m values(*{}.c) as *&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query in the choice section adds your stock names to the dropdown. The delimiter put ", " between each selected stock name. The fields in the dashboard query limits the columns to be only the chosen stocks. All will allow all fields through&lt;/P&gt;&lt;P&gt;There may be other ways to filter the fields but see if this works for you&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 20:09:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/518951#M34839</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-09-10T20:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using json token as dropdown token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/519540#M34882</link>
      <description>&lt;P&gt;This is great! I had to flip the fields to below the timechart command but it's working well!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 18:22:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Issue-with-using-json-token-as-dropdown-token/m-p/519540#M34882</guid>
      <dc:creator>uhaba</dc:creator>
      <dc:date>2020-09-14T18:22:31Z</dc:date>
    </item>
  </channel>
</rss>

