Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared 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
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

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

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • 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 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

Share:

    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

    • More Essential AI tutorials for Node.js Developers

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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

    Red Hat legal and privacy links

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

    Report a website issue