How do I schedule a Continuous Query to run at a set time every day?

Hello All,

I’m trying to create a continuous query that will go off at 2am every morning and downsample the last days metrics. I was wondering how influxdb responds to a group by time() of anything over 24h (Such as 25h or 26h), as the CQ goes by preset time boundary’s would this result in the CQ being run 1 or 2 hours after midnight (1am or 2am) where a usual 24h preset would run or would it simply reject this?

I have tried looking this up online but to no avail unfortunately

@William_Tyler CQs (InfluxQL) only allow for duration based time ranges, and with the basic time GROUP BY time() statement, will execute at that interval. If you specify 25h or 26h, it will execute that specific cadence and begin to increment the hour of the day the CQ actually runs.

To do what you’re trying to do, you can use an offset interval in your CQ time range:

GROUP BY time(24h,2h)

This CQ will run every 24 hours, but query the time range 2:00am (yesterday) to 1:59:59am (today), which may not be what you’re after.

Another option would be to upgrade to InfluxDB 2.x and use a Flux task to run this same operation. Flux tasks let you define execution times on a cron schedule. You also have much more control over what time range is actually queried.

1 Like

Yes, I think this is exactly what I’m after, you’re a legend, thank you!