Skip to main content
Version: Next

Lifecycle Policies

Lifecycle policies are background tasks that automatically clean up old records from your buckets. They help you manage storage efficiently by removing outdated data based on rules you define.

How It Works​

A lifecycle policy runs at a configurable interval and scans the target bucket for records older than max_age. It removes these records and logs the operation in the $audit system bucket. You can optionally scope policies to specific entries or filter records using conditions.

Policies are stored on disk and remain active after restarts. However, read-only (replica) instances cannot execute lifecycle policies. Every policy run is recorded as a lifecycle_run event in the $audit bucket for transparency and debugging.

Supported Actions​

Currently, ReductStore supports one action type for lifecycle policies:

TypeDescription
deleteRemoves records older than max_age from the bucket

More action types may be added in future releases.

Policy Settings​

You can configure lifecycle policies using the following settings:

SettingDescriptionRequiredDefault
typeAction type (e.g., delete)Nodelete
bucketTarget bucket nameYes-
entriesList of entries to scope the policy (wildcard * supported)No-
max_ageMaximum age of records before action is applied (e.g., 30d, 1h, 5m)Yes-
intervalPolicy execution interval (e.g., 3600s, 10m)No3600s
whenJSON condition to filter records (see Conditional Query Reference)No-
modePolicy mode: enabled (default) or disabledNoenabled

Conditional Policies​

You can refine lifecycle policies using the entries and when parameters:

  • entries: Limit the policy to specific entries (e.g., sensor-1,sensor-2 or sensor-*)
  • when: Apply the policy only to records matching a condition (e.g., {"&sensor_type": {"$eq": "temperature"}})

For more details, see the Conditional Query Reference.

Example​

Imagine you store telemetry data from temperature sensors in a bucket called telemetry. You want to automatically delete records older than 30 days, but only for specific sensors (sensor-1 and sensor-2) and only if the sensor_type label equals temperature. Here’s how you’d configure the policy:

version: "3"
services:
reductstore:
image: reduct/store:latest
ports:
- "8383:8383"
volumes:
- ./data:/data
environment:
RS_API_TOKEN: my-api-token
RS_BUCKET_1_NAME: telemetry
RS_LIFECYCLE_1_NAME: purge-sensors-30d
RS_LIFECYCLE_1_BUCKET: telemetry
RS_LIFECYCLE_1_TYPE: delete
RS_LIFECYCLE_1_MAX_AGE: 30d
RS_LIFECYCLE_1_INTERVAL: 10m
RS_LIFECYCLE_1_ENTRIES: "sensor-1,sensor-2"

RS_LIFECYCLE_1_WHEN: |
{
"&sensor_type": { "$eq": "temperature" }
}

Managing Policies​

Currently, lifecycle policies can only be provisioned using environment variables. They cannot be updated or removed via the API.

info

Provisioned policies cannot be modified or deleted through the API. To make changes, update the environment variables and restart the ReductStore instance.

Audit Logs​

Every lifecycle run generates a lifecycle_run event in the $audit bucket. The event includes:

  • Policy name and action type
  • Target bucket and duration of the run
  • Number of records processed
  • Error details (if any)