I need to display data in Table panel, highlighting values that are greater than average of current query result.
For example, if my query returns values ‘16.25, 7.96, 9.12, 9.03, 8.76, 8.85, 9.21’, I need to change color of 16.25.
If dynamic thresholds (i.e. specify variable in Thresholds section) were supported, that could be done easily, but that’s not possible as of now.
So I perform the following steps:
I calculate average value using the following variable MyVar:
from(bucket: "MyBucket")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) =>
r["_field"] == "MyField")
|> group(columns: ["_measurement", "_field"])
|> last()
|> group()
|> mean()
To my query I add an extra column to be used for configuration later:
|> map(fn: (r) => ({ r with Avg: ${MyVar} }))
I am using ‘Config from query’ transformation to specify Threshold1:
This is a result I receive:
The only problem now is that I can’t change these colors (i.e. red and green).
Any ideas how to change these colors? Or how to solve main task (highlight values that are above average) in the other way?
I also tried to specify ‘Color’ instead of ‘Threshold1’ from 'Config from query, but didn’t succeed with it.
I am using Grafana 10.2.6