Problem with Stat Panel

Hi,
I have a dashboard with the panel stat, this panel read data a mysql table,
I have 2 boolean states, 0 or 1 I want to play with these values ​​make a state label with color depending on what is being read from the table, 0 would be yellow, 1 would be green and finally if not no more are written rows in the table that interprets that there is no value and turns red.

my problem is that when values ​​or rows are not being inserted in the table it always shows me the last value, either 0 or 1, so I can never show the label in red, I have tried to configure show last value and last value not null and it doesn’t work.

This is my configuration panel:


Right now it’s been more than an hour since I have records in the table

and as you can see the panel is green because the last value was 1 and my need is that when no data is recorded it turns red.

my query to mysql table is this:

Does your request ever return a value that isn’t 0 or 1? A special value like undefined or NaN?

FWIW:
Prometheus has a built-metric called up{} where every time it scrapes an endpoint, it returns 1 for up and 0 for down.

It works very well for service monitoring like you are describing.

It is an option that I had also thought of, that when it has no state, it returns a NAN, and with that in Stat I could configure it, what happens is that I do not want to modify the code that it inserts in the database if possible.

I’m going to try Prometheus and if I can’t, I’ll have to modify the scripts that insert into the mysql tables.

Thank you very much for your contribution, I keep you informed

1 Like