-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Is your feature request related to a problem? Please describe.
We have a usecase where we'd like to be able to collect statistics on the frequency of data recieved by a sensor (avg/stdev). ATM we've had to do this in a rather hacky way, but this feels like an easy agg to build into timescaledb-toolki
Describe the solution you'd like
I think we could have a 2 step rollup agg. Which could be used like:
with frequencies as (SELECT
sensor_uuid,
frequency_agg(time) as agg
FROM
datapoint
WHERE
time >= NOW() - '1 MONTH'::INTERVAL
)
select,
sensor_uuid,
average(agg),
stddev(agg)
from
frequencies
This would hopefully also support rollups, etc. Its a bit like a heartbeat agg, but:
- We dont care about when its dead or not. just about frequency of the heartbeat?
- We dont need to supply a time, thats g
Describe alternatives you've considered
We've got some implementation of this, but its hacky. We basically had to:
- Create a function that takes a list of timestamps, and calculates their diff
- Create another function to allow a stats_agg of a list
- We then use avg, stddev etc on that.
Additional context
I thought what we needed was: #770, but actually what we need to do is calculate the avg frequency, and then i want to be able to use that in a heartbeat agg, which while this PR is kinda nice as a feature, creates a chicken and egg problem! having some kinda frequency agg would be great.
I'd be interested in helping out with development of this if needed