Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bea0f31

Browse files
gerharddeadtrickster
authored andcommitted
Fix ETS mappings rabbitmq core collector (#80)
* Remove redundant Dockerfile ARG * Allow overriding DOCKER_BASE_IMAGE when building Docker image * Add make target that allows building ezs in a specific OTP context This was necessary to test that the fixes for #75 work in RabbitMQ v3.7.9 & OTP v21.2.5, the combo that ships in Docker image rabbitmq:3.7.9. This is the first RabbitMQ Docker image that supports prometheus_rabbitmq_exporter (compiled with OTP v21.0.2). Docker image rabbitmq:3.7.8 ships with OTP v20.3.8.5 Notice that I disable prometheus_process_collector in the Docker build context. This fails to build due to Docker image erlang:21.2.5 missing native libs. Didn't want to shave this yak as well. * Fix metric mappings to ETS tables In RabbitMQ v3.7.x, the following mappings were not valid and would result in crashes when a produce/consumer would connect to RabbitMQ: * connection_metrics * connection_recv_count, recv_count * connection_send_count, send_count * channel_queue_metrics * channel_queue_get, get * channel_queue_get_no_ack, get_no_ack * channel_queue_deliver, deliver * channel_queue_deliver_no_ack, deliver_no_ack * channel_queue_redeliver, redeliver * channel_queue_ack, ack * channel_queue_get_empty, get_empty The following metric was mapped incorrectly: * connection_churn_metrics * 7, queue_deleted There is more line churn in this commit than necessary. I was re-formatting all metrics as I was going over all mappings. This confirms that I've checked that all mappings are accurate. I've tested manually against current v3.7.x branch via `make run-broker` as well as rabbitmq:3.7.9 Docker image: make distclean make otp-21.2.5-build-context make /usr/local/bin/elixir apt update && apt install zip make ezs ^D make docker_build DOCKER_BASE_IMAGE=rabbitmq:3.7.9-management docker run -it -p 5672:5672 -p 15672:15672 deadtrickster/rabbitmq_prometheus:3.7 cd ~/github.com/rabbitmq/rabbitmq-perf-test make run ARGS="-x 1 -y 1 -r 1" curl localhost:15672/api/metrics # NO CRASHES! Fixes #75 cc @dcorbacho
1 parent e3b2283 commit bea0f31

File tree

3 files changed

+172
-113
lines changed

3 files changed

+172
-113
lines changed

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ARG RABBITMQ_MINOR_VERSION
21
ARG FROM_IMAGE
32
ARG PROMETHEUS_RABBITMQ_EXPORTER_VERSION
43
FROM ${FROM_IMAGE}

Makefile

+48-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@ dep_prometheus_cowboy = hex $(PROMETHEUS_COWBOY_VERSION)
2020
PROMETHEUS_HTTPD_VERSION = 2.1.10
2121
dep_prometheus_httpd = hex $(PROMETHEUS_HTTPD_VERSION)
2222

23+
# prometheus_process_collector will fail to build in otp-*-build-context, skipping
24+
ifneq ($(DOCKER_BUILD_CONTEXT),1)
2325
PROMETHEUS_PROCESS_COLLECTOR_VERSION = 1.4.3
2426
dep_prometheus_process_collector = hex $(PROMETHEUS_PROCESS_COLLECTOR_VERSION)
27+
endif
2528

2629
DEPS = rabbit rabbitmq_management \
2730
prometheus prometheus_cowboy prometheus_httpd
2831

2932
# We do not want these deps defined as applications in app
33+
# prometheus_process_collector will fail to build in otp-*-build-context, skipping
34+
ifneq ($(DOCKER_BUILD_CONTEXT),1)
3035
BUILD_DEPS = rabbit_common rabbitmq_management_agent accept prometheus_process_collector
36+
else
37+
BUILD_DEPS = rabbit_common rabbitmq_management_agent accept
38+
endif
3139

3240
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
3341
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
@@ -56,7 +64,7 @@ distclean::
5664
@rm -fr tmp
5765

5866
DOCKER_IMAGE_VERSION = $(RABBITMQ_MINOR_VERSION)
59-
DOCKER_BASE_IMAGE = rabbitmq:$(DOCKER_IMAGE_VERSION)-management
67+
DOCKER_BASE_IMAGE ?= rabbitmq:$(DOCKER_IMAGE_VERSION)-management
6068

6169
define BUILD_DOCKER_IMAGE
6270
docker build \
@@ -145,10 +153,13 @@ tmp/prometheus_httpd-$(PROMETHEUS_HTTPD_VERSION).ez: $(REBAR) $(REBAR_DEPS_DIR)
145153
$(REBAR) archive && \
146154
mv prometheus_httpd-$(PROMETHEUS_HTTPD_VERSION).ez $(CURDIR)/tmp/
147155

156+
# prometheus_process_collector will fail to build in otp-*-build-context, skipping
157+
ifneq ($(DOCKER_BUILD_CONTEXT),1)
148158
tmp/prometheus_process_collector-$(PROMETHEUS_PROCESS_COLLECTOR_VERSION).ez: $(REBAR) $(REBAR_DEPS_DIR) tmp
149159
@cd $(REBAR_DEPS_DIR)/prometheus_process_collector && \
150160
$(REBAR) archive && \
151161
mv prometheus_process_collector-$(PROMETHEUS_PROCESS_COLLECTOR_VERSION).ez $(CURDIR)/tmp
162+
endif
152163

153164
tmp/$(EZ).ez: up app tmp
154165
@rm -fr $(EZ) && mkdir $(EZ) && \
@@ -162,7 +173,10 @@ ezs:: tmp/accept-$(ACCEPT_VERSION).ez
162173
ezs:: tmp/prometheus-$(PROMETHEUS_VERSION).ez
163174
ezs:: tmp/prometheus_cowboy-$(PROMETHEUS_COWBOY_VERSION).ez
164175
ezs:: tmp/prometheus_httpd-$(PROMETHEUS_HTTPD_VERSION).ez
176+
# prometheus_process_collector will fail to build in otp-*-build-context, skipping
177+
ifneq ($(DOCKER_BUILD_CONTEXT),1)
165178
ezs:: tmp/prometheus_process_collector-$(PROMETHEUS_PROCESS_COLLECTOR_VERSION).ez
179+
endif
166180
ezs:: tmp/$(EZ).ez
167181

168182
define RUN_DOCKER_TEST_IMAGE
@@ -194,3 +208,36 @@ test: ezs docker_build
194208
$(ENSURE_RABBIT_IN_DOCKER_IS_RUNNING) && \
195209
$(VERIFY_METRICS_API) && \
196210
$(CLEAN_DOCKER_TEST_IMAGE)
211+
212+
# This plugin is currently expected to work with RabbitMQ v3.7.9 and above:
213+
# https://github.com/deadtrickster/prometheus_rabbitmq_exporter#versioning
214+
#
215+
# The OTP version that ships in rabbitmq:3.7.9 Docker image is v21.2.5:
216+
# docker run -it --rm rabbitmq:3.7.9 -- cat /usr/local/lib/erlang/releases/21/OTP_VERSION
217+
# 21.2.5
218+
#
219+
# We are creating an Erlang/OTP build context which has the same version as RabbitMQ v3.7.9 Docker image
220+
# The goal is to produce ezs that are compatible with RabbitMQ v3.7.9 Docker image
221+
MIN_SUPPORTED_OTP_VERSION := 21.2.5
222+
.PHONY: otp-$(MIN_SUPPORTED_OTP_VERSION)-build-context
223+
otp-$(MIN_SUPPORTED_OTP_VERSION)-build-context:
224+
@docker run --tty --interactive --rm --name build_prometheus_rabbitmq_export \
225+
--env LANG=C.UTF-8 \
226+
--env LANGUAGE=C.UTF-8 \
227+
--env LC_ALL=C.UTF-8 \
228+
--env DOCKER_BUILD_CONTEXT=1 \
229+
--volume $(CURDIR):/prometheus_rabbitmq_exporter \
230+
--workdir /prometheus_rabbitmq_exporter \
231+
erlang:$(MIN_SUPPORTED_OTP_VERSION) bash
232+
# make /usr/local/bin/elixir
233+
# apt update && apt install zip
234+
# make ezs
235+
236+
tmp/elixir: tmp
237+
@cd tmp && \
238+
cd elixir || git clone https://github.com/elixir-lang/elixir.git; \
239+
git checkout v1.8
240+
241+
/usr/local/bin/elixir: tmp/elixir
242+
@cd tmp/elixir && \
243+
make clean install

0 commit comments

Comments
 (0)