Hello!
I’m currently looking at trying to replicate the functionality that we’re used to with Ganglia using TimescaleDB and Telegraf.
We would like to keep raw host metrics for 30 days, 10 minute aggregates for 6 months and 60 minute aggregates for 3-5 years.
I have set up the CAGGs as follows:
CREATE MATERIALIZED VIEW cpu_10m WITH (timescaledb.continuous) AS
SELECT tag_id,
time_bucket(INTERVAL '10 minutes', time) AS bucket,
AVG(usage_guest) AS usage_guest,
AVG(usage_guest_nice) AS usage_guest_nice,
AVG(usage_idle) AS usage_idle,
AVG(usage_iowait) AS usage_iowait,
AVG(usage_irq) AS usage_irq,
AVG(usage_nice) AS usage_nice,
AVG(usage_softirq) AS usage_softirq,
AVG(usage_steal) AS usage_steal,
AVG(usage_system) AS usage_system,
AVG(usage_user) AS usage_user
FROM cpu
GROUP BY tag_id, bucket;
SELECT add_continuous_aggregate_policy('cpu_10m',
start_offset => INTERVAL '6 months',
end_offset => INTERVAL '30 days',
schedule_interval => '1 day');
SELECT add_continuous_aggregate_policy('cpu_60m',
start_offset => INTERVAL '5 years',
end_offset => INTERVAL '6 months',
schedule_interval => '1 day');
for just average CPU metrics for example.
However, I think that this would require us to keep raw metrics for 6 months (well, actually 7 months) for the cpu_60m
policy to work right? Is there a way I can do this to only keep raw metrics for 30 days at the maximum and have averages over 10 and 60 minutes otherwise please? Could this be done by making the cpu_60m
CAGG select from cpu_10m?
Thank you,
Will.