Dashboards & Visualizations

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

robertlynch2020
Motivator

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
Motivator

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
Motivator

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
Communicator

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
Motivator

Hi - Thanks for your answer.

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

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...