Dashboards & Visualizations

Using time token to restrict results in dropdown

shailesh030
Path Finder

I have two dropdown inputs. First drop down is to select time . 2nd drop down is populated using another search but needs to be limited by time range selected in 1st drop down. Below is the form I wrote. I tried using with time token from previous dropdown but it doesn't help in limiting the search. I know that appending search with earliest= and latest= will restrict the results but then I am not able to use the $time$ token.

Is there any way to restrict the search results for 2nd dropdown based on a dynamic time range ?

<form>
  <label>Adhoc Query</label>
  <fieldset autoRun="false" submitButton="true">
    <input type="dropdown" token="time" searchWhenChanged="true">
      <label>Select a Time Range:</label>
      <choice value="-30m@m">Last half hour</choice>
      <choice value="-60m@m">Last 1 hour</choice>
      <choice value="-240m@m">Last 4 hours</choice>
      <choice value="-24h">Last 24 hours</choice>
      <choice value="-48h">Last 2 days</choice>
      <choice value="-10d@d">Last 10 days</choice>
      <default>-30m@m</default>
    </input>
    <input type="dropdown" token="operationname" searchWhenChanged="true">
      <label>Select an Operation:</label>
      <prefix>OpNm="*</prefix>
      <suffix>"</suffix>
      <default>*</default>
      <choice value="*">All</choice>
      <populatingSearch fieldForValue="OpNm" fieldForLabel="OpNm">
        <![CDATA[ sourcetype="abclogskv" | stats count by OpNm]]>
        <earliestTime>$time$</earliestTime>
        <latestTime/>
      </populatingSearch>
    </input>
 </fieldset>
 </form>
0 Karma

shailesh030
Path Finder

Hi! acharlieh,

I had tried that with rich xml editor and it was complaining about invalid XML . This time I changed to plain text and used the same token it worked. I am not sure why though.

Thanks for prompting me to try it out again.

Regards
Shailesh

0 Karma

lennys26
Communicator

Hi Shailesh. Just so you know, I also have issues with the rich XML editor in both IE and Chrome. I now always use a separate editor.

0 Karma

shailesh030
Path Finder

Thanks lenny.. I will also be avoiding rich XML editor

0 Karma

acharlieh
Influencer

Why are you not able to use the $time$ token inline?

<populatingSearch fieldForValue="OpNm" fieldForLabel="OpNm">
   <![CDATA[ sourcetype="abclogskv" earliest="$time$" latest=now | stats count by OpNm]]>
</populatingSearch>
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...