New to Kestra?
Use blueprints to kickstart your first workflows.
Schedule a Kestra flow to purge executions, logs, metrics and outputs older than one month, reclaim storage, and keep your instance clean and fast.
id: purge
namespace: system
tasks:
- id: purge_executions
type: io.kestra.plugin.core.execution.PurgeExecutions
endDate: "{{ now() | dateAdd(-1, 'MONTHS') }}"
purgeLog: false
states:
- SUCCESS
- id: purge_logs
type: io.kestra.plugin.core.log.PurgeLogs
endDate: "{{ now() | dateAdd(-1, 'MONTHS') }}"
triggers:
- id: daily
type: io.kestra.plugin.core.trigger.Schedule
disabled: true
cron: 0 9 * * *
Kestra instances accumulate execution data over time: execution records, logs, metrics, and task outputs that pile up in storage and the backend database. Left unchecked, this growth slows down the UI, inflates storage costs, and clutters your execution history. This flow is a scheduled housekeeping routine that automatically purges execution data older than one month, reclaiming space and keeping your instance responsive without any manual cleanup.
The flow runs two dedicated maintenance tasks in sequence:
purge_executions (io.kestra.plugin.core.execution.PurgeExecutions) deletes execution data whose endDate is older than one month, computed dynamically with {{ now() | dateAdd(-1, 'MONTHS') }}. The states property is set to SUCCESS, so only successful executions are purged and the audit trail of failed runs is preserved. purgeLog is set to false so that log deletion is handled separately.purge_logs (io.kestra.plugin.core.log.PurgeLogs) deletes logs older than the same one-month cutoff. Logs are usually the largest chunk of data, so isolating them in their own task lets you run or rerun this step independently.A Schedule trigger (io.kestra.plugin.core.trigger.Schedule) is configured to fire daily at 0 9 * * *. It ships disabled: true so the flow does not run before you have reviewed it.
Storage hygiene is itself a workflow, and Kestra treats it as one. The declarative YAML makes retention policy explicit and version controlled. The Schedule trigger runs cleanup unattended on a cron cadence, while built-in retries and execution history give you observability and lineage over the maintenance job itself, something a manual database DELETE or an external cron script cannot offer. Splitting executions and logs into separate tasks means a failure in one step does not block the other, and you can rerun a single task from the UI.
This flow uses core maintenance tasks only and references no secrets.
endDate cutoff and the states filter, then adjust to your retention policy.disabled property to false (or remove that line) to activate the daily schedule.states field empty to purge executions regardless of status.dateAdd window (for example -7, 'DAYS' or -3, 'MONTHS') to match your retention requirements.Note: this flow will not purge flow definitions or namespace files. Only execution-related data is removed, so your code stays safe.