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!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...