Dashboards & Visualizations

How to set and unset a LOT of tokens together?

zeinstein
Path Finder

Hi,

I have many single value panels on my dashboards (around 35 usually). Clicking on each of these should open up a detailed view for that value in the same dashboard. Is there a way to do it without having to set the token which my details view depends on and unsetting the other 34 for each single value? Not to mention setting up the depends/rejects for each...
Maybe just setting one token based on which single value the user clicked on?

Thanks!

0 Karma

vikashgartner
Loves-to-Learn Lots

@zeinstein were you able to find any good solution for this

0 Karma

Kenshiro70
Path Finder

I did a similar version of this, so I'll share what I did. The use case: I wanted a dropdown of server IDs for newbie users but a direct entry text box for advanced users. The same token did not work: the input tokens all seem to recalculate at the same time. It MIGHT work for a drilldown; you can try two and test.

If not, how I solved it was to have the two inputs feed into a hidden text input field, like so:

    <fieldset submitButton="false">
      <input type="dropdown" token="dropdown_picker" searchWhenChanged="true">
        <label>Either select server OR </label>
        <default></default>
        <search>
          <query>| inputlookup server_list.csv
            | fields + server_name 
            | table server_name</query>
        </search>
        <fieldForValue>server_name</fieldForValue>
        <fieldForLabel>server_name</fieldForLabel>
        <change>
          <condition match="$value$!=&quot;&quot;">
            <set token="form.input_parse">$value$</set>
          </condition>
        </change>
      </input>
      <input type="text" token="text_picker" searchWhenChanged="true">
        <label>Enter Server Name</label>
        <default></default>
        <change>
          <condition match="$value$!=&quot;&quot;">
            <set token="form.input_parse">$value$</set>
          </condition>
        </change>
      </input>
    </fieldset>
<row depends="$dummy_token$">
  <panel>
    <input type="text" token="input_parse" searchWhenChanged="true">
      <default></default>
    </input>
 </panel>
</row>
<search id="serverDataFetch">
  <query>| inputlookup server_list.csv where sever_name="$input_parse$"
        | table server_name datacenter server_type</query>
</search>

Note how I set the form field with "form.field_name" - that seemed to avoid the token conflict.

0 Karma

woodcock
Esteemed Legend

I would have a section to do unset of all tokens make this trigger on any click, followed by the appropriate set token.

0 Karma

vikashgartner
Loves-to-Learn Lots

Do you have a sample code on how we can do this

0 Karma

rjthibod
Champion

This sounds like something would require JS to do efficiently. You would need to share more information about the tokens and dashboards in order to get the most help from the community.

Here is an example JS segment I made for someone else that was doing something similar. They would modify a token called $License$ and then set a token with the prefix "show_token_" and suffix of the value in $License$. All other tokens with the prefix "show_token_" were unset.

var tokens = mvc.Components.get('submitted');
tokens.on("change:License", function(model, value, options) {
  var display_token = undefined;
  var display_value = undefined;

  if (value !== undefined && value.length > 0) {
    display_token = "show_license_" + value;
    display_value = "true";
  }
  var keys = model.keys();
  keys = _(keys).filter(function(k) {return k.indexOf('show_license_') === 0;});
  _(keys).each(function(token) {

    if (token === display_token) {
      model.set(token, display_value);
    } else {
      model.set(token, undefined);
    }
  }
});

rjthibod
Champion

@zeinstein, did this solution work for you?

0 Karma
Get Updates on the Splunk Community!

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...