Skip to content
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

Enable "rabbitmq_prometheus" in RabbitMQ 3.8 by default #422

Merged
merged 1 commit into from Aug 19, 2020

Conversation

tianon
Copy link
Member

@tianon tianon commented Jun 25, 2020

Closes #419

@tianon
Copy link
Member Author

tianon commented Jun 25, 2020

Arg, we're butting up against:

if [ -z "$shouldWriteConfig" ] && [ ! -f "$oldConfigFile" ] && [ ! -f "$newConfigFile" ]; then
# no config files, we should write one
shouldWriteConfig=1
fi

I really don't like this script... 🤦

@gerhard
Copy link
Contributor

gerhard commented Jun 26, 2020

I really don't like this script... 🤦

I couldn't agree more.

I would definitely advocate for its removal and reduce the sprawl of environment variables by requiring users to configure most aspects of RabbitMQ using the sysctl config format. This has built-in validation and many improvements over env vars or the classic config: https://www.rabbitmq.com/configure.html#config-file

A relevant improvement that shipped in 3.8.4 is improved support for multiple sysctl config files: rabbitmq/rabbitmq-server#2258 & rabbitmq/rabbitmq-server#2277 . This allows users to specify multiple config files in sysctl format and not mutate a single file.

There has never been a better time to put an end to the docker-entrypoint,.sh madness!


As extra context, this is exactly what we are doing in the commercial version of RabbitMQ, which ships as an OCI.

Copy link
Contributor

@gerhard gerhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes look good to me. The docker-entrypoint.sh is even more complex than it was before, and my previous comment stills stands, but I don't think that we should leave that distract from this.

Let me know if you would like me to QA when the checks are green and it's ready to merge.

This is a fantastic change, I am very excited to see it take shape so quickly. It's great to see you move so fast on this @tianon 👍🏻

3.7-rc/alpine/docker-entrypoint.sh Outdated Show resolved Hide resolved
@tianon
Copy link
Member Author

tianon commented Jul 1, 2020

The only reason I'm touching docker-entrypoint.sh here is for:

SSL will need to be configured for rabbitmq-prometheus on top of rabbitmq-management

... and that's also why it only supports the SSL-related flags that are supported for the server and for the management plugin.

If you think we don't need that (and that if users configure the server to use SSL, we can leave it up to them to configure SSL for prometheus), we can drop all but the change to disable_metrics_collector.

@tianon
Copy link
Member Author

tianon commented Jul 1, 2020

We could also skip the docker-entrypoint.sh changes here and add a deprecation warning to docker-entrypoint.sh separately so that users who would be affected by the removal of it know that we intend to remove it / delete most of it at some point.

@tianon
Copy link
Member Author

tianon commented Jul 1, 2020

Also, I guess moving disable_metrics_collector to use a conf.d file instead makes it both easier to add/remove and makes this script unaware of it, so that's probably a better solution to what I pushed in https://github.com/docker-library/rabbitmq/compare/6bda400327dce532bacff769ea8b908125c7515d..e2cf7d1bbc5825230b5bcc79725816fc38bb55cf.

gerhard added a commit to rabbitmq/rabbitmq-prometheus that referenced this pull request Jul 1, 2020
Context: we want to move away from environment variables and use either
config files or env files (such as the rabbitmq-env.conf).

Since .erlang.cookie is neither, the official RabbitMQ Docker image
handles this by writing the value from the RABBITMQ_ERLANG_COOKIE env
var into the file if it does not exist. The problem is that if this file
exists, and the value is different from the RABBITMQ_ERLANG_COOKIE env
var, CLI tools will not be able to communicate with the rabbit node, as
described here: rabbitmq/rabbitmq-cli#443

The only gotcha is that this file must be owned by the user, and
privileges should not be too open (git should have captured this). If
not, RabbitMQ will fail to boot. This is somewhat similar to how OpenSSH
reacts when private key permissions are too open.

re docker-library/rabbitmq#422 (comment)

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
@nesc58
Copy link

nesc58 commented Jul 10, 2020

How can I configure return_per_object_metrics configurable? For me it's a need to configure it.

Thank you for initiating this PR 👍

@tianon
Copy link
Member Author

tianon commented Jul 21, 2020

@nesc58 I honestly find joy in the fact that you're asking, because that very variety of question is why I hesitated even adding the configuration bits I did here 😄 -- the end goal is to not provide any custom configuration behavior anymore, so the direct answer to your question is that it should be put in /etc/rabbitmq/rabbitmq.conf or /etc/rabbitmq/conf.d/foo.conf (as per standard upstream RabbitMQ configuration) 👍

@gerhard
Copy link
Contributor

gerhard commented Jul 24, 2020

@nesc58: How can I configure return_per_object_metrics configurable? For me it's a need to configure it.

For Docker Compose, I would recommend mounting the config file at /etc/rabbitmq/conf.d/prometheus.return_per_object_metrics.conf. The contents of the file would be:

prometheus.return_per_object_metrics = true

For Docker Swarm, I would recommend using a service config to generate that config file.

For K8S, I would recommend a ConfigMap to generate that config file.

@nesc58
Copy link

nesc58 commented Jul 27, 2020

For Docker Compose, I would recommend mounting the config file at /etc/rabbitmq/conf.d/prometheus.return_per_object_metrics.conf. The contents of the file would be:

Thank you. That was what I am looking for :-)

@michaelklishin
Copy link
Contributor

What's blocking this from being merged @tianon @gerhard?

@tianon
Copy link
Member Author

tianon commented Aug 6, 2020

I think just your eyeballs to ensure my final (simplified) version is acceptable as a default. 😅

Copy link
Contributor

@gerhard gerhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, will keep an eye on this PR until it makes it through 👀

update.sh Outdated Show resolved Hide resolved
@gerhard
Copy link
Contributor

gerhard commented Aug 19, 2020

rabbitmq:3.8 & rabbitmq:3.8-management image variants work as expected, OK to merge 👍

@yosifkit yosifkit merged commit 86a695b into docker-library:master Aug 19, 2020
@yosifkit yosifkit deleted the prometheus branch August 19, 2020 23:02
@jwillmer
Copy link

jwillmer commented Jul 1, 2021

@tianon I'm using the script below as entrypoint in my docker-compose file via: entrypoint: ["bash", "/scripts/cluster-entrypoint.sh" ]. How would I need to change it in order to support new versions of rabbitmq?

#!/bin/bash

set -e

# Start RMQ from entry point.
# This will ensure that environment variables passed
# will be honored
/usr/local/bin/docker-entrypoint.sh rabbitmq-server -detached

# Do the cluster dance
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@rabbitmq1

# Stop the entire RMQ server. This is done so that we
# can attach to it again, but without the -detached flag
# making it run in the forground
rabbitmqctl stop

# Wait a while for the app to really stop
sleep 2s

# Start it
rabbitmq-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider providing a Prometheus variant
6 participants