Convert long to duration

  • What Grafana version and what operating system are you using?
    v9.2.3

  • What are you trying to achieve?
    display a long value as a duration. This value represents the time left before SSL cert expiry

  • How are you trying to achieve it?
    I have the time in milliseconds but cannot find a way to display it as a duration. Ideally, something like moment.duration().humanize().

In the table below, it is the expires in field that I want to convert to duration

domain      expires at                  exires in
x.y.z       2023-01-07 18:59:59.000     4859190312
w.y.z       2023-01-07 18:59:59.000     4859190312
a.b.c       2023-02-04 18:59:59.000     7278390312
b.b.c       2023-02-07 18:59:59.000     7537590312

Welcome

What is your data source? And what is expires at? Is that what you want the final result to look like?

The data source is Prometheus. The data comes from blackbox exporter. Expires at is (probe_ssl_last_chain_expiry_timestamp_seconds - time())*1000 which is how much time (ms) is left until the cert expires.

Looking for a way to convert it to a readable form in grafana.

Why you can’t use unit Time / duration (ms)?

More than likely because I am not familiar enough with Grafana. Can you explain more please?

1 Like