Dashboards & Visualizations

How to reset time filter in the below case?

supraja
Path Finder

supraja_0-1664679985911.png

<form>
<fieldset submitButton="false">
<input type="time" token="tok_time">
<label>Time</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>
<input id="Reset" type="link" token="resetTokens" searchWhenChanged="true">
<label></label>
<choice value="Reset">Reset</choice>
<change>
<condition value="Reset">
<unset token="tok_Time"></unset>
<unset token="form.tok_Time"></unset>
<set token="resetTokens">yes</set>
<set token="form.resetTokens">yes</set>
</condition>
</change>
</input>
<html depends="$alwaysHideCSSOverride$">
<style>
div[id^="Reset"] button{
width: 180px !important;
background: rgb(192,192,192,1);
padding: 10px;
border-radius: 10px;
color: Blue !important;
}
</style>
</html>
</fieldset>
</form>

Tags (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

You were not using the right tokens in the change element (also you had case issue tok_TIme vs tok_time). Here's your example - working (I added a panel to show the token values)

 

<form>
  <fieldset submitButton="false">
    <input type="time" token="tok_time">
      <label>Time</label>
      <default>
      <earliest>-24h@h</earliest>
      <latest>now</latest>
      </default>
    </input>
    <input id="Reset" type="link" token="resetTokens" searchWhenChanged="true">
      <label></label>
      <choice value="Reset">Reset</choice>
      <change>
        <set token="tok_time.earliest">-24h@h</set>
        <set token="tok_time.latest">now</set>
        <set token="form.tok_time.earliest">-24h@h</set>
        <set token="form.tok_time.latest">now</set>
        <unset token="form.resetTokens"></unset>
      </change>
    </input>
    <html depends="$alwaysHideCSSOverride$">
      <style>
      div[id^="Reset"] button{
      width: 180px !important;
      background: rgb(192,192,192,1);
      padding: 10px;
      border-radius: 10px;
      color: Blue !important;
      }
      </style>
    </html>
    </fieldset>
    <row>
      <panel>
        <html>
          <h1>E:$tok_time.earliest$</h1>
          <h1>L:$tok_time.latest$</h1>
          <h1>R:$form.resetTokens$</h1>
        </html>
      </panel>
    </row>
</form>

 

 

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You were not using the right tokens in the change element (also you had case issue tok_TIme vs tok_time). Here's your example - working (I added a panel to show the token values)

 

<form>
  <fieldset submitButton="false">
    <input type="time" token="tok_time">
      <label>Time</label>
      <default>
      <earliest>-24h@h</earliest>
      <latest>now</latest>
      </default>
    </input>
    <input id="Reset" type="link" token="resetTokens" searchWhenChanged="true">
      <label></label>
      <choice value="Reset">Reset</choice>
      <change>
        <set token="tok_time.earliest">-24h@h</set>
        <set token="tok_time.latest">now</set>
        <set token="form.tok_time.earliest">-24h@h</set>
        <set token="form.tok_time.latest">now</set>
        <unset token="form.resetTokens"></unset>
      </change>
    </input>
    <html depends="$alwaysHideCSSOverride$">
      <style>
      div[id^="Reset"] button{
      width: 180px !important;
      background: rgb(192,192,192,1);
      padding: 10px;
      border-radius: 10px;
      color: Blue !important;
      }
      </style>
    </html>
    </fieldset>
    <row>
      <panel>
        <html>
          <h1>E:$tok_time.earliest$</h1>
          <h1>L:$tok_time.latest$</h1>
          <h1>R:$form.resetTokens$</h1>
        </html>
      </panel>
    </row>
</form>

 

 

0 Karma

supraja
Path Finder

the below one is not working, if you add one more token of other filter , it is not working .

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @supraja,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @supraja,

I'm not sure that's possible to add an html button in the input section, so I used this solution that's running in my dashboards:

    <input type="radio" token="resetTokens" searchWhenChanged="true">
      <label></label>
      <choice value="reset">Reset Inputs</choice>
      <choice value="retain">Retain</choice>
      <default>reset</default>
      <change>
        <condition value="reset">
          <unset token="token1"></unset>
          <unset token="timestamp"></unset>
          <set token="resetTokens">retain</set>
        </condition>
      </change>
    </input>

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...