Guide
Configuring Persistent Queues in Logstash for Durable Event Processing
Enable Logstash persistent queues to protect in‑flight events across restarts, with step‑by‑step configuration, verification, and rollback guidance.
Published by Tasadduq Burney
24 Aug 2025, 17:15 UTC
3 min134.9K views0

Desired outcome
Enable Logstash persistent queues so that in‑flight events are saved to disk and can be recovered after an unexpected shutdown or restart, without data loss.
Necessary prerequisites
- Logstash version 7.0 or later (persistent queues were introduced in 6.0 and stabilized in 7.x).
- Administrative access to the host where Logstash runs (to edit
logstash.ymland restart the service). - Sufficient free disk space on the volume that will hold the queue; a rule of thumb is at least twice the expected peak in‑flight event size.
- Backup of the current
logstash.ymlin case you need to revert.
Focused procedure
- Identify the queue directory.
Edit
logstash.yml(usually located at/etc/logstash/logstash.yml) and set or verifypath.queue. Example:
Ensure the directory exists and is owned by the Logstash user (# path.queue: /var/lib/logstash/queue path.queue: /mnt/logstash_queuechown -R logstash:logstash /mnt/logstash_queue). - Enable the persisted queue type.
Add or modify the following line in the same file:
Optionally tune the queue characteristics (see table below).queue.type: persisted - Apply the change.
Save the file and restart Logstash. On a systemd host:
If you run Logstash from the command line, stop the current process (sudo systemctl restart logstashCtrl+Corkill) and start it again with the same flags. - Verify that the persistent queue is active.
Check the startup log for the line:
Then list the queue directory:[INFO ] logstash.agent - Persistent queue is enabled
The presence ofls -la $path.queue # Expected output includes: # queue.log (the active page file) # checkpoint (contains the last processed batch)queue.logand acheckpointfile indicates that events are being written to disk. - Test durability.
1. Send a few test events to a pipeline (e.g., via
curl -XPOST 'http://localhost:5044' -d '{"msg":"test"}'if using Beats input). 2. While Logstash is still running, kill it abruptly to simulate a crash:
3. Restart Logstash as in step 3. 4. Observe the output (e.g., Elasticsearch, stdout, or a file). The previously sent test events should appear after restart, confirming recovery from the persistent queue.sudo kill -9 $(pgrep -f logstash)
Expected checks
- Startup log contains
Persistent queue is enabled. - The
path.queuedirectory shows a growingqueue.logfile and acheckpointfile that updates after each batch. - After an abrupt stop and restart, events that were in flight before the stop appear in the downstream output.
Relevant recovery options (rollback)
Changing queue.type requires a full restart; there is no in‑place migration. To revert to the default in‑memory queue:
- Restore the original
logstash.yml(or comment out thequeue.typeline). - Stop Logstash.
- Optionally, clear the queue directory to avoid stale checkpoint files interfering with the in‑memory queue (
rm -rf $path.queue/*). - Start Logstash again.
Note: Removing the queue directory while Logstash is running will cause the pipeline to stall; perform the cleanup only when the service is stopped.
Limitations and practical verification
- Persistent queues increase I/O latency; monitor disk latency (
iostat -x 1) and ensure the underlying storage can sustain the expected write rate. - The default
page_capacity(64 MB) andmax_bytes(1 GB) are suitable for most workloads; adjust only after observing queue growth patterns. - If the queue directory runs out of space, Logstash will block the pipeline and log warnings like
Persistent queue is full. Prevent this by setting up disk‑usage alerts on the volume hostingpath.queue.
Configuration reference table
| Setting | Description | Typical value |
|---|---|---|
queue.type |
Queue implementation; persisted enables disk‑backed queue. |
persisted |
page_capacity |
Maximum size of each page file before a new page is created. | 64mb |
max_bytes |
Upper bound for total queue size on disk; older pages are dropped when exceeded. | 1gb |
checkpoint.writes |
Number of batch checkpoints to keep; higher values increase durability but use more disk. | 1024 |
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.