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

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...