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$ < 60, 1,$secbetween$ < 300,5, $secbetween$ < 600,10,$secbetween$<1800,30,$secbetween$<3600,60,$secbetween$<7200,120,$secbetween$<10800,180,$secbetween$<21600,360$secbetween$<43200,720,$secbetween$<86400,1440,$secbetween$>86400,1440)</eval>
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>