Delete allocation

I’m trying to find solution for deleting old allocations.
I know about gc, but I want to store only last 3 allocations for job for example.
Read documentation, unfortunately couldn’t find api or cli command for removing allocation.
Could you please help with it?

There is no such API. GC removes all dead allocations. If you want to store history of allocations, you have to implement it yourself.

how can you troubleshoot a dead allocation if there is no history stored ? @Kamilcuk

Hi. You can’t.

Do nomad api /v1/event/stream > history.json and you will have all the history of everything that happens for debugging. Consider some preprocessing like jq .Events[] and forward logs to Grafana Loki.

I did actually a python project that parses nomad event stream and maintains an indexed relational database of current and historic allocations, jobs, deployment, nodes in postgres. That project is not great to maintain and use. Maybe i will revisit it.

I think just the event stream with some indexing capabilities of loki is all needed for most people.