Error shutting down ActiveMQ with JMX Exporter

124 views
Skip to first unread message

Brad Pridgeon

unread,
May 19, 2020, 6:00:12 PM5/19/20
to Prometheus Users
I'm testing this JMX Exporter with ActiveMQ to get metrics.  Per instructions in this post, I setup the jar as a Java agent.

Here are the changes in the activemq/bin/env file:

if [ -z "$ACTIVEMQ_OPTS" ] ; then
    ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config"
fi

ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -javaagent:/apps/jmx_exporter/jmx_prometheus_javaagent-0.13.0.jar=localhost:8042:/apps/jmx_exporter/config.yml"

It starts correctly, and the metrics are accessible over the configured port, but when I stop ActiveMQ, I get the following exception below.  Does anyone know why this is occurring ?

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at sun.net.httpserver.ServerImpl.(ServerImpl.java:100)
at sun.net.httpserver.HttpServerImpl.(HttpServerImpl.java:50)
at sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:35)
at com.sun.net.httpserver.HttpServer.create(HttpServer.java:130)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer.(HTTPServer.java:176)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:31)

Harald Koch

unread,
May 19, 2020, 9:53:36 PM5/19/20
to Prometheus Users

On Tue, May 19, 2020, at 18:00, Brad Pridgeon wrote:
I'm testing this JMX Exporter with ActiveMQ to get metrics.  Per instructions in this post, I setup the jar as a Java agent.

Just FYI - unless your traffic volumes are low, I don't recommend this. Accessing the ActiveMQ JMX endpoints causes high CPU usage and measurably affects performance.

--
Harald


Dhinesh Kumar Thiruppathi

unread,
Aug 19, 2020, 9:22:33 AM8/19/20
to Prometheus Users
I too face similar issue while shutting down the ActiveMQ broker, when running the JMX exporter as java agent in the JVM. 

Please suggest.

Reply all
Reply to author
Forward
0 new messages