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!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...