Dashboards & Visualizations

Time Picker in the Dashboard not working as expected.

iamsplunker31
Path Finder

We have a dashboard . When we select time period say 11/13/19 (9 am to 11 am ). The results are displying from 11/13/19 (8 am to 10 am) and the results consist of all zeros in between 8 to 9 am where there are values from 9 to 10 am . I think the zeros are diplaying because it's not the correct time. I don't think it's a timezone issue. How can we fix time picker for the dashboard so that it will only displays the results for selected time period(8 am 10 am) with no zeros?
Here are the tokens used for the source code

 <eval token="earliestTime">if(isstr(earliest), relative_time(now(),earliest), earliest)</eval>
 <eval token="latestTime">if(isstr(latest), relative_time(now(),latest), latest)</eval>
 <eval token="earliestTime1">relative_time(earliestTime,"-7d")</eval>
 <eval token="latestTime1">relative_time(latestTime,"-7d")</eval>
 <eval token="earliestTime2">relative_time(earliestTime,"-14d")</eval>
 <eval token="latestTime2">relative_time(latestTime,"-14d")</eval>
 <eval token="earliestTime3">relative_time(earliestTime,"-21d")</eval>
 <eval token="latestTime3">relative_time(latestTime,"-21d")</eval>
 <eval token="earliestTime4">relative_time(earliestTime,"-28d")</eval>
 <eval token="latestTime4">relative_time(latestTime,"-28d")</eval> 
0 Karma

woodcock
Esteemed Legend

Your approach seems very strange to me but in any case, you are missing dollar-signs, so like this:

<eval token="earliestTime">if(isstr(earliest), relative_time(now(),earliest), earliest)</eval>
<eval token="latestTime">if(isstr(latest), relative_time(now(),latest), latest)</eval>
<eval token="earliestTime1">relative_time($earliestTime$,"-7d")</eval>
<eval token="latestTime1">relative_time($latestTime$,"-7d")</eval>
<eval token="earliestTime2">relative_time($earliestTime$,"-14d")</eval>
<eval token="latestTime2">relative_time($latestTime$,"-14d")</eval>
<eval token="earliestTime3">relative_time($earliestTime$,"-21d")</eval>
<eval token="latestTime3">relative_time($latestTime$,"-21d")</eval>
<eval token="earliestTime4">relative_time($earliestTime$,"-28d")</eval>
<eval token="latestTime4">relative_time($latestTime$,"-28d")</eval> 
0 Karma

aberkow
Builder

Have you played around with relative time modifiers such as @h? https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/SearchTimeModifiers#Searching_the...

In this sense, you can have everything snap to the nearest hour, for example:

relative_time(now(),"-h@h"

will snap to 7 PM whether you run this at 8:02 PM or 8:47 PM.

0 Karma

iamsplunker31
Path Finder

@aberkow, Thank you for your response.
1)Do you mean I need to update the tokens as below?
if(isstr(earliest), relative_time(now(),"-h@h"earliest), earliest)
if(isstr(latest), relative_time(now(),"-h@h"latest), latest)
2) When you say if we run the search 8:02 PM or 8:47 PM will snap it to 7 PM. Can't we fix the dashboard/time picker to take specific time. In our case 9am to 11 am
Please Advise

0 Karma
Register for .conf21 Now! Go Vegas or Go Virtual!

How will you .conf21? You decide! Go in-person in Las Vegas, 10/18-10/21, or go online with .conf21 Virtual, 10/19-10/20.