InfluxDB Data Retention

PUBLISHED ON 10/10/2019 — SYSOPS

Setting up 1 year data retention policy on existing database. Data older than 1 year will automatically drop out.

# influx
Connected to http://localhost:8086 version 1.7.8
InfluxDB shell version: 1.7.8
>

Select the database you want to modify

> use telegraf
Using database telegraf
>
> show retention policies;
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true
>
> alter retention policy "autogen" on "telegraf" duration 52w shard duration 168h default
>

Empty prompt means successful change.

We can check it again:

> show retention policies;
name    duration  shardGroupDuration replicaN default
----    --------  ------------------ -------- -------
autogen 8736h0m0s 168h0m0s           1        true
>

After a few minutes, the data will be cleared and the changes will be seen.

See Also