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
SplunkTrust
SplunkTrust

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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...