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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...