Skip to main content
Version: v2.x

Auto cleanup of event trigger logs

Available on: Cloud, Enterprise Edition
Supported from

Auto cleanup for event triggers is available from Hasura version v2.13 and above.

Introduction

Hasura provides a way to automate the cleanup of the event trigger logs based on the following parameters:

Name of the parameterDescriptionDefaultExample
clear_older_thanMinimum age (in hours) of the event logs that need to be cleared from when the cleanup action is invoked.-clear_older_than: 168 means logs older than 168 hours (7 days) will be deleted.
scheduleCron expression at which the cleanup should be invoked.-A 0 0 * * * schedule means that the cleanup will be invoked every day at 00:00 (UTC time).
clean_invocation_logsOption to indicate whether the corresponding invocation logs are also to be cleaned.falseclean_invocation_logs: false means that invocation logs will not be cleaned.
batch_sizeMaximum number of logs to delete in a single statement during the cleanup action. If there are more events to be cleaned than the batch_size then the cleanup action will execute multiple statements sequentially until all old event logs are cleared.10000Suppose there are 10000 events pending deletion and a batch_size of 1000 then the cleanup will be performed in 10 batches sequentially.
timeoutMaximum time (in seconds) that a batch can take during the cleanup process. If a batch times out, the cleanup process is halted.60A timeout of 60 means a batch of cleanup should not take more than 60 seconds. If a batch takes more than the timeout, then all the subsequent batches for the cleanup action will be cancelled.
pausedIndicates if the auto-cleanup process is paused.falsepaused: true means cleanup is paused, hence no logs will be deleted.

Auto cleanup

For automatic cleanup, you can provide a cleanup config while adding the event trigger and Hasura will clean up the logs according to the provided config.

For an existing event trigger, head to the Modify tab of the event trigger and scroll down to the Auto-cleanup Event Logs section.

Auto cleanup
Warning

If you initially choose not to delete invocation_logs, but later they need to be deleted, you will need to delete the retained logs manually.

Manual APIs

For cleaning up the event trigger logs using an API, Hasura provides the cleanup_event_trigger_logs API.

Managing automatic cleaners

For the ease of managing automated cleanups, Hasura provides few metadata APIs such as:

Tip

While applying migrations, you may pause all the installed cleaners for better performance.

API usage examples

  • Activate the cleaners on all the triggers defined on all the event-trigger-supported sources
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
"type" : "resume_event_trigger_cleanups",
"args": {
"event_triggers": {
"sources": "*"
}
}
}
  • Activate the cleaners on all the triggers defined on the sources: source_1, source_2
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
"type" : "resume_event_trigger_cleanups",
"args": {
"event_triggers": {
"sources": ["source_1", "source_2"]
}
}
}
  • Activate the cleaners on triggers: sample_trigger_1, sample_trigger_2 defined on source default
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
"type": "resume_event_trigger_cleanups",
"args": {
"event_triggers": [
{
"source_name": "default",
"event_triggers": ["sample_trigger_1", "sample_trigger_2"]
}
]
}
}
Note

The management APIs will only affect the event trigger log cleaners if the event triggers have cleaners configured.