How can I configure ActiveMQ Artemis and Spring Boot to expose the metrics of the embedded ActiveMQ Artemis via the actuator API?
My goal is to expose it via the Prometheus endpoint so I can scrape it.
FYI: I am using Spring Boot 3.2
I added the following dependencies
implementation 'org.apache.activemq:artemis-jakarta-server'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-otel'
implementation 'org.springframework.boot:spring-boot-starter-artemis'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
My application.properties contains the following settings:
spring.artemis.mode=embedded
spring.artemis.password=test
spring.artemis.user=test
spring.artemis.embedded.enabled=true
spring.artemis.embedded.persistent=true
spring.artemis.embedded.data-directory=./mq-data
spring.artemis.embedded.cluster-password=test
spring.artemis.embedded.topics=module1.out.topic
management.endpoint.health.show-components=always
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=prometheus,health,hawtio
management.server.port=8090
But still the Prometheus endpoint did not provide the metrics of ActiveMQ Artemis.
I posted the question to answer it myself so that someone else can find the solution faster than I did.
ActiveMQ Artemis provides an interface for a metrics plugin that you can implement. Afterwards you need to configure your embedded ActiveMQ Artemis instance with the plugin.
How did I do it?
Provide an Implementation of the
ActiveMQMetricsPluginHere is a simple implementation of the class that allows you to pass in the
MeterRegistrythat Spring Boot Micrometer autoconfiguration provides:Configure ActiveMQ Artemis
Spring Boot provides an configuration for its auto-configuration that you can use to configure the embedded instance: