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

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

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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...