activemq-artemis

How can I expose more attributes as metrics from ActiveMQ Artemis


To expose metrics from ActiveMQ Artemis I'm using this plugin, and it works fine for me. There are a few metrics which I need, such as First Message Age. Is there a way I can add it in the implementation of the plugin? Or does it need to be added in ActiveMQ itself?


Solution

  • To expose more attributes you'd need to modify the broker itself.

    The metrics plugin implementations simply take what is exposed by the broker and put it into a format consumable by the target system (i.e. Prometheus).

    To be clear, the First Message Age attribute was intentionally not exposed due to a couple of issues:

    1. All of the "first message" attributes on the queue are relatively expensive to execute because they require actually inspecting the first message on the queue. This inspection pauses normal queue operation which can negatively impact the performance of both consumers and producers on the queue. A broker can support tens of thousands of queues and metrics can be gathered every few seconds. Combining these factors together with the performance impact of the "first message" operation(s) can add up to a meaningful difference in behavior.
    2. Most folks who want to know the First Message Age simply want to use the age of the message as a way to determine whether or not messages are being consumed effectively. However, this can be deduced by inspecting other metrics. For example, if Message Count > 0 and Consumer Count > 0 but Messages Acknowledged is stagnant then you likely have a stalled consumer. Tools like Prometheus have a rich query language that should be able to handle this kind of work.