To clean up closed workflow history before retention period

Is there any existing api to clean up the closed workflow history before retention period?

There is no direct api that I am aware of. You could change namespace retention period but that would affect executions that complete after this update, not before.

What’s specific need for this? What persistence store do you use?

One thing you maybe be able to use is tctl admin commands, for example:

tctl adm wf delete -h

I’ve the following case: we are replacing RabbitMQ with Temporal, one of use-case is to sent telemetry/metrics data every second per monitoring entity, the data is some amount of numbers let it be 1K, monitoring entities are about 10K. We don’t need to store the data after processing it may just disappeared because it will be outdated on the next second. So it’s about 10Mb per sec of useless data.

Maybe it’s a misuse of Temporal, but we’ve only one use-case with such conditions and we don’t want to keep RabbitMQ only for this single use-case.

It is indeed a misuse of Temporal. I wouldn’t use it for this.

Maxim, thank you for quick response. Is there a feature request we can upvote to implement autodeletion of specific completed workflows (maybe via workflow options?) or setting retention period to 1 minute or a second?

You can hack it by the last activity in the workflow, calling delete.

1 Like

How can I do this in typescript. Is there an example for this?

The example of calling an activity at the end of the workflow?

No, deleting the workflow from an activity. I am not able to find documentation/example for it.

You call deleteWorkflowExecution using WorkflowService.