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!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...