If you want to implement features not supported by those policies, you can write a user-defined action to downsample and compress chunks instead. The following example downsamples raw data to an average over hourly data. This is an illustrative example, which can be done more simply with a continuous aggregate policy. But you can make the query arbitrarily complex.
Create a procedure that first queries the chunks of a hypertable to determine if they are older than the
lagparameter. The hypertable in this example is named
metrics. If the chunk is not already compressed, downsample it by taking the average of the raw data. Then compress it. A temporary table is used to store the data while calculating the average.
Register the job to run daily. In the
lagto 12 months to drop chunks containing data older than 12 months.
Found an issue on this page?Report an issue!