Coloring Stat value based on result of second query (transforms)

Hi all!

My goal is to change the color of a stat value, based on the result of another query (on the same row in this case). Influx data looks like this:

timestamp float error_state
164566 22.1 1

The float value should be colored based on the value of error_state (traffic lights):

error_state color
1 green(ok)
2 orange(warn)
3 red(error)

The two queries look like this:

float:
SELECT mean("float") FROM "autogen"."nodes_hist" WHERE ("nodeId" = 'c57ab2fdfce1b7a1cf4e32d3638fc159') AND $timeFilter GROUP BY time($__interval) fill(none) ORDER BY time DESC LIMIT 10000
error_state:
SELECT last("error_state") FROM "autogen"."nodes_hist" WHERE ("nodeId" = 'c57ab2fdfce1b7a1cf4e32d3638fc159') AND $timeFilter GROUP BY time($__interval) fill(none) ORDER BY time DESC LIMIT 10000

I went through the documentation of transforms and to me it sounds like Config from query results should do what I want. So I implemented the following transform:

I tried various Use as configurations (value mappings, …) but none of them worked for the coloring. It seems I’m not in general on the wrong path, since when I use decimals or unit it works like expected (see images). Still I do not get the coloring based on external value working.

Any help would be appreciated!

Regards,
Oliver

I was unable to do it in Stats

image

but it is doable in Dynamic Text (you will need to pretty it up a bit more)

1 Like

Thanks! I would prefer using the Stats element but if this fails, I can go back to dynamic text. I would expect it is possible transforms on Stats but how… Maybe someone comes up with an idea?

Oliver

1 Like

Anyone else having an idea on how to get this working on a Stat value?

Thanks and regards,
Oliver

Just as a feedback. What I now did is little ugly IMHO but the best solution I could come up with.
I moved the error_state query to dashboard variables. I can now access the result of the error state via a variable. The lookup from [1|2|3] to [green|yellow|red] I realized via my Redis data source. See below:

variable

queries

transforms

1 Like