-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Logging: Add journald support #2940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note that erlang-systemd is only used for its journald support in this pull request. I plan to change how we tell systemd RabbitMQ is ready to use this new dependency as well. This will allow us to get rid of the previous methods ( |
0a4dee3
to
c4f3693
Compare
The implementation depends on erlang-systemd [1] which uses Unix socket support introduced in Erlang 19. Therefore it doesn't rely on a native library. We also don't need special handling if the host doesn't use journald. To enable the journald handler, add the following configuration variable: log.journald = true The log level can also be set the same way it is with other handlers: log.journald.level = debug The log messages are communicated to journald using structured data. It is possible to configure which fields are transmitted and how they are named: log.journald.fields = SYSLOG_IDENTIFIER="rabbitmq-server" syslog_timestamp syslog_pid priority ERL_PID=pid In this example: * the `SYSLOG_IDENTIFIER` is set to a string literal * `syslog_timestamp and `syslog_pid` are aliases for SYSLOG_TIMESTAMP=time and SYSLOG_PID=os_pid * `priority` is a special field computed from the log level * `ERL_PID=pid` indicates `pid` should be sent as the `ERL_PID` field. The message itself is implicit and always sent. Otherwise, the list of fields must be exhaustive: fields which are unset in a particular log event meta are sent as an empty string and non-mentionned fields are not sent. The order is not important. Here are some messages printed by `journalctl -f` during RabbitMQ startup: Mar 26 11:58:31 ip-172-31-43-179 rabbitmq-server[19286]: Ready to start client connection listeners Mar 26 11:58:31 ip-172-31-43-179 rabbitmq-server[19286]: started TCP listener on [::]:5672 Mar 26 11:58:31 ip-172-31-43-179 rabbitmq-server[19286]: Server startup complete; 0 plugins started. [1] https://github.com/rabbitmq/erlang-systemd
c4f3693
to
91583a0
Compare
Here is how I tested the patch:
|
Until now, we were using socat(1). It was added as a dependency to our Debian and RPM packages. Unfortunately, the availability of this package has not always been good. We also supported erlang-sd_notify which relied on a UDP socket. None of them had journald support. Now, thanks to erlang-systemd, we can use the Unix socket and provide more fine-grained status updates if we want. Journald support is also provided by erlang-systemd. It was added to RabbitMQ in commit 91583a0 (#2940).
Until now, we were using socat(1). It was added as a dependency to our Debian and RPM packages. Unfortunately, the availability of this package has not always been good. We also supported erlang-sd_notify which relied on a UDP socket. None of them had journald support. Now, thanks to erlang-systemd, we can use the Unix socket and provide more fine-grained status updates if we want. Journald support is also provided by erlang-systemd. It was added to RabbitMQ in commit 91583a0 (#2940).
Since RabbitMQ 3.9 [1] journald logging support has been implemented As we use journald logging for most of the services and aim to make it a standard, switching rabbitmq to journald follows this goal and deployment unification [1] rabbitmq/rabbitmq-server#2940 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-rabbitmq_server/+/826446/ Change-Id: I86462f8279ebb5dc28e92fc8440cc0ab26f0759d
* Update openstack-ansible-rabbitmq_server from branch 'master' to 9790981aa60fbdc0aba6fc41c71feb65d57aa063 - Merge "Use journald logging for RabbitMQ" - Use journald logging for RabbitMQ Since RabbitMQ 3.9 [1] journald logging support has been implemented As we use journald logging for most of the services and aim to make it a standard, switching rabbitmq to journald follows this goal and deployment unification [1] rabbitmq/rabbitmq-server#2940 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-rabbitmq_server/+/826446/ Change-Id: I86462f8279ebb5dc28e92fc8440cc0ab26f0759d
The implementation depends on erlang-systemd which uses Unix socket support introduced in Erlang 19. Therefore it doesn't rely on a native library. We also don't need special handling if the host doesn't use journald.
To enable the journald handler, add the following configuration variable:
The log level can also be set the same way it is with other handlers:
The log messages are communicated to journald using structured data. It is possible to configure which fields are transmitted and how they are named:
In this example:
SYSLOG_IDENTIFIER
is set to a string literalsyslog_timestamp and
syslog_pid` are aliases for SYSLOG_TIMESTAMP=time and SYSLOG_PID=os_pidpriority
is a special field computed from the log levelERL_PID=pid
indicatespid
should be sent as theERL_PID
field.The message itself is implicit and always sent. Otherwise, the list of fields must be exhaustive: fields which are unset in a particular log event meta are sent as an empty string and non-mentionned fields are not sent. The order is not important.
Here are some messages printed by
journalctl -f
during RabbitMQ startup: