Dashboards & Visualizations

Use Dropdown Selector to Choose Day Ranges

lennys26
Communicator

Hello.

I am trying to use a drop down selector (as opposed to the time selector) in my dashboard to create a token with an @d value in %e-%b-%Y %T.%L.

In other words, I want to provide users an option for "Today, Yesterday, This Week" and have that populate tokens with earliest (@d) & latest (@d+86399) value of that day.

Ex:

Input: User selects TODAY

Token.start:  16-jun-2022 00:00:00.000

Token.end: 16-jun-2022 23:59:59.999

This should be straight forward, but for some reason, I am racking my brain trying to get this.

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@lennys26 - You can use input something like this in the Simple XML.

   <input type="dropdown" token="release" searchWhenChanged="true">
      <label>Release</label>
      <choice value="Today">Today</choice>
      <choice value="Yesterday">Today</choice>
      <change>
        <condition label="Today">
          <set token="custom_earliest">-@d</set>
          <set token="custom_latest">now</set>
        </condition>
        <condition label="Yesterday">
          <set token="custom_earliest">-2d@d</set>
          <set token="custom_latest">-1d@d</set>
        </condition>
      </change>
      <default>Today</default>
    </input>

(I could be wrong in the values assigned, but this is the logic you can use.)

 

I hope this helps!!!

gcusello
SplunkTrust
SplunkTrust

Hi @lennys26,

you can create your own time defaults in [Settings -- User Interface -- Time Ranges]

remember to assign the new default Time ranges to the roles of your users.

Ciao.

Giuseppe

lennys26
Communicator

Thanks for the reply. Actually it is not for the time range of the search itself, but for secondary criteria in my DB that is being queried (DBXQUERY).  

So, for some more info, the variable will be used like this:

 

| dbxquery query=" 
SELECT <field1>, <field2>
FROM <db_name>
WHERE start_time >= <$start_time_tok$> AND start_time <$end_time_tok$>
AND segment_time between <$start_seg_tok$> AND <$end_seg_tok$> ;" 

 

I am trying to get the <start_seg_tok> and <end_seg_tok> to be the start and end of the particular day selected in the drop down.

I am not using the Splunk provided time selector in this case.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...