Search code examples
spring-bootprometheusmicrometerspring-micrometerapache-pulsar

Can we expose Apache Pulsar metrics through Micrometer?


The broker metrics are exposed under "/metrics/" at port 8080. But, what about the client metrics (both consumer and producer)? Can we expose Apache Pulsar metrics through Micrometer (particularly with Prometheus)?

It would be interesting if we are using Pulsar with Spring Boot. I'm not using the Spring for Apache Pulsar framework. The client metrics would be like: how long it takes to consume a batch, how many failures, etc.


Solution

  • IMHO Apache Pulsar does not have built-in support for exposing client metrics directly through Micrometer` or any other specific metrics system

    Although Pulsar does not have native integration with Micrometer, you can instrument your Pulsar client code to collect metrics and then use Micrometer to export those metrics to Prometheus.

    use the Pulsar client API's built-in mechanisms for tracking performance, failures, etc. e.g. can use timers to measure the time it takes to consume a batch and counters to track the number of failures. Once you have collected the metrics in your Pulsar client code, you can push them to Micrometer's registry, and Micrometer will expose them to Prometheus.