It's possible this already exists (or exists as a request as part of #5930 
<https://github.com/influxdata/influxdb/issues/5930>)...

I'm trying to figure out a way to efficiently calculate the average over a 
given time period of a cumulative value. It is sort of like doing a 
moving_average(non_negative_derivative(field)), but that won't work right 
now since moving_average requires an aggregate function.

Even better, given two fields where one (A) is that cumulative count and 
another (B) is the count of how many values are in that counter.   
Currently, I'm using the java dropwizard/metrics library which does this in 
the application itself, but I would like to be able to arbitrarily 
calculate the moving average later, varying the time units.  
You can imagine doing this for tracking the time it takes to perform some 
action.  So A is the cumulative time spent, and B is the cumulative number 
of actions.  Then you can get a clear time/action metric over varying time 
periods.

perhaps just doing:
SELECT non_negative_derivative(last(A), 1s) / 
non_negative_derivative(last(B), 1s) FROM ...
is all I need.

Is there a better way to handle this with influx that I'm not thinking of? 

-- 
Remember to include the InfluxDB version number with all issue reports
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/f38b8afb-42fd-4733-8bda-065375d03f15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to