You want the FOR clause, which will cause the CQs to recalculate prior intervals and pick up any newly written points in those intervals. https://docs.influxdata.com/influxdb/v1.0/query_language/continuous_queries/#advanced-syntax. E.g.
CREATE CONTINUOUS QUERY foo ON db RESAMPLE EVERY 20s *FOR 2m * BEGIN SELECT median(aa) AS aa INTO foomeas FROM barmeas GROUP BY time(20s),* END Note that the GROUP BY time offset just moves the beginnings of the buckets, delaying the query execution time is just a side effect. I've removed it from the query. On Wed, Oct 12, 2016 at 10:43 AM, Michael C <[email protected]> wrote: > I was wondering if someone out there could offer some advice on setting up > a CQ for my system. It would appear CQs might not be powerful enough to > accomplish what i'm after, but im still new-ish to influx so maybe im wrong? > > > I have a system where multiple nodes out in the world transmit packets of > data once per minute, that contain 60 samples each, 1 for each second. The > data is received and stored in influxdb. Note that this packet of 60 > samples from a given node could be received at any time over the minute. > Thus, from influx's perspective there could be up to 1 minute of latency > before receiving the next 60 seconds of data with respect to the start of > each new minute. > > With this set up, I would like to have a CQ perform a 20second median on > the second by second data. > > However it would seem that the latency of my system poses a problem to CQ > usage. It would seem that CQ's need to execute within the vicinity of > now() and for my case would occur on a 20second clock boundary. Given my > setup, there would be many cases where the data simply hasnt arrived yet > when the query ran due to my 1 minute latency. I tried adding an offset in > the GROUP BY time(), but this doesnt seem to work (as expected after > reading the docs, https://docs.influxdata.com/ > influxdb/v1.0/query_language/continuous_queries/) > > > Below is an example of one of the many queries I have tried: > > CREATE CONTINUOUS QUERY foo ON db RESAMPLE EVERY 20s BEGIN SELECT > median(aa) AS aa INTO foomeas FROM barmeas GROUP BY time(20s, -60s),* END > > > Is there any way to make CQs work with my system given the latency? > > I suspect it would work if I were computing 5 minute medians as I could > then offset by -1m, but that is not what i'm after. Or maybe im confused. > > Any advice would be much appreciated! > > Mike > > -- > Remember to include the version number! > --- > You received this message because you are subscribed to the Google Groups > "InfluxData" 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/7574ae65-fdcf-4417-b299-d72471d79ff8%40googlegroups.com > <https://groups.google.com/d/msgid/influxdb/7574ae65-fdcf-4417-b299-d72471d79ff8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Sean Beckett Director of Support and Professional Services InfluxDB -- Remember to include the version number! --- You received this message because you are subscribed to the Google Groups "InfluxData" 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/CALGqCvNP2uSHa1phrOpQKxojTWYcoTs7cq8d4RD9-a9dKRjV0A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
