Changing Retention Time in InfluxDB 2 - WebGUI + Console

Learn how to modify retention time in InfluxDB 2, optimizing data storage and managing retention policies. Improve database performance.

This step-by-step guide explains how to change the retention time in InfluxDB 2. Learn how to modify the duration for storing data, optimize storage space, and manage data retention policies. Improve search engine visibility with this SEO-optimized tutorial.

Change Retention Time via WebGUI Dashboard

1. Access InfluxDB 2:

Open the InfluxDB 2 user interface in your web browser.

2. Navigate to Buckets:

Go to the "Buckets" section and select the desired bucket.

3. Modify Retention Time:

Click on "Manage" for the bucket and navigate to the "Retention" tab. Adjust the duration for storing data according to your needs.

4. Confirm Changes:

Save the changes and confirm the modification of the retention time.

5. Verify Retention Time:

Double-check the new retention time by viewing the bucket's settings or querying the InfluxDB database.

6. Apply to Existing Data:

If you want to apply the retention time changes to existing data, you can run a continuous query to rewrite the data into a new retention policy.

7. Monitor and Optimize:

Regularly monitor your InfluxDB storage usage and adjust retention policies as necessary to optimize storage space and manage data effectively.

Change Retention Time via command line

1. Open Command Line Interface:

Launch your preferred command-line interface, such as Terminal or Command Prompt.

2. Access InfluxDB 2:

Connect to your InfluxDB 2 instance using the Influx CLI tool:

influx

3. Set Retention Policy:

Change the retention time by executing the following command

influx> alter retention policy <retention_policy_name> on <database_name> duration <duration>

Replace <retention_policy_name> with the name of the retention policy you want to modify, <database_name> with the name of your database, and <duration> with the desired duration (e.g., "7d" for 7 days).

4. Verify Changes:

To ensure the retention time modification was successful, query the retention policies for your database:

influx> show retention policies on <database_name>

Verify that the new retention time is reflected in the results.

5. Apply to Existing Data:

If you want to apply the retention time changes to existing data, you can run a continuous query to rewrite the data into a new retention policy.

6. Monitor and Optimize:

Regularly monitor your InfluxDB storage usage and adjust retention policies as necessary to optimize storage space and manage data effectively.