Dashboards & Visualizations

Creating 2 labels from one input

TzipR
Engager

I am working om creating a dashboard to display data from my app-I have a dropdown where you select which environment you want to see data for-I need to set 2 values based on this dropdown:

1.connection for db queries

2. host for logs based queries
I searched many option but couldn't get any to work:I am trying to do  <fieldset submitButton="false">
<input type="dropdown" token="connection">
<label>Select Region</label>
<default>dev-platform-postgres</default>
<choice value="dev-platform-postgres">US</choice>
<choice value="dev-platform-postgres-eu">EU</choice>
<change>
<condition label = 'dev-platform-postgres'>
<set token="host">eks-prod-saas-ue1-*</set>
</condition>
<condition label = 'dev-platform-postgres-eu'>
<set token="host">prd-shared-services-eu-eks*</set>
</condition>
</change>
</input>
</fieldset>
and then be able to use both $host$ and $connection$ tokens in the dashboard but I cant get $host$ initialized correctly
any help would be appreciated
also -side note I am getting a warning "Expected at most 1 children of fieldset in dashboard, instead saw 2"-how am I supposed to handle a case where I want 2 selections -one of date and one of connection?

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

I misunderstood your problem - your conditions need to use the values of the labels, i.e. US and EU

<form version="1.1" theme="light">
  <label>Hosts</label>
  <init>
    <set token="host">eks-prod-saas-ue1-*</set>
  </init>
  <fieldset submitButton="false">
    <input type="dropdown" token="connection">
      <label>Select Region</label>
      <default>dev-platform-postgres</default>
      <choice value="dev-platform-postgres">US</choice>
      <choice value="dev-platform-postgres-eu">EU</choice>
      <change>
        <condition label="US">
          <set token="host">eks-prod-saas-ue1-*</set>
        </condition>
        <condition label="EU">
          <set token="host">prd-shared-services-eu-eks*</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$host$ $connection$</p>
      </html>
    </panel>
  </row>
</form>

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Use an init block

<form version="1.1" theme="light">
  <label>Hosts</label>
  <init>
    <set token="host">eks-prod-saas-ue1-*</set>
  </init>
  <fieldset submitButton="false">
    <input type="dropdown" token="connection">
      <label>Select Region</label>
      <default>dev-platform-postgres</default>
      <choice value="dev-platform-postgres">US</choice>
      <choice value="dev-platform-postgres-eu">EU</choice>
      <change>
        <condition label="dev-platform-postgres">
          <set token="host">eks-prod-saas-ue1-*</set>
        </condition>
        <condition label="dev-platform-postgres-eu">
          <set token="host">prd-shared-services-eu-eks*</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$host$ $connection$</p>
      </html>
    </panel>
  </row>
</form>
0 Karma

TzipR
Engager

Hi @ITWhisperer thanks for taking the time to reply
when using init -it only initializes the first time but doesn't update accordingly when fieldset is changed

0 Karma

TzipR
Engager

I tried also :

<fieldset submitButton="false">
<input type="dropdown" token="connection">
<label>Select Region</label>
<default>dev-platform-postgres</default>
<choice value="dev-platform-postgres">US</choice>
<choice value="dev-platform-postgres-eu">EU</choice>
<change>
<condition match="$connection$==dev-platform-postgres">
<set token="host">eks-prod-saas-ue1-*</set>
</condition>
<condition match="$connection$==dev-platform-postgres-eu">
<set token="host">prd-shared-services-eu-eks*</set>
</condition>
</change>
</input>
</fieldset>


but again $host$ is not updated on fieldset change

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I misunderstood your problem - your conditions need to use the values of the labels, i.e. US and EU

<form version="1.1" theme="light">
  <label>Hosts</label>
  <init>
    <set token="host">eks-prod-saas-ue1-*</set>
  </init>
  <fieldset submitButton="false">
    <input type="dropdown" token="connection">
      <label>Select Region</label>
      <default>dev-platform-postgres</default>
      <choice value="dev-platform-postgres">US</choice>
      <choice value="dev-platform-postgres-eu">EU</choice>
      <change>
        <condition label="US">
          <set token="host">eks-prod-saas-ue1-*</set>
        </condition>
        <condition label="EU">
          <set token="host">prd-shared-services-eu-eks*</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$host$ $connection$</p>
      </html>
    </panel>
  </row>
</form>
0 Karma

TzipR
Engager

thanks -that works now

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...