I want to monitor and highlight when data in tables has not been updated for a while. The tables all have CreateDate fields so I use the last CreateDate to determine if the table has not been written to for X hours by using a max(CreateDate) in the SQL
What would be the best way to represent this on a Grafana Panel? It would be great to see it going amber when itβs close to too old and then red when it is out of date.
How about use a Stat panel to display the last Create date? Not sure if you will be able to set up thresholds (color of Stat panel to change) based on X hours or such, but you can try.
setTimeout(() => {
var x = document.getElementsByClassName(βcss-1hlp2knβ);
var date = 0
for (i = 0; i < x.length; i++) {
if (x[i].innerHTML.startsWith(β20β)) {
if (Date.parse(x[i].innerHTML) > date) {
date = Date.parse(x[i].innerHTML)
}
}
}
var now = new Date();
var diff = now - date;
var msec = diff;
var hh = Math.floor(msec / 1000 / 60 / 60);
msec -= hh * 1000 * 60 * 60;
var mm = Math.floor(msec / 1000 / 60);
msec -= mm * 1000 * 60;
var ss = Math.floor(msec / 1000);
msec -= ss * 1000;
if (hh > 0) {
hh = (β0β + hh).slice(-2)
res = hh + β:β + mm + β:β + ss
} else {
mm = (β0β + mm).slice(-2)
ss = (β0β + ss).slice(-2)
res = mm + β:β + ss
}
$(β#lastUpdateβ).text(res);
}, 4000);