Dashboards & Visualizations

Show/Hide Panels based off time range picker

mdeterville
Path Finder

Hi There:

I'd like to set up some panels that show/hide based on the values of the  date/time range picker.

Two different panels:

1. Show only when time range picker is set to <=30 days

2. Show only when time range picker is set to >30 days

I've tested a few "depends" set ups with no luck.

Any help would be greatly appreciated. 

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Can you show what you've tried. 

Here's an example that shows how it can be done. If you select a time range > 30 days, then it shows one panel or < 30 days, the other one.

<form>
  <label>Depends</label>
  <fieldset submitButton="false">
    <input type="time" token="time_range">
      <label></label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <done>
            <condition match="$result.x$==&quot;1&quot;">
              <set token="show"></set>
            </condition>
            <condition match="$result.x$==&quot;0&quot;">
              <unset token="show"></unset>
            </condition>
          </done>
          <query>| makeresults
| eval earliest=relative_time(now(),$time_range.earliest|s$)
| eval latest=if($time_range.latest|s$="now", now(), relative_time(now(),$time_range.latest|s$))
| eval diff=latest-earliest
| eval x=if(diff &gt; (86400*30),1,0)</query>
          <earliest>$earliest$</earliest>
          <latest>$latest$</latest>
        </search>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
  <row>
    <panel depends="$show$">
      <table>
        <search>
          <query>| makeresults
            | eval Message="This panel is now showing because time range span is more than 30 days"</query>
          <earliest>$earliest$</earliest>
          <latest>$latest$</latest>
        </search>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
    <panel rejects="$show$">
      <table>
        <search>
          <query>| makeresults
            | eval Message="This panel is now showing because time range span is less than 30 days"</query>
          <earliest>$earliest$</earliest>
          <latest>$latest$</latest>
        </search>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
</form>

Hope this helps

 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...