Open SGStino opened 4 years ago
previous = from(bucket: "Bucket") |> range(stop: v.timeRangeStart, start: 0) |> filter(fn: (r) => r["_measurement"] == "Tags.PLC_252.TANK1.LEVEL") |> filter(fn: (r) => r["_field"] == "value") |> last() current = from(bucket: "Bucket") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "Tags.PLC_252.TANK1.LEVEL") |> filter(fn: (r) => r["_field"] == "value") |> aggregateWindow(every: v.windowPeriod, fn: last) union(tables: [previous, current]) |> set(key:"_field", value:"test") |> yield()
This results in 2 series in grafana, both named "test". One containing a single value, the other one containing the range.
For grafana, this is equivalent:
from(bucket: "Bucket") |> range(stop: v.timeRangeStart, start: 0) |> filter(fn: (r) => r["_measurement"] == "Tags.PLC_252.TANK1.LEVEL") |> filter(fn: (r) => r["_field"] == "value") |> last() |> yield(name:"A") from(bucket: "Bucket") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "Tags.PLC_252.TANK1.LEVEL") |> filter(fn: (r) => r["_field"] == "value") |> aggregateWindow(every: 1s, fn: last) |> yield(name:"B")
To get the desired result, i need to use grafana's merge transform. But if there are multiple queries, they will all get merged instead. This means that it seems impossible to have multiple queries in the same panel?
To remedy, it would seem to be as simple of piping the union to window(every: inf)
window(every: inf)
This results in 2 series in grafana, both named "test". One containing a single value, the other one containing the range.
For grafana, this is equivalent:
To get the desired result, i need to use grafana's merge transform. But if there are multiple queries, they will all get merged instead. This means that it seems impossible to have multiple queries in the same panel?