What is the WAL and why does Prometheus restart slowly sometimes?

AdvancedConceptPrometheus Architecture
Answer

The Write-Ahead Log records every incoming sample before it is in the head block, so a crash loses nothing that was acknowledged. On startup Prometheus replays the WAL (plus checkpoints and mmapped chunks) to rebuild the head.

With millions of active series and a large WAL, replay can take many minutes and spike memory, causing OOM loops. Mitigations: lower cardinality, enough memory headroom, and keeping chunks_head (mmapped) so less needs replaying. Log line to watch: Replaying WAL, this may take a while.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus Architecture