Dashboards & Visualizations

Is there a Form Element that will accept a single datetime value?

Ashwin3
Engager

Is there a form element that accepts only a single datetime value?

User will be entering two fields, field 1 as  a single datetime and field 2 as a duration like "1h".

Based on this two inputs, need to calculate and set time values as below

 

For eg:

User input field 1[TimeTokenMid] --> 07/12/2022:18:00:00

User input field 2[Duration] --> "1h"

Need to calculate and set time ranges as below using relative_time function.

Token_1 = 07/12/2022:17:00:00 [TimeTokenMid - Duration using relative_time fnc]

Token_2 = 07/12/2022:19:00:00 [TimeTokenMid + Duration using relative_time fnc]

Currently i am taking field 1[TimeTokenMid] as text and doing calculation as the current timepicker control is not allowing to set a single custom time value. It has options only for selecting a range like (last 60 mins, between x and y etc)like that. In my usecase,I want to take a single timevalue input and calculate time ranges(+-) based on the duration input dynamically. Could you please suggest any solution?

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

One way is to use <eval token /> under <progress /> with a fake search, as inspired by .

For example,

<form>
  <label>Set time window</label>
  <search>
    <query>
      | makeresults
    </query>
    <progress>
      <condition match="true()">
        <eval token="latest_tok">strftime(relative_time(strptime($Token_1$, "%m/%d/%Y:%H:%M:%S"), "+" . $Token_2$), "%m/%d/%Y:%H:%M:%S")</eval>
      </condition>
    </progress>
  </search>
  <fieldset submitButton="false">
    <input type="dropdown" token="Token_1" searchWhenChanged="true">
      <label>start time</label>
      <choice value="07/12/2022:17:00:00">07/12/2022:17:00:00</choice>
      <choice value="07/13/2022:17:00:00">07/13/2022:17:00:00</choice>
      <choice value="07/14/2022:17:00:00">07/14/2022:17:00:00</choice>
      <initialValue>07/12/2022:17:00:00</initialValue>
    </input>
    <input type="dropdown" token="Token_2" searchWhenChanged="true">
      <label>interval</label>
      <choice value="2h">2h</choice>
      <choice value="4h">4h</choice>
      <choice value="8h">8h</choice>
      <choice value="12h">12h</choice>
      <default>2h</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <div>latest token: $latest_tok$</div>
      </html>
    </panel>
  </row>
</form>

 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

How much can you really learn in 3 minutes?

Observability can certainly be hard to understand – there's a lot of jargon and buzzwords and it seems to ...

Event Series: The Agentic SOC: Trust Before Autonomy

AI is fundamentally changing security operations, but true progress requires more than just automation—it ...

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...