Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • See all Red Hat products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Red Hat OpenShift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • See all technologies
    • Programming languages & frameworks

      • Java
      • Python
      • JavaScript
    • System design & architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer experience

      • Productivity
      • Tools
      • GitOps
    • Automated data processing

      • AI/ML
      • Data science
      • Apache Kafka on Kubernetes
    • Platform engineering

      • DevOps
      • DevSecOps
      • Red Hat Ansible Automation Platform for applications and services
    • Secure development & architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & cloud native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • See all learning resources

    E-books

    • GitOps cookbook
    • Podman in action
    • Kubernetes operators
    • The path to GitOps
    • See all e-books

    Cheat sheets

    • Linux commands
    • Bash commands
    • Git
    • systemd commands
    • See all cheat sheets

    Documentation

    • Product documentation
    • API catalog
    • Legacy documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore the Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Monitoring Red Hat AMQ 7 with the jmxtrans Agent

June 6, 2018
Roman Martin Gil
Related topics:
Containers
Related products:
AMQ BrokerStreams for Apache Kafka

    Monitoring Red Hat AMQ 7

    Red Hat AMQ 7 includes some tools for monitoring the Red Hat AMQ broker. These tools allow you to get metrics about the performance and behavior of the broker and its resources. Metrics are very important for measuring performance and for identifying issues that are causing poor performance.

    The following components are included for monitoring the Red Hat AMQ 7 broker:

    • Management web console that is based on Hawtio: This console includes some perspectives and dashboards for monitoring the most important components of the broker.
    • A Jolokia REST-like API: This provides full access to JMX beans through HTTP requests.
    • Red Hat JBoss Operation Network: This is an enterprise, Java-based administration and management platform for developing, testing, deploying, and monitoring Red Hat JBoss Middleware applications.

    These tools are incredible and fully integrated with the original product. However, there are cases where Red Hat AMQ 7 is deployed in environments where other tools are used to monitor the broker, for example, jmxtrans.

    jmxtrans is a popular monitoring tool for Java-based applications. It connects to a JVM via JMX, collects metrics, and sends the data to the back end of your choice. Included in jmxtrans is an agent to be deployed inside the application that is to be monitored. This blog shows how to integrate the jmxtrans agent with Red Hat AMQ 7.

    Set Up Red Hat AMQ 7

    First, you need to get the latest stable version of the jmxtrans agent. It is possible to get it from the following places:

    • Releases from GitHub repository
    • Maven Central Repository

    Copy the jmxtrans-agent JAR file into the $ARTEMIS_INSTANCE/lib folder.

    To load the agent at bootstrap time, you need to modify the artemis file in the $ARTEMIS_INSTANCE/bin folder. It defines an environment variable (AMQ_JMSTRANS_AGENT) to update the startup command line of the broker. This environment variable allows you to configure when to use the jmxtrans agent:

    # Add jmxtrans agent
    if [ "$AMQ_JMXTRANX_AGENT" = "true" ]; then
      echo "Using jmxtrans agent to collect metrics. Configuration loaded from $ARTEMIS_INSTANCE/etc/jmxtrans-agent.xml"
      JMXTRANX_OPTS="-Xbootclasspath/p:$ARTEMIS_INSTANCE/etc -javaagent:$ARTEMIS_INSTANCE/lib/jmxtrans-agent.jar=$ARTEMIS_INSTANCE/etc/jmxtrans-agent.xml"
    fi

    Next, you should load this configuration with the startup command line defined in the artemis file, as follows:

    exec "$JAVACMD" \
     $JAVA_ARGS \
     $JMXTRANX_OPTS -Xbootclasspath/a:"$LOG_MANAGER" \
     -Djava.security.auth.login.config="$ARTEMIS_INSTANCE/etc/login.config" \
     $ARTEMIS_CLUSTER_PROPS \
     -classpath "$CLASSPATH" \
     -Dartemis.home="$ARTEMIS_HOME" \
     -Dartemis.instance="$ARTEMIS_INSTANCE" \
     -Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-$(uname -m)" \
     -Djava.io.tmpdir="$ARTEMIS_INSTANCE/tmp" \
     -Ddata.dir="$ARTEMIS_DATA_DIR" \
     -Djava.util.logging.manager="$ARTEMIS_LOG_MANAGER" \
     -Dlogging.configuration="$ARTEMIS_LOGGING_CONF" \
     $DEBUG_ARGS \
     org.apache.activemq.artemis.boot.Artemis "$@"

    Defining Queries and Metrics

    The jmstrans agent allows you to define different queries to collect metrics from JMX beans. These queries are defined in the jmxtrans-agent.xml file, which is located in the $ARTEMIS_INSTANCE/etc folder. The queries will define the JMX beans and the attributes to be collected. The following shows a sample to get metrics from addresses and queues.

    <queries>
      <!-- Addresses -->
      <query objectName="org.apache.activemq.artemis:broker=*,component=addresses,address=*"
             attributes="MessageCount,NumberOfMessages,NumberOfPages,QueueNames"
             resultAlias="service=amq7,host=#hostname#,broker=%broker%,address=%address%,attribute.#attribute#"/>
     
      <!-- Queues -->
      <query objectName="org.apache.activemq.artemis:broker=*,component=addresses,address=*,subcomponent=queues,routing-type=*,queue=*"
             attributes="ConsumerCount,MaxConsumers,DeliveringCount,MessageCount,MessagesAcknowledged,MessagesAdded,MessagesExpired,MessagesKilled"
             resultAlias="service=amq7,host=#hostname#,broker=%broker%,address=%address%,queue=%queue%,artemis.addresses.#attribute#"/>
    </queries>

    Other queries to get other metrics in the JMX tree are also valid.

    Getting Metrics from the Console

    jmxtrans includes several output writers to send the collected metrics to external services, for example, as Graphite, CSV files, and InfluxDB. The output writers are defined in the jmxtrans-agent.xml file as follows:

     <!-- Output Writers -->
     <outputWriter class="org.jmxtrans.agent.ConsoleOutputWriter" />

    This block defines the console output writer, so the metrics will be shown as messages in the server console log.

    If you now start Red Hat AMQ 7, the output will be similar to this:

    $ export AMQ_JMXTRANX_AGENT=true
    $ ./bin/artemis run
    Using jmxtrans agent to collect metrics. Configuration loaded from /opt/amq/brokers/broker01-master/etc/jmxtrans-agent.xml
    2018-06-04 17:14:39.103 INFO [main] org.jmxtrans.agent.JmxTransAgent - Starting 'JMX metrics exporter agent: 1.2.8' with configuration '/opt/amq/brokers/broker01-master/etc/jmxtrans-agent.xml'...
    2018-06-04 17:14:39.113 INFO [main] org.jmxtrans.agent.JmxTransAgent - PropertiesLoader: Empty Properties Loader
    2018-06-04 17:14:39.445 INFO [main] org.jmxtrans.agent.JmxTransExporter - Configuration reload interval: 10secs
    2018-06-04 17:14:39.445 INFO [main] org.jmxtrans.agent.JmxTransAgent - JmxTransAgent started with configuration '/opt/amq/brokers/broker01-master/etc/jmxtrans-agent.xml'
     __ __ ____ ____ _
     /\ | \/ |/ __ \ | _ \ | |
     / \ | \ / | | | | | |_) |_ __ ___ | | _____ _ __
     / /\ \ | |\/| | | | | | _ <| '__/ _ \| |/ / _ \ '__|
     / ____ \| | | | |__| | | |_) | | | (_) | < __/ |
     /_/ \_\_| |_|\___\_\ |____/|_| \___/|_|\_\___|_|
    
    Red Hat JBoss AMQ 7.1.0.GA
    2018-06-04 17:14:40,370 INFO [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server
    ...

    After some seconds, you can see that the jmxtrans agent is collecting metrics and exporting them to the console (using the ConsoleOutputWriter):

    2018-06-04 17:14:43,740 INFO [org.apache.activemq.artemis] AMQ241001: HTTP Server started at http://localhost:8161
    2018-06-04 17:14:43,740 INFO [org.apache.activemq.artemis] AMQ241002: Artemis Jolokia REST API available at http://localhost:8161/console/jolokia
    2018-06-04 17:14:43,741 INFO [org.apache.activemq.artemis] AMQ241004: Artemis Console available at http://localhost:8161/console
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,attribute.MessageCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,attribute.NumberOfMessages 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,attribute.NumberOfPages 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,attribute.QueueNames DLQ 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.ConsumerCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.MaxConsumers -1 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.DeliveringCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.MessageCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.MessagesAcknowledged 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.MessagesAdded 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.MessagesExpired 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=ExpiryQueue,queue=ExpiryQueue,artemis.addresses.MessagesKilled 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.ConsumerCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.MaxConsumers -1 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.DeliveringCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.MessageCount 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.MessagesAcknowledged 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.MessagesAdded 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.MessagesExpired 0 1528125286
    service=amq7,host=localhost,broker=0_0_0_0,address=DLQ,queue=DLQ,artemis.addresses.MessagesKilled 0 1528125286

    Sample jmxtrans-agent.xml File

    The following shows a full sample file for the jmxtrans agent to be used with Red Hat AMQ 7:

    <jmxtrans-agent>
      <queries>
        <!-- ActiveMQ Artemis -->
        <!-- Addresses -->
        <query objectName="org.apache.activemq.artemis:broker=*,component=addresses,address=*"
               attributes="MessageCount,NumberOfMessages,NumberOfPages,QueueNames"
               resultAlias="service=amq7,host=#hostname#,broker=%broker%,address=%address%,attribute.#attribute#"/>
     
        <!-- Queues -->
        <query objectName="org.apache.activemq.artemis:broker=*,component=addresses,address=*,subcomponent=queues,routing-type=*,queue=*"
               attributes="ConsumerCount,MaxConsumers,DeliveringCount,MessageCount,MessagesAcknowledged,MessagesAdded,MessagesExpired,MessagesKilled"
               resultAlias="service=amq7,host=#hostname#,broker=%broker%,address=%address%,queue=%queue%,artemis.addresses.#attribute#"/>
     
      </queries>
    
      <!-- Output Writers -->
      <outputWriter class="org.jmxtrans.agent.ConsoleOutputWriter" />
     
      <!-- Other Properties -->
      <collectIntervalInSeconds>5</collectIntervalInSeconds>
      <reloadConfigurationCheckIntervalInSeconds>60</reloadConfigurationCheckIntervalInSeconds>
    </jmxtrans-agent>

    References

    More details about how to monitor Red Hat AMQ 7 using jmxtrans are available here:

    • Monitoring Your AMQ Deployment
    • Managing the Broker Using JMX
    • Using JON with AMQ Broker
    • jmxtrans Wiki
    • jmxtrans agent Wiki
    Last updated: November 16, 2023

    Recent Posts

    • Run privileged commands more securely in OpenShift Dev Spaces

    • Advanced authentication and authorization for MCP Gateway

    • Unify OpenShift Service Mesh observability: Perses and Prometheus

    • Visualize Performance Co-Pilot data with geomaps in Grafana

    • Integrate a custom AI service with Red Hat Ansible Lightspeed

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue