Token models

SplunkJS Stack uses a single default token model. For HTML dashboards, two autogenerated token models are defined―a default model and a submitted model. These token models behave as follows:

  • Tokens in the default model are propagated immediately when they change. For example, when a token value is selected from a dropdown list, other options that rely on this token will get these values immediately.
  • Tokens in the submitted model only get updated values when the Search button is clicked, which happens by copying the contents of the default model to the submitted model when a click occurs. For example, let's say you have a search that relies on multiple token values but you don't want the search to be run until all values have been set. Using the submitted model, the user selects multiple options, then clicks a Search button, which updates the token values all at once and then runs the search.

The token model is specified in the constructor of the search manager, view, element, or form input using the tokenNamespace option as follows:

// This search manager uses the "submitted" token model
new SearchManager({
    "id": "search1",
    "search": "index=_internal sourcetype=$sourcetype$ | head $choices$",
    "earliest_time": "$earliest$",
    "latest_time": "now",
    "preview": true
}, {tokens: true, tokenNamespace: "submitted"});

The default namespace does not need to be explicitly declared because when a namespace is not specified, the default model is used. For example:

// This table uses the "default" token model
new TableElement({
    "id": "element1",
    "showPager": true,
    "managerid": "search1",
    "el": $("#element1")
}, {tokens: true}).render();