Dashboards & Visualizations

How to edit my Simple XML to set a default value for the input time label token in my dashboard?

skota524
Explorer

Check the code attached below.
default time = 1 week window. Setting the drop-down label to "time_selected" token.

set token="time_selected" ==> $label$

When i open the dashboard, $time_selected$ = $label$
When i change the Time to (1 week window or All time), $time_selected$ = 1 week window.

Issue:
By default we set the time to 1 week window, but $label$ token is not set.
When we change the time, it's working fine.

Expected:
it to work by default.
When i open the dashboard, $time_selected$ should be "1 week window"

Code:
alt text

Any help is appreciated!

0 Karma

skota524
Explorer

Interesting, its the browser issue. Working fine on Chrome, but not on firefox.

Attaching the screenshots

Mozilla :
alt text

Chrome:
alt text

0 Karma

somesoni2
Revered Legend

The code in your question works for me Splunk 6.5. Here is the code that I used to test (run anywhere sample). What version of Splunk you're on?

<form>
  <label>TestsrchFilter</label>
  <fieldset submitButton="false">
    <input type="time" token="time" searchWhenChanged="true">
      <label>Select Time</label>
      <default>
        <earliest>rt-1w</earliest>
        <latest>rtnow</latest>
      </default>
      <change>
        <set token="selected_time">$label$</set>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>$selected_time$</title>
      <table>
        <search>
          <query>index=_internal | timechart span=1h count</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>
0 Karma

skota524
Explorer

Version is 6.3

I tried with 6.4 also. Still same issue.

0 Karma

skota524
Explorer

Its browser issue. Working fine with chrome, but not with firefox

0 Karma

somesoni2
Revered Legend

Can you try in IE?

0 Karma

skota524
Explorer

Its fine in IE. So issue with Mozilla

0 Karma

rjthibod
Champion

If what you are doing would work (which I am not sure it will) , you need to add the "condition" xml element.

<change>
    <condition label="*">
      <set token="time_selected">$label$</set>
    </condition>
</change>

The other thing to try is anywhere you have $time_selected$ in the dashboard, substitute it with $form.globalTime$. Still not confident it is possible, but are the only two things I can think of.

0 Karma

lguinn2
Legend

I am not sure that the realtime search times are supported in simple XML. Did you really want a realtime search in your dashboard?

0 Karma

skota524
Explorer

Yes. We need a live dashboard.

Real time search is working fine. But the only issue is label is not setting on load of dashboard.
Its working fine, when we change it.

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

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

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...