How to show "33 minutes ago" on Grafana dashboard with InfluxDB?
Asked Answered
U

3

14

I have recently set up Grafana with InfluxDB. I'd like to show a panel that indicates how long it has been since an event took place.

Examples:

  • Server last reported in: 33 minutes ago
  • Last user sign up: 17 minutes ago

I can get a single metric pretty easily with the following code:

SELECT time, last("duration") as last_duration FROM custom_events ORDER BY time DESC

But I can't seem to get Grafana to do what I want with the time field.

Any suggestions?

Underlet answered 26/2, 2016 at 0:13 Comment(5)
What is grafana showing? Nothing? Or is the time just improperly rounded?Blacksmith
@Blacksmith Grafana just shows the metric "last_duration", but not the time.Underlet
So on the Y axis is the last_duration, isn't the X axis the timestamp?Blacksmith
@Blacksmith Grafana will not allow me to use the timestamp or a tag as a value. It will only allow me to use an InfluxDB field as a value.Underlet
@Blacksmith There are no X- and Y-axis on a Grafana table or singlestat panel.Cytolysin
S
16

Since Grafana(4.6.0) this is now possible with singlestat panels.

  1. GoTo the Options-Tab
  2. Select Value -> Stat -> Time of last point
  3. Select Value -> Stat -> Unit -> Date & time -> From Now

enter image description here

Synonymize answered 16/3, 2018 at 12:40 Comment(0)
T
1

Its currently(4.0.3) not possible to show the last timestamp in singlestat panels. But there is an issue for supporting this. Hopefully we will find time to implement this in the future.

Tradesfolk answered 12/12, 2016 at 17:36 Comment(0)
V
0

In 8.4.0 There is a unit selection that allows you to do this, make sure your timestamp is in milliseconds since the epoch and select From Now as the unit in the dropdown menu

singlestat pannel expressing time since

Virtue answered 7/4, 2022 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.