Dashboards & Visualizations

Dashboard TimePicker using always the UTC

damucka
Builder

Hello,

I need the dashboard time picker to use always the UTC time independent on the user TZ. 

How would I do this?

Could someone paste the corresponding code?

I was trying to copy paste some code that I found in the google, see below, but I am failing on the translation of the SPL into the dashboard XML commands. Like e.g. the below would not execute the regex properly - I mean I would not know how to do this. Then the UTCtime does not get set and the following commands are not working.

Any ideas?

Kind Regards,

Kamil

 

 

    <input type="time" token="date_time" searchWhenChanged="true">
      <label>Time</label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
      <change>
        <eval token="MYtime">strftime(now(), "%m/%d/%Y %H:%M:%S %Z")</eval>
        <eval token="UTCtime">MYtime</eval>
        <eval token="UTCtime">rex field=UTCtime mode=sed "s/\s+\S+$/ UTC/"</eval>
        <eval token="UTC_time">strptime(UTCtime, "%m/%d/%Y %H:%M:%S %Z")</eval>
        <eval token="TZdelta">round(_time - UTC_time, 0)</eval>
        <eval token="earliestUTC">'earliest' + $TZdelta$</eval>
        <eval token="latestUTC">'latest' + $TZdelta$</eval>
        <eval token="form.from">strftime(relative_time(now(),'earliest'), "%F %T")</eval>
        <eval token="form.to">strftime(relative_time(now(),'latest'), "%F %T")</eval>
        <eval token="stop_ts_from">relative_time(now(),'earliest')*1000</eval>
        <eval token="stop_ts_to">relative_time(now(),'latest')*1000</eval>
        <eval token="curr_date_from">strftime($stop_ts_from$/1000,"%Y%m%d")</eval>
        <eval token="curr_date_to">strftime($stop_ts_to$/1000,"%Y%m%d")</eval>
        <eval token="timediff">strptime($form.to$, "%Y-%m-%d %H:%M:%S")  - strptime($form.from$, "%Y-%m-%d %H:%M:%S")</eval>
        <eval token="secbetween">$timediff$/1800</eval>
        <eval token="timegran">case($secbetween$ &lt; 60, 1,$secbetween$ &lt; 300,5, $secbetween$ &lt; 600,10,$secbetween$&lt;1800,30,$secbetween$&lt;3600,60,$secbetween$&lt;7200,120,$secbetween$&lt;10800,180,$secbetween$&lt;21600,360$secbetween$&lt;43200,720,$secbetween$&lt;86400,1440,$secbetween$&gt;86400,1440)</eval>

 

 

 

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It looks like you are missing some $s around token names - I don't know if the following will work, but you could try using replace instead of rex?

        <eval token="UTCtime">$MYtime$</eval>
        <eval token="UTCtime">replace($UTCtime$,"\s+\S+$"," UTC")</eval>
        <eval token="UTC_time">strptime($UTCtime$, "%m/%d/%Y %H:%M:%S %Z")</eval>
        <eval token="TZdelta">round(now() - $UTC_time$, 0)</eval>
0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...