How to show the latest timestamp for measuring InfluxDB in a Grafana (or singlestat) table?

I use Telegraf / InfluxDB / Grafana to register and view metrics for my servers. Sometimes one of these component edges and metrics stop flowing into InfluxDB.

To be able to notice when this happens (instead of using Monit to restart the service), I would like to create a Grafana dashboard where I have a singlestat dashboard for each host that shows the most recent timestamp (or better, how much time has passed) since the last metric. I would also like to colorize a singlestat background depending on how long it has been. I would like to be able to do this for any InfluxDB metric, as different metrics may have different reasons for the lag.

Right now, I tried something similar in InfluxQL, but I just get an error message that at least one non-temporary field should be present in the request:

SELECT last(time) FROM "system" WHERE "load1" > -1 GROUP BY "host"

If I try to change it to this, I get a “multiple series error”:

SELECT last(time), last("load1") FROM "system" GROUP BY "host"

Am I trying to do something difficult, or am I missing something obvious?

+4
source share
1 answer

Query Influxdb to get the latest timestamp

... the query syntax was taken from somewhere in this issue . I have not looked at the singlestat panel yet, but I suggest creating a “ script panel .
Start by manually creating a dash of a single-paste with a dummy number. Then export it to see what json looks like. Then re-create the same json with the result from the above a query using a scripted toolbar.

grafana/public/dashboards 'scripted.js' 'scripted_templated.js'. , , json. here - javascript, infuxdb json . .

0

Source: https://habr.com/ru/post/1661717/


All Articles