Hi all,
I am a long term user of MRTG+RRDtool, and I am considering using TSDB for my monitoring data. I would like to do the same as MRTG does - to have:
- 5-min average data for the last day and half,
- 30-min aggregate for ~10 days back,
- 1h aggregate for the last month or so, and
- daily aggregate kept indefinitely.
I am able to create various CA-materialized views either on top of the raw data, or on top of each other. But I would like to use them all together - to be able to draw for example a weekly graph not only for the last week, but also further back in history, even though there is only corasely-grained aggregate data available. Is there a better way how to do this than to use a complicated UNION of subselects on all four materialized views, as described here?
Also, when creating an aggregate on top of another aggregate, can the time bucket column use the same name on both aggregates? When I try to do so, I get the continuous aggregate view must include a valid time bucket function
error:
=> create materialized view temperature_5min with (timescaledb.continuous) AS select id, time_bucket(interval '5 mins', time) AS time_bucket,
avg(value), max(value), min(value) from temperature GROUP BY id, time_bucket;
NOTICE: refreshing continuous aggregate "temperature_5min"
HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation.
CREATE MATERIALIZED VIEW
=> create materialized view temperature_30min
with (timescaledb.continuous)
as
select time_bucket(interval '30 min', temperature_5min.time_bucket) as time_bucket,
id,
avg(avg), min(min), max(max)
from temperature_5min
group by id, temperature_5min.time_bucket;
ERROR: continuous aggregate view must include a valid time bucket function
I am probably missing a column alias ... AS something
somewhere, but can’t figure out where. And all the examples I have seen so far seem to use a different name of the time column in the upper and lower aggregates.
Thanks!
-Yenya