0
0
RabbitmqHow-ToBeginner ยท 4 min read

How to Configure Alarms in RabbitMQ for Resource Monitoring

In RabbitMQ, you configure alarms using the rabbitmqctl set_vm_memory_high_watermark and rabbitmqctl set_disk_free_limit commands to set memory and disk space thresholds. These alarms automatically block producers or stop the broker when limits are exceeded to protect stability.
๐Ÿ“

Syntax

RabbitMQ alarms are configured mainly via command-line tools or configuration files. The key commands are:

  • rabbitmqctl set_vm_memory_high_watermark <value>: Sets the memory usage threshold as a fraction (e.g., 0.4 for 40%) or absolute value.
  • rabbitmqctl set_disk_free_limit <value>: Sets the minimum free disk space before alarm triggers. Value can be bytes or human-readable (e.g., 1GB).

These alarms help RabbitMQ block producers or stop accepting messages to avoid crashes.

bash
rabbitmqctl set_vm_memory_high_watermark 0.4
rabbitmqctl set_disk_free_limit 1GB
๐Ÿ’ป

Example

This example sets a memory alarm at 50% usage and a disk free space alarm at 500MB. It shows how to apply these settings using rabbitmqctl.

bash
rabbitmqctl set_vm_memory_high_watermark 0.5
rabbitmqctl set_disk_free_limit 500MB
rabbitmqctl status
Output
Status of node rabbit@hostname ... [{pid,12345}, {running_applications,[{rabbit,"RabbitMQ","3.11.14"}, ...]}, {alarms,[{memory,mem_alarm},{disk_free,disk_free_alarm}]}, ...]
โš ๏ธ

Common Pitfalls

Common mistakes when configuring RabbitMQ alarms include:

  • Setting memory watermark too high, causing late alarms and broker instability.
  • Using disk free limits too low, which can cause unexpected broker shutdowns.
  • Not restarting RabbitMQ after changing config files, so alarms don't apply.
  • Confusing absolute values and fractions for memory watermark.

Always verify alarms with rabbitmqctl status after configuration.

bash
## Wrong: setting memory watermark as 50 (interpreted as 50 bytes, not 50%)
rabbitmqctl set_vm_memory_high_watermark 50

## Right: set as fraction 0.5 for 50%
rabbitmqctl set_vm_memory_high_watermark 0.5
๐Ÿ“Š

Quick Reference

CommandPurposeValue Format
rabbitmqctl set_vm_memory_high_watermark Set memory usage alarm thresholdFraction (e.g., 0.4) or absolute bytes
rabbitmqctl set_disk_free_limit Set minimum free disk space alarmBytes or human-readable (e.g., 1GB)
rabbitmqctl statusCheck current alarms and broker statusNo value
rabbitmqctl clear_vm_memory_high_watermarkClear memory alarm settingNo value
rabbitmqctl clear_disk_free_limitClear disk free alarm settingNo value
โœ…

Key Takeaways

Use rabbitmqctl commands to set memory and disk alarms to protect broker stability.
Memory watermark can be a fraction (like 0.4) or absolute bytes; avoid confusion.
Disk free limit accepts human-readable sizes like 1GB or bytes.
Always verify alarm status with rabbitmqctl status after configuration.
Restart RabbitMQ if you change alarms via config files to apply settings.