Dashboards & Visualizations

Dashboard: Set Token When Dashboard is Open

htkwan
Path Finder

Hello,
Would like to set a token when the user opens a dashboard. Pls. advise. Thanks.

Tags (3)

dbcase
Motivator

put this right below the dashboard statement in Simple XML

<init>
    <set token="app_name">my_app_name</set>
  </init>

ArthurGautesen
Path Finder

I usually use a globally accessible .csv file with a single entry value in it (because it is faster getting to finalized), but this always works in a pinch. Just toss this after your description and before everything else.

<search id="onDashboardOpen">
<query>index=* | head 1</query>
<earliest>-1m</earliest>
<latest>now</latest>
<finalized>
MyValue
</finalized>
</search>

martin_mueller
SplunkTrust
SplunkTrust

Instead of either, you could use | makeresults as a dummy query, should be much faster.

http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/makeresults

0 Karma

htkwan
Path Finder

Hello,
Can one set a token when the dashboard is opened? I don't have any inputs. Thanks.

0 Karma

joao_amorim
Communicator

Inside time_range input for example you can put:

<change>
    <set token="yourtoken">value</set>
</change>

It will set the token value as soon as you open the dashboard.

martin_mueller
SplunkTrust
SplunkTrust

If that's a token the user can modify, set the default value for the input the user uses to modify the token.
If that's a token the user can't modify, replace the uses of the token with the value you'd like the token to have.

If those two approaches don't do what you need, please describe what you need rather than what non-working solution you have in mind.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

If that's a constant, consider declaring a macro and use that. Bonus: Declare once, use in all dashboards.

You mentioned "program", if you've descended into the Javascript level below SimpleXML dashboards, you can use the generated setToken() function at any time you please.

0 Karma

htkwan
Path Finder

Hello Martin,
One can declare a variable to have a certain value in typical program. Want to do so, in the dashboard, too. Thanks

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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...