Blueprints

Purge execution data including logs, metrics and outputs on a schedule

About this blueprint

System Trigger

This flow will purge all execution data older than 1 month, including logs, metrics and outputs. In this specific flow, we chose to purge only the successful executions in order to keep the audit trail of failed executions. However, you can leave the states field empty to purge all execution data, regardless of the execution status, or adjust it to your needs.

Given that logs often consistute the largest chunk of data that needs to be purged, we use a dedicated task to purge logs (so that you can run it independently or rerun only this step in case something fails). Keep in mind though that, by default, the PurgeExecutions task would also automatically purge the logs.

It is recommended to run this flow daily to keep your Kestra instance clean and save storage space.

Before using this flow, make sure to set the disabled property to false (or remove that line entirely).

Note that this flow will not purge the flow definitions or the namespace files β€” your code will be safe. Only the execution-related data will be purged.

yaml
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 * * *"

Purge Executions

Purge Logs

Schedule

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra