InfluxDB : How to update duration of an existing database
Asked Answered
C

1

7

I have a database created with default retention policy which is infinite.

# SHOW RETENTION POLICIES ON "my_database" name duration shardGroupDuration replicaN default ---- -------- ------------------ -------- ------- autogen 0s 168h0m0s 1 true

How I can modify the retention-policy of the live database so that from now it keeps data only for last 10 days?

Costrel answered 18/7, 2017 at 16:1 Comment(0)
C
22

Easiest solution is to change(update) the current retention-policy.

ALTER RETENTION POLICY "autogen" ON "my_database" DURATION 10d

Now, after a while (ranging from 30m to 1h or more), InfluxDB will reflect the new retention-policy and trim the database off the data older than the specified 10 days.

Another approach can be to create and employ a new retention policy. Check the doc for more: https://docs.influxdata.com/influxdb/v1.2/query_language/spec/#alter-retention-policy

Costrel answered 18/7, 2017 at 16:1 Comment(4)
Would this change duration of retention policy "autogen" if it is used on other databases? Because if you have "autogen" on all databases, would that impact others?Santoyo
it is a per database setting so it wont impact other databases.Petulance
does that remove the existing data injected into db that before you alter the policy?Compare
@Compare if the new retention limit is less than the old one, then yes. The data for the extra days will be deleted, but its not instantly.Costrel

© 2022 - 2024 — McMap. All rights reserved.