We have the requirement that the whole monitoring infrastructure has to be bootstrap-able in remote environments without internet connectivity. We want to automatically create the continuous aggregates after the timescaledb server has been set up using an plpgsql script:
set role timescale;
CREATE MATERIALIZED VIEW cpu_hourly
WITH (timescaledb.continuous) AS
SELECT
time_bucket(INTERVAL '1 hour', time) as bucket,
*
from cpu
group by bucket, host
WITH NO DATA;
select add_continuous_aggregate_policy('cpu_hourly', start_offset => INTERVAL '1 day', end_offset => INTERVAL '61 minutes', schedule_interval => '1 hour');
grant select on cpu_hourly to grafana;
reset role;
The problem is, that at the time that this script is executed, no metrics have yet been reported to the server by telegraf and therefore none of the tables required for the select exist. Some metrics might take multiple hours to be sent to the server.
Are any solutions to this problem?