table manager does not purge chunk in loki 2.4
I wanted to have a deletion of chunk data older than 31 days so I made such config
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
storage_config:
boltdb_shipper:
active_index_directory: "/var/lib/loki/boltdb-shipper-active"
cache_location: "/var/lib/loki/boltdb-shipper-cache"
cache_ttl: 24h
shared_store: filesystem
filesystem:
directory: /var/lib/loki/chunks
chunk_store_config:
max_look_back_period: 0s
table_manager:
retention_deletes_enabled: true
retention_period: 31d
but actually the deletion never happen.
did I forget something in the configuration ?
loki version: 2.4.1
Solution 1:
I'm not sure it's your case, but starting on the Loki 2.4.0, the single binary no longer runs a table-manager, this impacts anyone in the following scenarios:
- Running a single binary Loki with any index type other than boltdb-shipper or boltdb
- Relying on retention with the configs retention_deletes_enabled and retention_period
See more info and how to resolve this issue, in the Loki Upgrade Guide, here.
Solution 2:
Retention in Grafana Loki is achieved either through the Table Manager or the Compactor. In your case, boltdb-shipper is used for index and chunks. Table manager isn't a great choice when it comes to local storage.
The Compactor retention will become the default and have a long-term support. It supports more granular retention policies on per tenant and per stream use cases.
Please kindly check the Guide here
compactor:
retention_enabled: true
retention_delete_delay: 2h <amount of hours to delay the retention period>
retention_delete_worker_count: 150
limits_config:
retention_period: [30d]