Quantcast
Channel: InfluxDB - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 199

How to get an average around an event?

$
0
0

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.

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 199

Trending Articles