Dashboards & Visualizations

Why doesn't Splunk acknowledge tokens set with JavaScript inside dashboard input tags?

pembleton
Path Finder

Hi,

I'm having a problem using tokens set with JavaScript inside my XML, specifically inside input tags.

I have a dashboard with tabs and I'm using js to set a token when I move between them.
Then I use the token in my dashboard queries so they'll run only when their respective tab is active.

All work's well for most queries, but for those inside an input tag, there's a problem: splunk doesn't acknowledge the token set within the js code. it does recognize tokens set within the xml.

js code that sets the token:

var tokens  = mvc.Components.getInstance("submmited");
tokens.set(tabToken, '');

dashboard xml:

<!-- Doesn't work! -->
<input>
<search>
<query>
index=$index$ sourcetype=$sourcetype$ $control_token$
</query>
</search>
</input>


<!-- Work! -->
<table>
<search>
<query>
index=$index$ sourcetype=$sourcetype$ $control_token$
</query>
</search>
</table>

This behavior repeats throughout the dashboard, so I don't think it is caused by a faulty query. (also it starts working immediately after expelling the control_token)

Any ideas on why might this occur?
thanks in advance.

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

Methinks you have a typo, try this:

var tokens  = mvc.Components.getInstance("submitted");
tokens.set(tabToken, '');

submitted with 2 t's and 1 m.

0 Karma

pembleton
Path Finder

the typo is only in my question, not in the source. sorry about that.
anyway i don't think the problem is in a typo.
like i said, the token does work on most queries just not inside an input tag.

0 Karma

rvisj
New Member

hi @alacercogitatus, did you find any solution or alternate to his problem, bcs I am facing the same problem.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Get Agentic with Splunk Lantern: Connect to Cisco Cloud Control, Transform ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

July Community Events: Master ITSI 5.0 & Automate Splunk

Struggling with alert fatigue or feeling like you're spending more time on infrastructure maintenance than ...

New Release of Federated Search: Bringing Splunk Analytics to More of Your Data

Organizations today are generating more data than ever and storing it across cloud object stores, data lakes, ...