Custom unit to show durations

  • What Grafana version and what operating system are you using?
    Grafana 9.2.3 running in a docker container on debian host

  • What are you trying to achieve?
    I want to Display a Bar chart that shows durations (Hours:minutes) on the y-axis

  • How are you trying to achieve it?
    I have a duration field (interval) from a postgres datasource.
    The query is a bit more complex, the relevant select part is this:

SELECT 
  time,
  EXTRACT(epoch FROM duration)*1000 as duration,
  ---...

First I divided the duration/epoch by 3600, so I would get a float that represents hours.
However this leads to the y Axis and the bar-labels showing values like 5.5 where I would prefer to read 5:30 if possible.

To solve this, I am tried to use the following custom unit in Standard options:

time: H:mm

and since the input for custom time: formats apparently expects milliseconds, I am multiplying the epoch value by 1000

  • What happened?
    The duration is interpreted as time with a timezone.
    The local timezone is used (CET which is +1h right now) and consequently a duration of 0 is displayed as 1:00 (i.e. one hour) instead of 0

  • What did you expect to happen?
    I would LIKE the value to be interpreted as duration, effectively to ignore the timezone, or simply overwrite it with UT such that 0 is 0.