Resilience4j | Expose Circuit Breaker Metrics to JMX using Micrometer | Simple example

In this article we will look at very simple & basic example to expose Resilience4j circuit breaker statistics i.e. metrics to JMX in the form of JMX MBean. We will use the code example from this article to expose JMX metrics.

Resilience4j | Circuit breaker basics & runtime behavior/state changes | Simple example for beginners

Resilience4j integration with Micrometer

Resilience4j provides integration with Micrometer. Micrometer is a simple facade library for popular monitoring systems. Micrometer provides a way to expose its statistic over JMX which we will be using for this article.

Maven dependencies required for this example



Circuit Breaker example with micrometer & JMX integration

In below example, you can see a micrometer meter registry created using very simple jmx configurations. Then we bind circuit breaker registry with the meter registry. For any other classes used in this example, refer the article.

Output of this program & runtime behavior can be referred in this article.



Lets look at the JMX Mbean exposed by this example. You can run this application & then go to jconsole from your JDK/bin. In JConsole application, select the process of above program as shown below.

Then go to MBeans tab & you will see “metrics” JMX mbean which provides lot of different statistics for circuit breaker. Below screenshot shows failure rate statistics at that moment. You can keep refreshing to get latest stats.



These are the metrics that are exposed in above example.

  • resilience4jCircuitbreakerBufferedCalls.kind.failed.name.externalService
  • resilience4jCircuitbreakerBufferedCalls.kind.successful.name.externalService
  • resilience4jCircuitbreakerCalls.kind.failed.name.externalService
  • resilience4jCircuitbreakerCalls.kind.ignored.name.externalService
  • resilience4jCircuitbreakerCalls.kind.not_permitted.name.externalService
  • resilience4jCircuitbreakerCalls.kind.successful.name.externalService
  • resilience4jCircuitbreakerFailureRate.name.externalService
  • resilience4jCircuitbreakerSlowCallRate.name.externalService
  • resilience4jCircuitbreakerSlowCalls.kind.failed.name.externalService
  • resilience4jCircuitbreakerSlowCalls.kind.successful.name.externalService
  • resilience4jCircuitbreakerState.name.externalService.state.closed
  • resilience4jCircuitbreakerState.name.externalService.state.disabled
  • resilience4jCircuitbreakerState.name.externalService.state.forced_open
  • resilience4jCircuitbreakerState.name.externalService.state.half_open
  • resilience4jCircuitbreakerState.name.externalService.state.open



Leave a Reply

Your email address will not be published.