Hi all, I’m trying to display in a Singlestat panel the uptime of a Docker container.
I’m using InfluxDB and Telegraf along with Grafana.
Telegraf sends the field “started_at” to Influx, which stores the EpochNano timestamp of the moment when the container is started.
In Grafana I’m using this query to convert the timestamp from EpochNano to just Epoch
“SELECT mean(“started_at”) / 1000000000 FROM “docker_container_status” WHERE (“container_name” = ‘influxdb’) AND $timeFilter GROUP BY time(1s) fill(null)”
The important part is the “/ 1000000000”.
After that is performed I have the Epoch timestamp (number of seconds passed since 01/01/1970 to the moment I started the container). That’s ok as far as I can tell. But when I go to “Visualization (Singlestat) > Value > Unit > Time & Date” and choose “From Now” my panel displays:
49 years ago.
The “raw” value (after dividing it by 1000000000) is:
So I guess that what’s actually happening is that “From Now” is showing me the result of (my_timestamp - 01/01/1970_timestamp) instead of (now_timestamp - my_timestamp).
Is it a bug? Is it intended to work that way?
And if it’s intended, do you know some trick to make the Singlestat panel to show me the amount of time passed since my timestamp? (Remember that I want to see the uptime of my docker container).