Dashboards & Visualizations

Dynamic dropdown and multiple tokens

sb01splunk
Explorer

I have a very simple dynamic dropdown that lists computers by their FQDN. I have one panel that can use that token value "Failures" and I have one panel that needs the domain name stripped away "Errors." Is there an easy way to do this?

 

 

  <fieldset submitButton="false" autoRun="true">
    <input type="dropdown" token="TheName">
      <label>Computers:</label>
      <fieldForLabel>host</fieldForLabel>
      <fieldForValue>host</fieldForValue>
      <search>
        <query>index="bfront" source="/var/log/audit/audit.log" | dedup host | table host | sort by host</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    </input>
    <input type="time" token="TheTime" depends="$TheName$">
      <label>Time:</label>
      <default>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel depends="$TheName$">
      <title>Failures</title>
      <chart>
        <search>
          <query>index="bfront" sourcetype="linux_audit" host="$TheName$" type=USER_LOGIN res=failed | top limit=10 acct</query>
          <earliest>$TheTime.earliest$</earliest>
          <latest>$TheTime.latest$</latest>
          <refresh>5m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.axisTitleX.visibility">collapsed</option>
        <option name="charting.axisTitleY.visibility">collapsed</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.chart">bar</option>
        <option name="charting.chart.showDataLabels">all</option>
        <option name="charting.drilldown">all</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.legend.placement">none</option>
        <option name="charting.seriesColors">["0xf8be34","0xf8be34","0xf8be34","0xf8be34","0xf8be34"]</option>
        <option name="height">260</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
    <panel depends="$TheName$">
      <title>Errors</title>
      <chart>
        <search>
          <query> index="bront" source="/var/log/messages" host="$TheName$" eventtype=err0r | top limit=20 process</query>
          <earliest>$TheTime.earliest$</earliest>
          <latest>$TheTime.latest$</latest>
          <refresh>5m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.chart">pie</option>
        <option name="charting.drilldown">all</option>
        <option name="height">270</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
  </row>

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Evaluate smallhost as everything before the first dot in host and use this as the label, keeping the fqdn as the value. Then set tokens for use in queries when the dropdown changes.

  <fieldset submitButton="false" autoRun="true">
    <input type="dropdown" token="TheName">
      <label>Computers:</label>
      <fieldForLabel>smallhost</fieldForLabel>
      <fieldForValue>host</fieldForValue>
      <search>
        <query>index="bfront" source="/var/log/audit/audit.log" | dedup host | table host | sort by host | rex field=host "^(?&lt;smallhost&gt;[^\.]+)"</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    <change>
      <set token="failhost">$value$</set>
      <set token="errorhost">$label$</set>
    </change>
    </input>
    <input type="time" token="TheTime" depends="$TheName$">
      <label>Time:</label>
      <default>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel depends="$TheName$">
      <title>Failures</title>
      <chart>
        <search>
          <query>index="bfront" sourcetype="linux_audit" host="$failhost$" type=USER_LOGIN res=failed | top limit=10 acct</query>
          <earliest>$TheTime.earliest$</earliest>
          <latest>$TheTime.latest$</latest>
          <refresh>5m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.axisTitleX.visibility">collapsed</option>
        <option name="charting.axisTitleY.visibility">collapsed</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.chart">bar</option>
        <option name="charting.chart.showDataLabels">all</option>
        <option name="charting.drilldown">all</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.legend.placement">none</option>
        <option name="charting.seriesColors">["0xf8be34","0xf8be34","0xf8be34","0xf8be34","0xf8be34"]</option>
        <option name="height">260</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
    <panel depends="$TheName$">
      <title>Errors</title>
      <chart>
        <search>
          <query> index="bront" source="/var/log/messages" host="$errorhost$" eventtype=err0r | top limit=20 process</query>
          <earliest>$TheTime.earliest$</earliest>
          <latest>$TheTime.latest$</latest>
          <refresh>5m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.chart">pie</option>
        <option name="charting.drilldown">all</option>
        <option name="height">270</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
  </row>

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Evaluate smallhost as everything before the first dot in host and use this as the label, keeping the fqdn as the value. Then set tokens for use in queries when the dropdown changes.

  <fieldset submitButton="false" autoRun="true">
    <input type="dropdown" token="TheName">
      <label>Computers:</label>
      <fieldForLabel>smallhost</fieldForLabel>
      <fieldForValue>host</fieldForValue>
      <search>
        <query>index="bfront" source="/var/log/audit/audit.log" | dedup host | table host | sort by host | rex field=host "^(?&lt;smallhost&gt;[^\.]+)"</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    <change>
      <set token="failhost">$value$</set>
      <set token="errorhost">$label$</set>
    </change>
    </input>
    <input type="time" token="TheTime" depends="$TheName$">
      <label>Time:</label>
      <default>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel depends="$TheName$">
      <title>Failures</title>
      <chart>
        <search>
          <query>index="bfront" sourcetype="linux_audit" host="$failhost$" type=USER_LOGIN res=failed | top limit=10 acct</query>
          <earliest>$TheTime.earliest$</earliest>
          <latest>$TheTime.latest$</latest>
          <refresh>5m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.axisTitleX.visibility">collapsed</option>
        <option name="charting.axisTitleY.visibility">collapsed</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.chart">bar</option>
        <option name="charting.chart.showDataLabels">all</option>
        <option name="charting.drilldown">all</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.legend.placement">none</option>
        <option name="charting.seriesColors">["0xf8be34","0xf8be34","0xf8be34","0xf8be34","0xf8be34"]</option>
        <option name="height">260</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
    <panel depends="$TheName$">
      <title>Errors</title>
      <chart>
        <search>
          <query> index="bront" source="/var/log/messages" host="$errorhost$" eventtype=err0r | top limit=20 process</query>
          <earliest>$TheTime.earliest$</earliest>
          <latest>$TheTime.latest$</latest>
          <refresh>5m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.chart">pie</option>
        <option name="charting.drilldown">all</option>
        <option name="height">270</option>
        <option name="refresh.display">none</option>
      </chart>
    </panel>
  </row>

sb01splunk
Explorer

This works perfectly! Thanks!!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...