Hi all
I’m trying to work out a way to differentiate the results from different Flux queries when run as part of the same panel. Here’s the code:
import "date"
month = date.truncate(t: now(), unit: 1mo)
from(bucket: "Power")
|> range(start: month)
|> filter(fn: (r) => r["_measurement"] == "consumption")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["series"] == "House")
|> filter(fn: (r) => r["_value"] > 0)
|> sum()
|> map(fn: (r) => ({ r with _value: r._value / 1000.0 * 0.1413 }))
|> yield(name: "Consumed")
from(bucket: "Power")
|> range(start: month)
|> filter(fn: (r) => r["_measurement"] == "consumption")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["series"] == "Hot_Water")
|> sum()
|> map(fn: (r) => ({ r with _value: r._value / 1000.0 * 0.1283 }))
|> yield(name: "Hot Water")
from(bucket: "Power")
|> range(start: month)
|> filter(fn: (r) => r["_measurement"] == "consumption")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["series"] == "House")
|> filter(fn: (r) => r["_value"] < 0)
|> sum()
|> map(fn: (r) => ({ r with _value: r._value / 1000.0 * 0.49 }))
|> yield(name: "Feed-In")
Both results from the House series end up labelled value House. The _result field that should be populated by the yield() function doesn’t appear to be presented to Grafana. When I run the same query in InfluxDB explorer, it seems to work.
Because the two House results have the same label, there is no way to differentiate them to override the display label.
Any ideas?