Singlestat Coloring duration

Hi there,

I’m new to Grafana (using 6.7.2 windows build) and I’m currently struggling to coloring the background in Singlestat panel. I have already searched the community and have tried a couple of things but unfortunatley with no success. So please bear with me if this question is actually already answered.

I think the problem is the time format of my query output.

As you can see the unit is set to duration (hh:mm:ss) what matches exactly my query output. But why is the thresholds are ignored? What I want to achiev is a dynamic background with coloring like this

if (value <= 01:00:00)
Green
else if (value > 01:00:00 AND value <= 02:00:00)
Yellow
else if (value >= 03:00:00)
Red

Any help is much appreciated.

Thanks,

Sven

You’re setting the thresholds based on the formatted value (hh:mm:ss) rather than the value in the query result.

If I assume that the query returns UNIX timestamps, the threshold should be something like:

IF (value <= 3600000) THEN GREEN

where 3600000ms = 1h

Hi Marcus,

thanks for you quick answer. But no, this is indeed the query output. Here is the important part of the query what I’m using to calculate time averages out of a Maria DB datasource.

SELECT
TIME_FORMAT(SEC_TO_TIME(avg(hour(Bearbeitungszeit) * 3600 + (minute(Bearbeitungszeit) * 60) + second(Bearbeitungszeit))),’%H:%i:%s’) Bearbeitungszeit
FROM
(

)

But maybe I don’t need the formatting in the query itself, probably I can just use a unix timestamp and the formatting will be done in the value unit. Probably with unix timestamp query output the threshold function can work better.

I will give it a try and will give feedback.

Thanks,

Sven

I have tried a couple of thins with unix timestamp query results and it seems grafana interpreted it not quite correctly.

I have now a unit timestamp with 1586988004 what can be convert in a correct date

image

When I change my query in Grafana I get the same output first but the coverting is strange when I set unit to a datetime value.

The unit duration comes more close to what I try to achieve, but why I dont’t get just hh:mm:ss as desired?

Could it be there is a difference as a unix timestamp is intepreted between my local maria db and grafana?

Anyway, no change a hh:mm:ss query output can used in singelstat thresholds?

Thanks,

Sven

You are pretty correct. The threshold should be in seconds. It worked for me in any Grafana dashboard. Currently I am using hh.mm.ss unit but should be same for any time units