How to enable queues for remote JMX monitoring?

Latest response

Hi,

Cannot find instructions about how to configure the artemis activemq broker to enable queue over remote jmx, ie. management.xml, broker.xml, artemis.profile, etc.?

Used version.

artemis version: 2.6.3.redhat-00015
hawtio version: 1.4.0.redhat-630371
jolokia version: 1.4.0

What to configure to enable queue status within JMX monitoring?
Cannot find this within the manual pages. Please advice.

Only get the CPU, disk, uptime in the JMX monitoring...

Screenshot from amq mngmt console:
AMQ mngmt console screenshot

Screenshot from 3-party mngmt tool (for comment in discussion area below):
Problem when not using the same port

Best regards,
Fredrik

Responses

Hello Fredrik,

I am not sure I fully understand the problem you are having. When you create and start an AMQ 7 (or Artemis) broker, it also starts an embedded web console, typically available at http://localhost:8161/console. From there you can monitor all your broker addresses and you should be able to see JMX statistics for these addresses as well.

While the version of Artemis you are running seems somewhat old, it should still behave the same way. Can you confirm that you can open the web console and that you can see all addresses under the Artemis or JMX tab?

Best Regards, Torsten Mielke

Hi,

Yes. Can access through webportal... see attached picture.

Can also access the queues with jolokia (if logged in - webbrowser) according to:

http://sabstfu3369:8161/console/jolokia/exec/org.apache.activemq.artemis:broker="sabstfu3369",component=addresses,address="CoordError",subcomponent=queues,routing-type="anycast",queue="CoordError"/countMessages()

Additional: Here we struggle with system-to-system connection by oauth-handling... Looking into this also...

When we run in the logged in web browser, the jolokia REST-call works...

{"request":{"mbean":"org.apache.activemq.artemis:address=\"CoordError\",broker=\"sabstfu3369\",component=addresses,queue=\"CoordError\",routing-type=\"anycast\",subcomponent=queues","type":"exec","operation":"countMessages()"},"value":39,"timestamp":1616668212,"status":200}

The initial question, when using JMX-connection we cannot see the queues, do we need to enable some plugin, or configure some file to enable this? Or do you see that everything is as it should be according the attached image?

Using JNDI:/jmxrmi .

For remote access we disabled the management.xml and added system properties within artemis.profile according to manual.

-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=8091 
-Dcom.sun.management.jmxremote.rmi.port=8091 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Djava.rmi.server.hostname=sabstfu3369 

Best regards, Fredrik

Hello Fredrik,

Thanks for the screen shot which confirms that you can see the brokers addresses and statistics using Jolokia. I just noticed when connecting via jconsole that I can query all JMX MBeans as well, however for any of the JMX attributes I only see "Unavailable" instead of the actual attribute value.

Let me follow up further on that.

Hello Torsten,

Exact, we only see "Unavailable" for queue details...

Okay, great. I'll wait on results from you to follow up with! Thanks!

Best regards, Fredrik

Hello Fredrik,

I also had to learn that this is expected out of the box behaviour.

Please add the following lines to the end of your etc/artemis.profile file

JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.port=1099"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.rmi.port=1098"

In addition you may also want to enable the following line in etc/management.xml:

<management-context xmlns="http://activemq.org/schema">
    <connector connector-port="1099"/>

With this configuration I can connect to the Artemis broker using remote JMX connection and am able to view all JMX attributes.

I hope that helps.

Best Regards, Torsten Mielke

Nice! Will try tomorrow. Thanks! I'll come back with results... brb :)

Didn't get your config to work, had conflicts with JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.port=1099" and management.xml so the amqbroker service didn't start at all if I use both configurations at the same time.

Also the jmxremote.rmi.port need to be same as the mxremote.port otherwise I cannot connect with JMX. Maybe my JNDI-path is wrong /jmxrmi?

See comments and configuration below...

Hello Torsten,

We also run Karaf (Fuse) at the same node, so 1099 is already used.

I ​configure to use the port 1199 instead, put it both in the JAVA_ARGS in artemis.profile as you explained. And also 1199 within the management.xml file but then amqbroker didn't start...

If I use one of the 1199 then the amqbroker service start, but I cannot access it remotely.

So the only way we have working right now is only JAVA_ARGS in the artemis.profile and disabled port within the management.xml.

Any suggestions from your side? What can we try?

Best regards, Fredrik

This is our configuration right now.

The etc/artemis.profile

ARTEMIS_HOME='/opt/bst/amqbroker/amq-broker-7.2.3'
ARTEMIS_INSTANCE='/opt/bst/amqbroker/amq-broker-7.2.3/instance1'
ARTEMIS_DATA_DIR='/opt/bst/amqbroker/amq-broker-7.2.3/instance1/data'

# The logging config will need an URI
# this will be encoded in case you use spaces or special characters
# on your directory structure
ARTEMIS_INSTANCE_URI='file:/opt/bst/amqbroker/amq-broker-7.2.3/instance1/'
ARTEMIS_INSTANCE_ETC_URI='file:/opt/bst/amqbroker/amq-broker-7.2.3/instance1/etc/'

# Cluster Properties: Used to pass arguments to ActiveMQ Artemis which can be referenced in broker.xml
#ARTEMIS_CLUSTER_PROPS="-Dactivemq.remoting.default.port=61617 -Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 -Dactivemq.remoting.hornetq.port=544

JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.ssl=false"
# This line cannot be enabled, then the service broker will not start...
#JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.port=1199"
JAVA_ARGS="$JAVA_ARGS -Dcom.sun.management.jmxremote.rmi.port=1199"

JAVA_ARGS="$JAVA_ARGS -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx2G -Dhawtio.realm=activemq  -Dhawtio.offline="true" -Dhawtio.role=amq,view -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml -Djon.id=amq"

And the etc/management.xml

<management-context xmlns="http://activemq.org/schema">
   <connector connector-port="1199" />
   <authorisation>
      <whitelist>
         <entry domain="org.apache.activemq.artemis"/>
      </whitelist>
      <default-access>
         <access method="list*" roles="amq"/>
         <access method="get*" roles="amq"/>
         <access method="is*" roles="amq"/>
         <access method="set*" roles="amq"/>
         <access method="*" roles="amq"/>
      </default-access>
      <role-access>
         <match domain="org.apache.activemq.artemis">
            <access method="list*" roles="amq"/>
            <access method="get*" roles="amq"/>
            <access method="is*" roles="amq"/>
            <access method="set*" roles="amq"/>
            <access method="*" roles="amq"/>
         </match>
         <match domain="org.apache.activemq.artemis" key="subcomponent=queues">
            <access method="list*" roles="amq"/>
            <access method="get*" roles="amq"/>
            <access method="is*" roles="amq"/>
            <access method="set*" roles="amq"/>
            <access method="*" roles="amq"/>
         </match>
      </role-access>
   </authorisation>
</management-context>

If we not use the same port for jmxremote.port and jmxremote.rmi.port then we cannot connect and fetch the jmx-information at all...

See screenshot attached at the top.

Failed. Failed to retrieve RMIServer stub

Best regards, Fredrik

Hello Fredrik,

The line in etc/mangement.xml

  <connector connector-port="1199" />

should only be needed when using remote access to Hawtio/Jolokia but you seem to access the brokers statistics using plain JMX connections. In that case it should suffice to add the JAVA_ARGS just as you did.

I am not sure why it still does not work for you.