Dashboards & Visualizations

How to modify a token

syk19567
Explorer

Hi community,

I have a dropdown for environments like DEV/CT/PROD, and saved it into a token `SDLC`.
Now I would like to define another token `new_sdlc`. It's "ctpm" when `SDLC` is "pm"; Otherwise, it's the same value as `SDLC`.

In the end, I found a way working but a bit stupid, simply because it seems "!=" is not allowed so I have to list all conditions.

I've checked a few posts but didn't find a working and elegant way. I bet there is one. Looking forward to your help.

Here is my code:

<fieldset submitButton="false">
<input type="time" token="field1">
<label></label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
<input type="dropdown" token="SDLC">
<label>SDLC</label>
<choice value="prod">PROD</choice>
<choice value="ct">CT</choice>
<choice value="pm">PM</choice>
<default>prod</default>
<initialValue>prod</initialValue>
<change>
<condition label="CT">
<set token="new_sdlc">ct</set>
</condition>
<condition label="PM">
<set token="new_sdlc">ctpm</set>
</condition>
<condition label="PROD">
<set token="new_sdlc">prod</set>
</condition>
</change>
</input>
</fieldset>
Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

<change>
<eval token="new_sdlc">if("$SDLC$"=="sldc","ctpm","$SDLC$")</eval>
</change>
0 Karma

syk19567
Explorer

A problem I noticed is, the new token only gets a value when we change the origin token.

That's to say, when we opened the dashboard, although the origin token has a default value, the new token is null, thus the queries don't work. We'll see "Search is waiting for input "

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What about if you set the initial value as well as the default value?

0 Karma

syk19567
Explorer

Thank you for the response! I had a try like this (maybe not exactly the same) before posting, and it didn't work.

However, this time I pasted yours and after a slight change, it works!

Now it's like:

if(SDLC=="pm","ctpm",SDLC)

So it seems I cannot use $ and quotes. After removing them, it's good!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...