Dashboards & Visualizations

Reference token in multiple dashboards

stephensibley
New Member

I have a trellis panel that shows the amount of errors per service. I have created an additional dashboard for each service that has errors. Each dashboard has the same name as the service, so when drilling down the URL is /app/search/$trellis.value$. I am using a custom time token for the master dashboard with the trellis panel.

Is it possible to reference that same custom time token in every drilled down dashboard? Right now, the custom time resets every time you drill down into a dashboard.

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

Hi @stephensibley,

If you have some token that you want to have in most of your dashboard then you can add below dashboard.js in $SPLUNK_HOME/etc/apps/your-app/appserver/static.

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
    ], function(mvc) {
        function setSessionValue(name, value) {
            try {
                if (typeof(localStorage) !== "undefined") {
                    localStorage.setItem(name, value);
                }
            } catch (error) {
                if (error == QUOTA_EXCEEDED_ERR) {
                    console.log("Error: Session Storage limit exceeds.");
                } else {
                    console.log("Error: Saving to session storage.");
                }
            }
        }

        function getSessionValue(name) {
            try {
                if (typeof(localStorage) !== "undefined") {
                    return localStorage.getItem(name);
                }
                return "";
            } catch (error) {
                console.log("Session Storage Error :GET: " + error);
                return "";
            }
        }

        var tokens = mvc.Components.get("default");
        var submitted = mvc.Components.get("submitted");

        token_value = getSessionValue("my_token");
        if(token_value !=""){
            tokens.set("my_token", token_value);
            submitted.set("my_token", token_value);
        }

        # on filter (token) change write function to set value on localStorage
        tokens.on("change:my_token", function(){
            setSessionValue("my_token", tokens.get("my_token");
        }
});

In my case the token name is my_token. No matter which dashboard I go wether I'm doing drilldown or go via navigation panel my_token will always have user selected value. Most importantly you do not require any change to your dashboards, but you might require to clear the browser and Splunk cache and restart the Splunk.

Hope this helps!!!

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...