Distributed Vaults - RabbitMQ Logs are not rotating causing machine freeze
Symptom
Due to a RabbitMQ bug in some distributed vault environments, the RabbitMQ logs do not rotate at 50MB.
This is allowing the log file to increase to a very large size, until it fills the drive and causes a server freeze, or services to be stopped.
The issue is usually discovered when the 'PADR' or 'PA Server' services stop for no reason, or when the VM is paused.
Environment
Privileged Access Manager (PAM, self-hosted) Distributed Vault
Distributed Vaults where Rabbit MQ is installed.
Cause
In the Rabbit MQ configuration file rabbitmq.conf there is a setting to rotate the logs every 50MB, but due to a bug in the RMQ software, this setting is not getting applied, even though other settings from the same file do get applied.
Path to conf file:
"C:\ProgramData\RabbitMQ\rabbitmq.conf"
Path to Log:
"C:\ProgramData\RabbitMQ\log\rabbitmq.log"
Resolution
In order to prevent the issue, we need to make changes to the Rabbit MQ configuration file to achieve the following:
- Replace log rotation from size based to date based, causing the logs to rotate daily at midnight
- Reduce the amount of saved logs from 15 to 3. Meaning three days of logs will be saved.
- Reduce the debug level so that the files are populated with less data and will not grow so much in size
- Increase the disk protection size from 200MB to 5GB. This will ensure the logs are not going to grow if the disk has less than 5GB or more of free space.
First we need to stop the 'RabbitMQ' service and delete (or zip and move to another drive) the existing large log files at:
C:\ProgramData\RabbitMQ\log\rabbitmq.log
*Note there could be more than one log with the files numbered such as rabbitmq.log.0, rabbitmq.log.1 and so on
Then apply the following changes to the RabbitMQ configuration file:
Lines to remove:
## log.file.rotation.size - set to 50MB
log.file.rotation.size=52428800
Lines to change:
log.file.level=warning
log.file.rotation.count=3
disk_free_limit.absolute=5000MB
Lines to add:
## rotate every night at midnight
log.file.rotation.date = $D0
Before:
## log.file.rotation.size - set to 50MB
listeners.tcp.1=127.0.0.1:5672
log.file.level=info
log.file=rabbitmq.log
log.file.rotation.size=52428800
log.file.rotation.count=15
disk_free_limit.absolute=200MB
After:
## rotate every night at midnight
listeners.tcp.1=127.0.0.1:5672
log.file.rotation.date = $D0
log.file.level=warning
log.file=rabbitmq.log
log.file.rotation.count=3
disk_free_limit.absolute=5000MB
Once the file is saved, start the 'RabbitMQ' service again and monitor the logs folder to ensure no mire than 3 logs files are generated after three days.