Grafana Loki Storage Retention
By default, when table_manager.retention_deletes_enabled
or
compactor.retention_enabled
flags are not set, then logs sent to
Loki live forever.
The minimum retention period is 24h.
The retention period must be a multiple of the index and chunks table period
, configured in the period_config
block.
Sample config:
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
table_manager:
retention_deletes_enabled: true
retention_period: 24h
The other way to setup the retention in Grafana Loki is via the Compactor.
limits_config:
retention_period: 168h
compactor:
working_directory: /data/retention
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
Note that retention is only available if the index period is 24h.
To purge data immediately you could set the retention_delete_delay
interval to 1m
. This is a delay after which chunks will be fully deleted during retention.
Do not forget to restart Loki after changing the configuration:
systemctl restart loki
systemctl status loki