Dashboards & Visualizations

How token namespaces and initialize tokens help with executing searches in html dashboard?

Mubarish
Path Finder

Hi
I have converted the simple xml dashboard (with form inputs and panel) to html where we can find the code such as

// Create token namespaces
    var urlTokenModel = new UrlTokenModel();
    mvc.Components.registerInstance('url', urlTokenModel);
    var defaultTokenModel = mvc.Components.getInstance('default', {create: true});
    var submittedTokenModel = mvc.Components.getInstance('submitted', {create: true});

    urlTokenModel.on('url:navigate', function() {
        defaultTokenModel.set(urlTokenModel.toJSON());
        if (!_.isEmpty(urlTokenModel.toJSON()) && !_.all(urlTokenModel.toJSON(), _.isUndefined)) {
            submitTokens();
        } else {
            submittedTokenModel.clear();
        }
    });

    // Initialize tokens
    defaultTokenModel.set(urlTokenModel.toJSON());

    var defaultUpdate = {};

    var submitTokens = function() {
        submitTokensSoon(pageLoading);
    };

    var submitTokensSoon = _.debounce(function(replaceState) {
        submittedTokenModel.set(defaultTokenModel.toJSON());
        urlTokenModel.saveOnlyWithPrefix('form\\.', defaultTokenModel.toJSON(), {
            replaceState: replaceState
        });
    });

I have searched in Splunk documentation for the detailed description of each statement, but I cant find any information. Can someone provide a detailed description of each statement and how it helps in executing searches with token values inputs?

Tags (3)
0 Karma

apruneda_splunk
Splunk Employee
Splunk Employee

The documentation mostly covers the way you can use tokens in the Web Framework, but there are a few topics that address how converted HTML dashboards use tokens, and how that token model works:

Walkthrough of the HTML Dashboard Code (TOKENS section)

Token Models

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...