Using Grafana Cloud w. Influxdb3 (cloud), so I can use either SQL or InfluxQL, but not Flux.
I want to find the average value of a field (“distance”) during a one-minute period before the field “extruder_target” gets a non-zero value. How can I do that?
I’ve tried setting a template variable to the time value of the event, but it seems I cannot. I tried setting a template variable with:
SELECT time as timestamp
FROM gantry
WHERE extruder_target > 0
AND time >= $__timeFrom AND time <= $__timeTo
ORDER BY time ASC
LIMIT 1
and then using that variable, but it seems not to get populated:
SELECT distance, time FROM "gantry" WHERE time > $__timeFrom and time < $heatingStart
flightsql: rpc error: code = InvalidArgument desc = Error while planning query: SQL error: ParserError("Expected: an expression:, found: EOF")
I do not need to use a template variable, any solution would be ok.