Dashboards & Visualizations

Time token for date range and and relative time previous week

Mary666
Communicator
Hello Guys,
Need some help with learning how to set a token for time in a dashboard that will populate the date when entered specifically when user selects date range or date & time rage under the search dropdown, similarly need to have this same token populate the date when user selects time range of previous week, or previous month, two days ago...
So far this is what I got, but its not populating any dates...
 
 

 

Token created:

<fieldset submitButton="false">
    <input type="time" token="time_selected" searchWhenChanged="true">
      <label>Select Time </label>
      <default>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </default>
      <change>
      </change>
    </input>

This is the field I used in where the token is needed:

| eval StartTime=strpTime("tokEarliest", "%Y-%m-%d %H:%M:%S"),  EndTime= strpTime(TimeOfOrigin, "%Y-%m-%d %H:%M:%S.%q")​

 

Labels (1)
0 Karma

sravankaripe
Communicator

try this

| eval StartTime=strpTime("now()-7d@h", "%Y-%m-%d %H:%M:%S"),  EndTime= strpTime(now(), "%Y-%m-%d %H:%M:%S.%q")​

 

0 Karma

Mary666
Communicator

@sravankaripe 

Thanks for your help, still having issues with it.  So my time token is created, I just need to replace it with the hard coded date in the StartTime for the time user selects either previous week, or a particular date entered. 

| eval StartTime=strpTime("2021-07-01 22:04:00", "%Y-%m-%d %H:%M:%S"),  EndTime= strpTime(endingSeq, "%Y-%m-%d %H:%M:%S.%q")​

 

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, ...