Example for using Axon Metrics with Spring Boot

378 views
Skip to first unread message

Patrick Geschinski

unread,
Dec 17, 2017, 5:53:07 AM12/17/17
to Axon Framework Users
Hey Guys,

can someone provide me an example how to register metrics with spring boot acutator ?

Greets.


Allard Buijze

unread,
Dec 18, 2017, 10:55:47 AM12/18/17
to axonfr...@googlegroups.com
Hi Patrick,

which part of registering Metrics do you need help with? 

If you already have your metrics, check out https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-dropwizard-metrics to see how to register them with Spring Boot.

To register the metrics measurements in Axon, check out the axon-metrics component. It contains a "org.axonframework.metrics.GlobalMetricRegistry" class that allows you to register metrics implementations of MessageMonitors for your components. If you autowire your (Axon) Configurer, MetricsRegistry (the one from dropwizard), you can instantiate a GlobalMetricRegistry instance and tell it to configure the Configurer to use the Metrics implementations. Tip: you can use @Autowired methods in your Spring Configuration classes to do these kind of things easily.

Cheers,

Allard

Op zo 17 dec. 2017 om 11:53 schreef Patrick Geschinski <patrick.g...@gmail.com>:
Hey Guys,

can someone provide me an example how to register metrics with spring boot acutator ?

Greets.


--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Patrick Geschinski

unread,
Dec 18, 2017, 3:43:53 PM12/18/17
to Axon Framework Users
Hi Allard,

thanks for your answer.
I forgot to mention that i have something like this:

@Autowired
private MetricRegistry metricRegistry;

@Bean
public GlobalMetricRegistry globalMetricRegistry() {
GlobalMetricRegistry globalMetricRegistry = new GlobalMetricRegistry(this.metricRegistry);
globalMetricRegistry.registerEventBus("eventBus");
return globalMetricRegistry;
}

And then i see some new metrics like these:

  • eventBus.messageTimer.ignoredTimer.fifteenMinuteRate0,
  • eventBus.messageTimer.successTimer.snapshot.999thPercentile0,
  • eventBus.messageTimer.allTimer.fifteenMinuteRate0,
  • eventBus.messageTimer.successTimer.snapshot.99thPercentile0,
  • eventBus.messageTimer.failureTimer.snapshot.max0,
  • eventBus.messageTimer.failureTimer.oneMinuteRate0,
  • eventBus.messageTimer.ignoredTimer.snapshot.98thPercentile0,
  • eventBus.messageTimer.failureTimer.snapshot.min0,
  • ....
But after firing some events and commands the counter stays the same...

So i think there is a missing link that i didn't consider...

Greets

Patrick

Allard Buijze

unread,
Dec 19, 2017, 4:31:49 AM12/19/17
to axonfr...@googlegroups.com
Hi Patrick,

the "registerEventBus" method registers the metrics with the MetricsRegistry, and returns an EventMonitor instance to use. That instance still needs to be registered with the EventBus itself to have the counters (and timers, etc) triggered.

For that, you can add the Configurer as a parameter, and do:

MessageMonitor<Message<?>> eventBusMonitor = globalMetricRegistry.registerEventBus("eventBus");
configurer.configureMessageMonitor(EventBus.class, (config, type, name) -> eventBusMonitor);

Also note that you can add dependencies as method parameters in Spring @Bean methods.

Cheers,

Allard

Op ma 18 dec. 2017 om 21:43 schreef Patrick Geschinski <patrick.g...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Patrick Geschinski

unread,
Dec 19, 2017, 8:47:55 AM12/19/17
to axonfr...@googlegroups.com
Hey Allard,

thank you.
Now it works...

I had some trouble because i use the axon spring autoconfiguration and the code above throws the Exception: "this builder has already been built"
So i moved to my own configuration for the EventBus and EventStore.

Greets

Patrick

To unsubscribe from this group and stop receiving emails from it, send an email to axonframework+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/QpUhVYwVnsM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.

pvanle...@gmail.com

unread,
Feb 13, 2018, 10:43:01 AM2/13/18
to Axon Framework Users
Hello Patrick,

I too am having problems getting the axon-metrics up and running on the event bus and we are using a spring boot autoconfigure approach as well. What I also tried is to define the eventStorageEngine myself, rather than relying on the autoconfigure feature. However, all metrics remain stuck at 0.
We were able to register the distinct registerEventProcessors, but this is quite overwhelming in the information it provides. Moreover, I'd settle for an overview of the metrics on the eventBus,

Could you send an excerpt of code that is actually working?

Kind regards,
Patrick

Op dinsdag 19 december 2017 14:47:55 UTC+1 schreef Patrick Geschinski:
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/QpUhVYwVnsM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframewor...@googlegroups.com.

Allard Buijze

unread,
Feb 14, 2018, 10:58:38 AM2/14/18
to axonfr...@googlegroups.com
Hi,

there seems to be an ordering issue in the definition of beans. In my experience, configuring the monitoring the main application context file solves this issue.
Meanwhile, we’ll be looking for better ways to work around this problem).

Cheers,

Allard
Message has been deleted

Steven van Beelen

unread,
Sep 16, 2020, 5:38:52 AM9/16/20
to Axon Framework Users
Hi Java Developer,

The metrics exposed by an Axon Framework application or only captured on sending and receiving messages.
Thus, you can define metrics for CommandBus (sending and receiving command metrics), EventBus (sending event metrics), QueryBus (sending and receiving query metrics), Event Processor (receiving event metrics) and the QueryUpdateEmitter (specific for update metrics on the subscription query).
Having said that, there is no means through which an Axon Framework application will share the amount of snapshots provided, as there is no place to tie a MessageMonitor to the snapshotting process.

There is some additional information available through Axon Server (of which I am uncertain if you are using it).
Specifics on how to consume these and what can be consumed, can be found here.

Trusting this will help you further!

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
Instead of this mailing list we have moved to use a forum style of communication, at https://discuss.axoniq.io/.
Hope to see you there!

On Wed, Jul 22, 2020 at 8:07 AM Java Developer <axondev...@gmail.com> wrote:
Hi Guys,

I am new to axon framework and prometheus I wanted to expose and enable axon metrics in prometheus for snapshot.

I refer the documentation below is link for the same

https://docs.axoniq.io/reference-guide/operations-guide/setting-up-axon-server/monitoring

So here it is mentioned it would be available under endpoint /actuator/metrics but when I try to hit that I found there was no metrics related to axon specific. So I added axon-micrometer dependency in my classpath and by adding that I saw metrics related to eventbus and querybus but not anything related to snapshots, commands or events.

I am using axon version 4.3.3 and spring boot version 2.3.0 and have added micrometer-registry dependency in my classpath.
And only change in my code is I have set my web base-path as /manage so in that case all metrics I will be seeing in /manage/metrics

can anyone guide me how to expose or enable metrics related to axon.snapshots.count and others related to commands and events. Is there anything else that needs to be added dependency or any property?

Thanks


--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages