How to graph tags values alongside fields values on timeseries graph panel? #118
Description
Hi,
I am aware of how to add threshold in Grafana Dashboard in the viz options but I'm exploring a different way to visualize the threshold values using influxdb tags as part of the measurement. This was briefly mentionned in a session from InfluxDays 2020 that it is possible towards the end. Below is what I tried using grafana 7.1 beta with the out of the box influxdb datasource with Flux configured.
Im currently trying out sending threshold values as tags from telegraf to influxdb as below for cpu usage.
# Read metrics about cpu usage
[[inputs.cpu]]
## Whether to report per-cpu stats or not
percpu = true
...
# threshold
[inputs.cpu.tags]
warning = "80"
error = "85"
critical = "90"
Then, in grafana, the influxql query would get the tags values for those threshold tags. Grafana is able to graph those threshold tags if I drop aggregate functions from the query.
SELECT usage_user, usage_system, usage_softirq, usage_steal, usage_nice, usage_irq, usage_iowait, usage_guest, usage_guest_nice, critical, error, warning FROM "cpu" WHERE "host" =~ /$server$/ and cpu = 'cpu-total' AND $timeFilter GROUP BY host
Below a screenshot of how it is rendered.
Showing the same using table:
Now, I tried to do the same with Flux, but it does not graph them as expected. I dont think we can force Grafana to tell it to graph tags values as it could be any string but in this case we are passing digits in string format.
The query is able to get threshold tags value for sure as show below.
I saw a transform that convert labels to fields but that only seem to work for table format. Is it not possible to have this working for graph format if the tags values are numbers?
Finally, I was trying to use another transform "Add Field from calculation" to see if I could tell it to use tag values insteaf of field values, but the transform only expect field or hardcoded number as below. Is it possible to have it working with tags values?
Thanks.