Dashboards & Visualizations

Variables in fieldForValue and fieldForLabel for form drop-down?

azqaz
Engager

I built a form that uses a couple of drop-downs. They use the same CSV file for input. The first drop-down lets you choose the column name from the table to populate the second drop-down with the values from that column. Since the choice in the first drop-down changes the field that will be returned from the search in the second drop-down I placed variables in the fieldForValue and fieldForLabel entries.

When I test in edit mode everything works fine, but when I click "Done" and try to use the form, I get the error "Duplicate labels causing conflict" and in the editor the variables in the "fieldFor" now have two pair of dollar signs around them rather than one. The source seems to look the same with just one pair of dollar signs.

Edit mode - $gm1$

Done mode - $$gm1$$

Below is the XML source of my form.

<form>
  <label>bc-test1</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="time" token="time1">
      <label>Time range</label>
      <default>
        <earliest>-1d@d</earliest>
        <latest>@d</latest>
      </default>
    </input>
    <input type="dropdown" token="gm1" searchWhenChanged="true">
      <label>Grouping Metric</label>
      <search>
        <query>| inputlookup groupings.csv | search | stats dc(*) as * | transpose</query>
      </search>
      <fieldForLabel>column</fieldForLabel>
      <fieldForValue>column</fieldForValue>
      <choice value="">All</choice>
    </input>
    <input type="dropdown" token="gv1" searchWhenChanged="true">
      <label>Group Value</label>
      <search>
        <query>| inputlookup groupings.csv | search | dedup $gm1$ | table $gm1$</query>
        <earliest>0</earliest>
      </search>
      <fieldForLabel>$gm1$</fieldForLabel>
      <fieldForValue>$gm1$</fieldForValue>
    </input>
    <input type="dropdown" token="hn1">
      <label>Hostname</label>
      <search>
        <query>| inputlookup groupings.csv | search $gm1$=$gv1$ | dedup Hostname | table Hostname</query>
      </search>
      <fieldForLabel>Hostname</fieldForLabel>
      <fieldForValue>Hostname</fieldForValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <chart>
        <search>
          <query>index=nmon (type=Mem OR type=CPU_ALL) $hn1$  | eval Busy_PCT = 100 - Idle_PCT | eval Mem_PCT = (1 - ((memfree + cached)/memtotal)) * 100 | timechart span=10m max(Busy_PCT) by host</query>
          <earliest>$time1.earliest$</earliest>
          <latest>$time1.latest$</latest>
        </search>
        <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisX.scale">linear</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">line</option>
        <option name="charting.chart.bubbleMaximumSize">50</option>
        <option name="charting.chart.bubbleMinimumSize">10</option>
        <option name="charting.chart.bubbleSizeBy">area</option>
        <option name="charting.chart.nullValueMode">gaps</option>
        <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.chart.style">shiny</option>
        <option name="charting.drilldown">all</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.placement">right</option>
      </chart>
    </panel>
  </row>
</form>
0 Karma
1 Solution

somesoni2
Revered Legend

Try this for your gv1 dropdown (2nd one)

 <input type="dropdown" token="gv1" searchWhenChanged="true">
       <label>Group Value</label>
       <search>
         <query>| inputlookup groupings.csv | search | dedup $gm1$ | table $gm1$ | eval Commonfield=$gm1$ | stats count by Commonfield</query>
         <earliest>0</earliest>
       </search>
       <fieldForLabel>Commonfield</fieldForLabel>
       <fieldForValue>Commonfield</fieldForValue>
     </input>

View solution in original post

somesoni2
Revered Legend

Try this for your gv1 dropdown (2nd one)

 <input type="dropdown" token="gv1" searchWhenChanged="true">
       <label>Group Value</label>
       <search>
         <query>| inputlookup groupings.csv | search | dedup $gm1$ | table $gm1$ | eval Commonfield=$gm1$ | stats count by Commonfield</query>
         <earliest>0</earliest>
       </search>
       <fieldForLabel>Commonfield</fieldForLabel>
       <fieldForValue>Commonfield</fieldForValue>
     </input>

azqaz
Engager

That worked. Thanks.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...