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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...