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!

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...