Dashboards & Visualizations

Splunk Enterprise fill tokens with JavaScript


Hello everyone,

I have created a Splunk form which has some html form inputs to update a lookup for me. To get the values from the html form inputs I'm using a Javascript code, such as the one bellow:

], function( mvc,
var tokens = mvc.Components.get("default");

$('#addentry').on("click", function (e){

var field1 = $("input[name=field1]").val();
tokens.set("tok_add_field1", field1);


Once addentry button is clicked the token is filled by the Javascript and a base search should run to update the value in a lookup. Problem is, after the token which the search needs is filled it still doesn't run (It runs if I go to Edit -> Source -> Cancel).



<search id="add_results">
| inputlookup example.csv
| append [ makeresults | eval field1="$tok_add_field1$"]
| outputlookup example.csv
<set token="confirmation">Search executed!</set>

Could someone please tell me what is missing in my search so that it is automatically executed once the tokens are filled?  Thanks a lot!

Additionally: I have noticed that once a Splunk input is filled, adding "?" to the URL, javascript will no longer update the tokens. Maybe a problem with the interaction between JS and browser.

Labels (3)
0 Karma
Get Updates on the Splunk Community!

Index This | How many sides does a circle have?

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

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...

Splunkbase | Splunk Dashboard Examples App for SimpleXML End of Life

The Splunk Dashboard Examples App for SimpleXML will reach end of support on Dec 19, 2024, after which no new ...