Skip to content

An implementation of Kafka metrics reporter which binds Kafka metrics to micrometer

Notifications You must be signed in to change notification settings

sahabpardaz/kafka-micrometer-binder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kafka Micrometer Binder

Tests Coverage Quality Gate Status JitPack

An implementation of Kafka MetricsReporter which binds Kafka client metrics to Micrometer.

Kafka has a built-in mechanism which allows us to gather its metrics and report them to different sources. In order to do so, we should implement MetricsReporter interface and register our class in client configs. After that, our implementation will receive metrics events from Kafka. The purpose of this library is to gather Kafka metrics and reports them to micrometer registry.

Usage

In Kafka consumer/producer configs you should set metric.reporters property to ir.sahab.micrometer.kafka.MicrometerKafkaMetricsReporter. Also, you should set a unique client.id which helps distinguish different clients' metrics in the same JVM.

for example:

KafkaConsumer<String, String> consumer = new KafkaConsumer<>(Map.of(
        "client.id", "events-consumer",
        "metric.reporters", MicrometerKafkaMetricsReporter.class.getName(),
        ...
        ));

Reported metrics will be like:

kafka.consumer.node.outgoing.byte.rate{client-id="events-consumer", node-id="node--1"}
kafka.consumer.coordinator.rebalance.total{client-id="events-consumer"}
...

About

An implementation of Kafka metrics reporter which binds Kafka metrics to micrometer

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages