Dashboards & Visualizations

How to overwrite a Token in a dashboard coming from a URL token

robertlynch2020
Influencer

I am passing in the following token host_token=$host_token$ in a URL

 

<link target="_blank">/app/RTPM/blackwidow_testing__technical_dashboard_19_01_2022_v2?host_token=$host_token$&amp;host_token1=$host_token$</link>

 

However, the Screen that is receiving the token blackwidow_testing__technical_dashboard_19_01_2022_v2 allready has an input for host_token (As the screen can be used on its own, with out someone passing in tokens)

It looks like this. Ideally if the host_token comes in from the URL, i want the value to be set to that. However that does not happy, the URL host_token seems to be ignored and the original dropdown works as if nothing happened. 

 

  <input type="dropdown" token="host_token">
        <label>HOST</label>
        <fieldForLabel>mx.env</fieldForLabel>
        <fieldForValue>mx.env</fieldForValue>
        <search>
          <query>| mstats avg("mx.process.cpu.utilization") as X WHERE "index"="metrics_test"  span=10s BY "mx.env" 
| dedup mx.env 
| table mx.env</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
      </input>

 

As a test I pass in 2 tokens host_token and host_token1 - host_token is set to undefined.

This is the one that i need to get set when it come in from the URL

robertlynch2020_0-1642602195231.png

 

 

 Any help would be amazing - thanks - Robbie

Labels (1)
Tags (1)
0 Karma
1 Solution

robertlynch2020
Influencer

Hi 

In the end, for this, I sent in a TOKEN that falls into what i call a URL trap.

So when the dashboard loads it will go into the correct condition depending on what we want to set the tokens to.

<search>
    <query>| makeresults count=1 annotate=false </query>
    <done>
      <!--Set Tokens if a URL has come to re set some of the tokens to they will be visibale in the screen-->
      <condition match="$URL_TRAP$==&quot;SET&quot;">
        <set token="form.host_token">$host_token1$</set>
        <set token="form.Severity_token">$Severity_token1$</set>
        <set token="Severity_token">$Severity_token1$</set>
        <set token="form.Service_Name">$Service_Name1$</set>
      </condition>
      <condition match="match($ERROR_FILTER$,&quot;true&quot;)">
        <set token="form.Severity_token">"FATAL" "ERROR"</set>
        <set token="Severity_token">"FATAL" "ERROR"</set>
      </condition>
      <condition match="match($EVENT_FILTER$,&quot;EVENT&quot;)">
        <eval token="form.time_token.earliest">$latest$</eval>
        <eval token="form.time_token.latest">$latest$+300</eval>
        <set token="form.Severity_token">*</set>
      </condition>
      <condition>
        <set token="Severity_token">*</set>
        <set token="Service_Name">*</set>
      </condition>
    </done>
  </search>

 

 

View solution in original post

0 Karma

robertlynch2020
Influencer

Hi 

In the end, for this, I sent in a TOKEN that falls into what i call a URL trap.

So when the dashboard loads it will go into the correct condition depending on what we want to set the tokens to.

<search>
    <query>| makeresults count=1 annotate=false </query>
    <done>
      <!--Set Tokens if a URL has come to re set some of the tokens to they will be visibale in the screen-->
      <condition match="$URL_TRAP$==&quot;SET&quot;">
        <set token="form.host_token">$host_token1$</set>
        <set token="form.Severity_token">$Severity_token1$</set>
        <set token="Severity_token">$Severity_token1$</set>
        <set token="form.Service_Name">$Service_Name1$</set>
      </condition>
      <condition match="match($ERROR_FILTER$,&quot;true&quot;)">
        <set token="form.Severity_token">"FATAL" "ERROR"</set>
        <set token="Severity_token">"FATAL" "ERROR"</set>
      </condition>
      <condition match="match($EVENT_FILTER$,&quot;EVENT&quot;)">
        <eval token="form.time_token.earliest">$latest$</eval>
        <eval token="form.time_token.latest">$latest$+300</eval>
        <set token="form.Severity_token">*</set>
      </condition>
      <condition>
        <set token="Severity_token">*</set>
        <set token="Service_Name">*</set>
      </condition>
    </done>
  </search>

 

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try using a "form." prefix to the token so that the input of the destination form gets overridden.

<link target="_blank">/app/RTPM/blackwidow_testing__technical_dashboard_19_01_2022_v2?form.host_token=$host_token$&amp;host_token1=$host_token$</link>

weidertc
Contributor

You can try using a 3rd host token.  the 3rd token uses the value of the url host token if available, otherwise, it uses the host token from the input.  use the 3rd host token wherever you need it.

robertlynch2020
Influencer

Hi - Thanks for your answer.

In the end, I posed the answer that I used.

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!

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 ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...