Changing Metric InfluxDB Retention Policies¶
This document will provide the steps that are needed to change how many days of data is stored in InfluxDB. The default configuration is to store the following amount worth of data:
-
Raw - default 14 days
-
Hourly (1hr consolidation) - default 3 months
-
Daily (24hr consolidation) - default 2 years
Note
-
For single server installations, this value can be reduced to save hard drive space.
-
For installations using InfluxDB database redundancy, this value must be changed by accessing the configuration on all affected database servers. A change made on one server will not be automatically copied to the other server.
Steps¶
-
Start a command line session to the server with the InfluxDB database.
-
Login to the database using the Assure1 shortcut:
a1influxroot
Note
If a "command not found" error is returned, the following can be run to load the Assure1 shortcuts:
source $A1BASEDIR/.bashrc
Next, run "a1influxroot" again.
-
The following can be used to get the current retention policies:
show retention policies;
-
One or more of the following queries can be used to change the retention policies. The below make the following changes:
-
Raw is changed to store 20 day's worth of data.
-
Hourly is changed to store 100 day's worth of data.
-
Daily is changed to store 800 day's worth of data.
ALTER RETENTION POLICY "raw" ON "Metric" DURATION 20d REPLICATION 2 SHARD DURATION 2d DEFAULT ALTER RETENTION POLICY "hourly" ON "Metric" DURATION 100d REPLICATION 2 SHARD DURATION 1w ALTER RETENTION POLICY "daily" ON "Metric" DURATION 800d REPLICATION 2 SHARD DURATION 30d
Warning
If increasing the number of days of data to keep, additional hard drive space will be utilized. This must be taken into consideration before changing the retention value.
-
-
Run the "show retention policies" query again and verify that the new value(s) are reported:
show retention policies;