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 :winking_face:

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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...