Loki Storage Retention
Retention in Loki is achieved through the Table Manager.
In order to enable the retention support, the Table Manager needs to be
configured to enable deletions and a retention period. Please refer to the
section of the Loki configuration reference for all available options.
table-manager.retention-deletes-enabled command line flags can be used. The
provided retention period needs to be a duration represented as a string that
can be parsed using Go’s time.Duration.
NOTE: To avoid querying of data beyond the retention period,
chunk_store_configmust be set to a value less than or equal to what is set in
Currently, the retention policy can only be set globally. A per-tenant retention policy with an API to delete ingested logs is still under development.
Since a design goal of Loki is to make storing logs cheap, a volume-based deletion API is deprioritized. Until this feature is released, if you suddenly must delete ingested logs, you can delete old chunks in your object store. Note, however, that this only deletes the log content and keeps the label index intact; you will still be able to see related labels but will be unable to retrieve the deleted log content.
For further details on the Table Manager internals, refer to the Table Manager documentation.
Example configuration with GCS with a 30 day retention:
schema_config: configs: - from: 2018-04-15 store: bigtable object_store: gcs schema: v11 index: prefix: loki_index_ period: 168h storage_config: bigtable: instance: BIGTABLE_INSTANCE project: BIGTABLE_PROJECT gcs: bucket_name: GCS_BUCKET_NAME chunk_store_config: max_look_back_period: 720h table_manager: retention_deletes_enabled: true retention_period: 720h