7
votes

At the moment I'm playing around with Spring Boot 2.1, Spring Kafka (2.2.0) and Micrometer (1.1.0).

I created a simple example project that contains:

  • a Spring Boot 2 app publishing random Hello World message to a Kafka topic
  • a Spring Boot 2 app consuming the Hello World message from a Kafka topic
  • a docker-compose file to spin up a Kafka broker and a Zookeeper instance (both official Confluent Docker images)

My goal is to get the Kakfa consumer metrics working that are released as part of micrometer 1.1.0.

Producing and consuming the Hello World message works perfectly fine also the (kafka) metrics are exposed http://host:port/actuator/metrics but when I request a specific Kafka metric like:

http://host:port/actuator/metrics/kafka.consumer.records.consumed.total

the value of the statistic COUNT is NaN.

{
  name: "kafka.consumer.records.consumed.total",
  description: "The total number of records consumed.",
  baseUnit: "records",
  measurements: [
    {
      statistic: "COUNT",
      value: "NaN"
    }
   ],
   availableTags: [
     {
       tag: "client.id",
       values: [
         "spring-kafka-consumer-hello-world-app"
       ]
     }
   ]
 }

Did I overlook some configuration on my Spring Boot app or Kafka broker? I hope you can point me in the right direction.

You can find my example project here.

1

1 Answers

1
votes

I just ran it in a debugger and the actuator is looking for an MBean with an object name...

kafka.consumer:type=consumer-fetch-manager-metrics,\
client-id=spring-kafka-consumer-hello-world-app

and we get...

javax.management.InstanceNotFoundException: kafka.consumer:type=consumer-fetch-manager-metrics,client-id=spring-kafka-consumer-hello-world-app

...but the app actually has 3 consumer MBeans with names:

kafka.consumer:type=consumer-fetch-manager-metrics,\
client-id=spring-kafka-consumer-hello-world-app-0

(and -1, -2).

I suggest you open an issue against micrometer.