Dashboards & Visualizations

Time range in form search

xiaoyuew
Path Finder

Is there a way to add time range in a form search, eg. specify start time and end time? right now i have a drop down list with a few options. But we would like to let user specify a time range as what they wish to see.

Thanks.

Tags (1)
0 Karma

Ayn
Legend

In addition to Draineh's answer, this can also be done in simple XML. Just use <input type="time"/>. Complete example below:

<form>
  <label>Example search form</label>

  <searchTemplate>sourcetype="example" someparam="$someparam$"</searchTemplate>

  <fieldset>
    <input type="text" token="someparam">
      <label>Value to filter someparam on</label>
      <seed>*</seed>
    </input>

    <input type="time"/>
  </fieldset>

  <row>
    <table>
      <title>Search results</title>
      <fields>_time, someparam, _raw</fields>
      <option name="showPager">true</option>
      <option name="count">30</option>
      <option name="displayRowNumbers">false</option>
      </table>
  </row>
</form>
0 Karma

xiaoyuew
Path Finder

I understand that there is an option for that which is to change the configuration in the times.conf.However, we don't want to do that. We just want this form to have fewer drop down options.

0 Karma

xiaoyuew
Path Finder

Thanks, Ayn.

What if I only want to have 3 options in the dropdown list, instead of the 10 choices we have by default? say i only want last 4 hours, last 24 hours and last 7 days.

0 Karma

Drainy
Champion

Yes.
If your dashboard is in advanced XML (you can convert it by adding ?showsource=1 to the end of your dashboard link, e.g /en-US/app/search/dashboard_live?showsource=1 This will display a page with a box that contains the converted simple xml in advanced xml)

You can then use the code;

  <module name="HiddenSearch" layoutPanel="panel_row1_col1" autoRun="True">
        <module name="TimeRangePicker">    
        <param name="label">Select Time Range: </param>
          <param name="searchWhenChanged">True</param>
          <param name="selected">Last 4 hours</param>

If you enclose all searches you want to inherit the time from this module by closing the module after them then as the user changes the selected time range it will update all searches.

To define the time ranges (other than default) you can edit times.conf (or create your own in the appname/local directory. See the following link for more detail;

http://docs.splunk.com/Documentation/Splunk/latest/admin/Timesconf

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!

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...

Index This | How many sevens are there between 1 and 100?

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