Skip to content

Commit

Permalink
logging: log to console
Browse files Browse the repository at this point in the history
As RabbitMQ is running under Pebble inside of a container, make
sure all log output goes to the console so it can easily be accessed
and collecting into observability solutions.

This requires that we bypass the helper wrapper script which will
always redirect STDOUT and STDERR to a log file.

(cherry picked from commit acf91f9)
  • Loading branch information
javacruft committed Sep 12, 2023
1 parent 20c6da3 commit 93d286c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,18 @@ def _check_rmq_running():

def _rabbitmq_layer(self) -> dict:
"""Pebble layer definition for RabbitMQ."""
# NOTE(jamespage)
# Use the full path to the rabbitmq-server binary
# rather than the helper wrapper script to avoid
# redirection of console output to a log file.
return {
"summary": "RabbitMQ layer",
"description": "pebble config layer for RabbitMQ",
"services": {
RABBITMQ_SERVICE: {
"override": "replace",
"summary": "RabbitMQ Server",
"command": "rabbitmq-server",
"command": "/usr/lib/rabbitmq/bin/rabbitmq-server",
"startup": "enabled",
"user": RABBITMQ_USER,
"group": RABBITMQ_GROUP,
Expand Down Expand Up @@ -588,6 +592,10 @@ def _render_and_push_rabbitmq_conf(self) -> None:
cluster_partition_handling = autoheal
queue_master_locator = min-masters
# Log to console for pod logging
log.console = true
log.file = false
"""
logger.info("Pushing new rabbitmq.conf")
container.push(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_rabbitmq_pebble_ready(self):
"rabbitmq": {
"override": "replace",
"summary": "RabbitMQ Server",
"command": "rabbitmq-server",
"command": "/usr/lib/rabbitmq/bin/rabbitmq-server",
"startup": "enabled",
"user": "rabbitmq",
"group": "rabbitmq",
Expand Down

0 comments on commit 93d286c

Please sign in to comment.