Purge Old Data in Kestra – Executions, Logs, KV
Use purge tasks to remove old executions, logs, and Key-value pairs, helping reduce storage usage.
Purge old execution data safely
The recommended to keep optimized storage is to use io.kestra.plugin.core.execution.PurgeExecutions, io.kestra.plugin.core.log.PurgeLogs, and io.kestra.plugin.core.kv.PurgeKV.
PurgeExecutions: deletes execution recordsPurgeLogs: removes bothExecutionandTriggerlogs in bulkPurgeKV: deletes expired keys globally for a specific namespace.
Together, these replace the legacy io.kestra.plugin.core.storage.Purge task with a faster and more reliable process (~10x faster).
The Enterprise Edition also includes PurgeAuditLogs.
The flow below purges executions and logs:
id: purgenamespace: company.myteamdescription: | This flow will remove all executions and logs older than 1 month. We recommend running it daily to prevent storage issues.
tasks: - id: purge_executions type: io.kestra.plugin.core.execution.PurgeExecutions endDate: "{{ now() | dateAdd(-1, 'MONTHS') }}" purgeLog: false
- 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 cron: "@daily"The example below purges expired Key-value pairs from the company Namespace. It’s set up as a flow in the system namespace.
id: purge_kv_storenamespace: system
tasks: - id: purge_kv type: io.kestra.plugin.core.kv.PurgeKV expiredOnly: true namespaces: - company includeChildNamespaces: truePurge tasks permanently delete data. Always test in non-production environments first.
Purge tasks vs. UI deletion
Purge tasks perform hard deletion, permanently removing records and reclaiming storage. In contrast, deleting items in the UI is a soft deletion—the data is hidden but retained (e.g., revision history and past executions can reappear if a flow with the same ID is recreated).
This distinction matters for compliance and troubleshooting: purge flows are best for cleaning up space, while UI deletions preserve history for auditability.
Purge tasks do not affect Kestra’s internal queues. Queue retention is managed separately via JDBC Cleaner (for database) or topic retention (for Kafka).
Renamed Purge Tasks in 0.18.0
We’ve improved the mechanism of the Purge tasks to make them more performant and reliable — some tasks have been renamed to reflect their enhanced functionality.
Here are the main Purge plugin changes in Kestra 0.18.0:
io.kestra.plugin.core.storage.Purgehas been renamed toio.kestra.plugin.core.execution.PurgeExecutionsto reflect that it only purges data related to executions (e.g. not including trigger logs — to purge those you should use thePurgeLogstask) — we’ve added an alias so that using the old task type will still work but it will emit a warning. We recommend using the new task type.io.kestra.plugin.core.storage.PurgeExecutionhas been renamed toio.kestra.plugin.core.storage.PurgeCurrentExecutionFilesto reflect that it purges all data from the current execution, including inputs and outputs. We’ve also added an alias for backward compatibility, but we recommend updating your flows to use the new task type.
Was this page helpful?