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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...