noxdafox / rabbitmq-cloudwatch-exporter

RabbitMQ Plugin for publishing cluster metrics to AWS CloudWatch
Mozilla Public License 2.0
41 stars 9 forks source link

Error during export #10

Closed dimmy-timmy closed 4 years ago

dimmy-timmy commented 4 years ago

Rabbitmq 3.8.0-rc.1 Erlang 22.0.7

Configuration in rabbitmq.conf :

cloudwatch_exporter.metrics.1 = overview
cloudwatch_exporter.metrics.2 = queue
cloudwatch_exporter.metrics.3 = node

ECS Task IAM used for credentials AWS_DEFAULT_REGION and AWS_REGION environment variables defined

Stacktrace ** {{badfun,nil},[{'Elixir.RabbitMQCloudWatchExporter.Exporter','-handle_info/2-fun-3-',1,[{file,"lib/rabbitmq_cloudwatch_exporter/exporter.ex"},{line,55}]},{'Elixir.Enum',flat_map_list,2,[{file,"lib/enum.ex"},{line,2986}]},{'Elixir.Enum',flat_map_list,2,[{file,"lib/enum.ex"},{line,2987}]},{'Elixir.RabbitMQCloudWatchExporter.Exporter',handle_info,2,[{file,"lib/rabbitmq_cloudwatch_exporter/exporter.ex"},{line,55}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,637}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,711}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}

noxdafox commented 4 years ago

Hello,

The plugin was built against RMQ v3.7.x and it's bytecode is most-likely not compatible with RMQ v3.8.x.

I am not planning to provide builds for RMQ v3.8.x until it's not declared stable.

Nevertheless, the plugin builds and operates correctly against RMQ master branch so I'd suggest to compile your own version and try to ship it. The documentation provides build instructions. Just use Elixir <= 1.8.x as per issue #9 there seems to be problem with the latest version.

dimmy-timmy commented 4 years ago

Thank you for quick response. I`ll try and let you know

dimmy-timmy commented 4 years ago

Following combination works perfectly: Makefile

PROJECT = rabbitmq_cloudwatch_exporter

DEPS = rabbit_common rabbit rabbitmq_management rabbitmq_management_agent
override dep_rabbit = git https://github.com/rabbitmq/rabbitmq-server 'v3.8.0-rc.1'
override dep_rabbit_common = git https://github.com/rabbitmq/rabbitmq-common 'v3.8.0-rc.1'
override dep_rabbitmq_management = git https://github.com/rabbitmq/rabbitmq-management 'v3.8.0-rc.1'
override dep_rabbitmq_management_agent = git https://github.com/rabbitmq/rabbitmq-management-agent 'v3.8.0-rc.1'
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk

elixir_srcs := mix.exs

app:: $(elixir_srcs) deps
    $(MIX) make_all

# FIXME: Use erlang.mk patched for RabbitMQ, while waiting for PRs to be
# reviewed and merged.

ERLANG_MK_REPO = https://github.com/rabbitmq/erlang.mk.git
ERLANG_MK_COMMIT = rabbitmq-tmp

include rabbitmq-components.mk
include erlang.mk

Dockerfile:

FROM elixir:1.8-otp-22 as build
ENV MIX_ENV=prod
RUN apt-get update && apt-get install -y rsync zip
RUN git clone https://github.com/noxdafox/rabbitmq-cloudwatch-exporter.git
ADD Makefile rabbitmq-cloudwatch-exporter
WORKDIR rabbitmq-cloudwatch-exporter
RUN curl --silent -L http://github.com/rabbitmq/mix_task_archive_deps/releases/download/0.4.0/mix_task_archive_deps-0.4.0.ez -o mix_task_archive_deps-0.4.0.ez
RUN mix archive.install --force ./mix_task_archive_deps-0.4.0.ez
RUN make dist

FROM rabbitmq:3.8-rc-management-alpine

COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/certifi-2.5.1.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/elixir-1.8.2.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/ex_aws_cloudwatch-2.0.4.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/ex_aws-2.1.1.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/hackney-1.15.1.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/idna-6.0.0.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/logger-1.8.2.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/metrics-1.0.1.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/mimerl-1.2.0.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/poison-3.1.0.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/rabbitmq_cloudwatch_exporter-0.2.1.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/singleton-1.2.0.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/ssl_verify_fun-1.1.4.ez ./plugins
COPY --from=build /rabbitmq-cloudwatch-exporter/plugins/unicode_util_compat-0.4.1.ez ./plugins

RUN rabbitmq-plugins enable --offline  rabbitmq_cloudwatch_exporter
noxdafox commented 4 years ago

Glad it worked!

Technically you don't need to modify the Makefile. RMQ Makefile detects from which branch to pull based on the branch name of the repository. Therefore, the master branch will pull the latest code. The v3.8.x branch should pull the 3.8 dependency versions whereas v3.7.x will do it for 3.7.

pmalon commented 4 years ago

@noxdafox I think that I am getting the same error: 02 Jan 2020 17:31:03.112rabbit-broker rabbit[3045]: ** {{badfun,nil},[{'Elixir.RabbitMQCloudWatchExporter.Exporter','-handle_info/2-fun-3-',2,[{file,"lib/rabbitmq_cloudwatch_exporter/exporter.ex"},{line,56}]},{'Elixir.Enum',flat_map_list,2,[{file,"lib/enum.ex"},{line,2986}]},{'Elixir.Enum',flat_map_list,2,[{file,"lib/enum.ex"},{line,2987}]},{'Elixir.RabbitMQCloudWatchExporter.Exporter',handle_info,2,[{file,"lib/rabbitmq_cloudwatch_exporter/exporter.ex"},{line,56}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,637}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,711}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]} 02 Jan 2020 17:31:03.113rabbit-broker rabbit[3045]: 2020-01-02 17:31:03.115 [error] <0.987.0> CRASH REPORT Process <0.987.0> with 1 neighbours crashed with reason: bad function nil in 'Elixir.RabbitMQCloudWatchExporter.Exporter':'-handle_info/2-fun-3-'/2 line 56 02 Jan 2020 17:31:03.113rabbit-broker rabbit[3045]: 2020-01-02 17:31:03.116 [error] <0.777.0> Supervisor 'Elixir.Singleton.Supervisor' had child 'Elixir.Singleton.Manager' started with 'Elixir.Singleton.Manager':start_link('Elixir.RabbitMQCloudWatchExporter.Exporter', [], rabbitmq_cloudwatch_exporter, 'singleton_0bpF3SXqPZTQc80tAf+lu7E5kqQ') at <0.986.0> exit with reason bad function nil in 'Elixir.RabbitMQCloudWatchExporter.Exporter':'-handle_info/2-fun-3-'/2 line 56 in context child_terminated 02 Jan 2020 17:31:33.488 on Rabbit 3.7.23 with Erlang version 22.2.1