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!

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureOn Demand Now Step boldly into the AI revolution with enhanced security ...