Dashboards & Visualizations

using multiple tokens to populate a dashboard

jcgever
Explorer

I'm new to xml and building dashboards in splunk. What I'm trying to do is build a dashboard that takes information from the user through drop down menus that build on each other. I've gotten it almost figured out but the last drop down menu doesn't populate with any results. Any pointers? here is what I have so far:

<form>
  <label>Environment search</label>
  <fieldset submitButton="false">
    <input type="time" token="datetime" searchWhenChanged="true">
      <label>Date and Time</label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="env" searchWhenChanged="true">
      <label>Environment</label>
      <choice value="*">all</choice>
      <choice value="*l1q*">qa</choice>
      <choice value="*l1d*">dev</choice>
      <choice value="*l1s*">stg</choice>
      <choice value="*1p*">prod</choice>
      <fieldForLabel>env</fieldForLabel>
      <fieldForValue>env</fieldForValue>
      <search>
        <query/>
        <earliest>$datetime.earliest$</earliest>
        <latest>$datetime.latest$</latest>
      </search>
    </input>
    <input type="dropdown" token="host">
      <label>Host</label>
      <fieldForLabel>host</fieldForLabel>
      <fieldForValue>host</fieldForValue>
      <search>
        <query>host=*$env$ | dedup host</query>
        <earliest>$datetime.earliest$</earliest>
        <latest>$datetime.latest$</latest>
      </search>
      <choice value="*">all</choice>
      <default>*</default>
      <initialValue>*</initialValue>
    </input>
    <input type="dropdown" token="apps" searchWhenChanged="true">
      <label>Apps</label>
      <fieldForLabel>apps</fieldForLabel>
      <fieldForValue>apps</fieldForValue>
      <search>
        <query>host=$host$ index=* |dedup index host</query>
        <earliest>$datetime.earliest$</earliest>
        <latest>$datetime.latest$</latest>
      </search>
      <choice value="*">all</choice>
      <default>*</default>
      <initialValue>*</initialValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <event>
        <title>logs</title>
        <search>
          <query>host=$host$ index=$apps$</query>
          <earliest>$datetime.earliest$</earliest>
          <latest>$datetime.latest$</latest>
        </search>
        <option name="list.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </event>
    </panel>
  </row>
</form>
0 Karma

jcgever
Explorer

Thanks! I didn't think to use tstats. Works like a charm now.

0 Karma

somesoni2
Revered Legend

Give this a try

<form>
   <label>Environment search</label>
   <fieldset submitButton="false">
     <input type="time" token="datetime" searchWhenChanged="true">
       <label>Date and Time</label>
       <default>
         <earliest>-15m</earliest>
         <latest>now</latest>
       </default>
     </input>
     <input type="dropdown" token="env" searchWhenChanged="true">
       <label>Environment</label>
       <choice value="*">all</choice>
       <choice value="*l1q*">qa</choice>
       <choice value="*l1d*">dev</choice>
       <choice value="*l1s*">stg</choice>
       <choice value="*1p*">prod</choice>
     </input>
     <input type="dropdown" token="host" searchWhenChanged="true">
       <label>Host</label>
       <fieldForLabel>host</fieldForLabel>
       <fieldForValue>host</fieldForValue>
       <search>
         <query>| tstats count WHERE host=*$env$ by host | table host</query>
         <earliest>$datetime.earliest$</earliest>
         <latest>$datetime.latest$</latest>
       </search>
       <choice value="*">all</choice>
       <default>*</default>
       <initialValue>*</initialValue>
     </input>
     <input type="dropdown" token="apps" searchWhenChanged="true">
       <label>Apps</label>
       <fieldForLabel>index</fieldForLabel>
       <fieldForValue>index</fieldForValue>
       <search>
         <query>| tstats count WHERE host=$host$ by index | table index </query>
         <earliest>$datetime.earliest$</earliest>
         <latest>$datetime.latest$</latest>
       </search>
       <choice value="*">all</choice>
       <default>*</default>
       <initialValue>*</initialValue>
     </input>
   </fieldset>
   <row>
     <panel>
       <event>
         <title>logs</title>
         <search>
           <query>host=$host$ index=$apps$</query>
           <earliest>$datetime.earliest$</earliest>
           <latest>$datetime.latest$</latest>
         </search>
         <option name="list.drilldown">none</option>
         <option name="refresh.display">progressbar</option>
       </event>
     </panel>
   </row>
 </form>
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...