Timezone in prometheus dashboard

1,560 views
Skip to first unread message

PK

unread,
Dec 10, 2021, 1:09:44 AM12/10/21
to Prometheus Users
Hi everyone,
Can anyone let me, Is it possible to get  local time support instead of UTC in prometheus dashboard?

Brian Candler

unread,
Dec 10, 2021, 3:26:27 AM12/10/21
to Prometheus Users
What version of prometheus are you running?  I am running 2.30.3 and for me it shows a checkbox for selecting local time in the local web UI on port 9090:

img1.png

Otherwise, when you say "prometheus dashboard" do you mean some external dashboard software like Grafana?  If so, the question relates to that software, not to prometheus.

PK

unread,
Dec 13, 2021, 12:25:07 AM12/13/21
to Prometheus Users
Thank you for your answer, but I have a different scenario as below mentioned:
Let's I want to make data available at the metric endpoint along with its timestamp(the time at which we got this data). But the system time is in PDT and I also want the Prometheus dashboard x-axis with this PDT time, not in(UTC or equivalent local time).

In go there is an API  NewMetricWithTimestamp(time,metric)
but here time is in UTC so I need to convert my PDT time to UTC and then this API returns the data value with the timestamp in milliseconds. So on the Prometheus dashboard, we are able to see the equivalent UTC time.  

Stuart Clark

unread,
Dec 13, 2021, 2:47:24 AM12/13/21
to PK, Prometheus Users
On 13/12/2021 05:25, PK wrote:
Thank you for your answer, but I have a different scenario as below mentioned:
Let's I want to make data available at the metric endpoint along with its timestamp(the time at which we got this data). But the system time is in PDT and I also want the Prometheus dashboard x-axis with this PDT time, not in(UTC or equivalent local time).

In go there is an API  NewMetricWithTimestamp(time,metric)
but here time is in UTC so I need to convert my PDT time to UTC and then this API returns the data value with the timestamp in milliseconds. So on the Prometheus dashboard, we are able to see the equivalent UTC time.  

There are two things to mention:

1. The timestamp within the Prometheus metric would always be in UTC regardless of the timezone of the application or Prometheus server.

2. Timestamps should pretty much never be used with metrics. Definitely not if you are instrumenting an application, with one of the few use-cases being connecting a third-party metrics system into Prometheus.

-- 
Stuart Clark

Brian Candler

unread,
Dec 13, 2021, 3:46:34 AM12/13/21
to Prometheus Users
On Monday, 13 December 2021 at 05:25:07 UTC princ...@gmail.com wrote:
Let's I want to make data available at the metric endpoint along with its timestamp(the time at which we got this data). But the system time is in PDT and I also want the Prometheus dashboard x-axis with this PDT time, not in(UTC or equivalent local time).

Prometheus handles timestamps as "epoch" values: the number of milliseconds since 1st Jan 1970 UTC.  This is what is stored in the database and returned from queries.  (As Stuart says: the exporter should almost never supply a timestamp anyway; the current timestamp is added by prometheus when it writes the value to the database)

If you want to *display* values in a human-readable form in your dashboard, and in any given timezone (say PDT), then that is a function of the dashboard software.
Reply all
Reply to author
Forward
0 new messages