title: Spring boot 2.3.4 - Kafka metrics are not visible in /actuator/prometheus
body: <p>I have a spring boot application (version 2.3.4) and I'm using @KafkaListener to consume records. I also use actuator and micrometer (version 1.5.5) for the metrics.</p>
  <p>The problem is that I can't see the Kafka metrics in  /actuator/prometheus.
  I'm using the following dependencies:</p>
  <pre><code>'org.springframework.boot' version '2.3.4.RELEASE'
  implementation group: 'org.springframework.kafka', name: 'spring-kafka', version: '2.5.10.RELEASE'
  implementation group: 'org.apache.kafka', name: 'kafka-clients', version: '2.5.1'
  </code></pre>
  <p>And added these properties to application.yaml:</p>
  <pre><code>management:
    server:
      port: 9091
    endpoints:
      web:
        exposure:
          include: &quot;*&quot;
    endpoint:
      health:
        probes:
          enabled: true
  
  spring:
    jmx:
      enabled: true
  </code></pre>
  <p>Trying to under if I should add anything else to make the kafka metrics visible in /actuator/prometheus</p>
  <p>Note that the metrics are visible when I use default KafkaTemplate, but when trying to create a custom KafkaTemplate, the metrics disappear:</p>
  <pre><code>@SpringBootApplication
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
      @Bean
      public ProducerFactory&lt;String, String&gt; customProducerFactory() {
          Map&lt;String, Object&gt; configProps = new HashMap&lt;&gt;();
          configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, &quot;127.0.0.1:9092&quot;);
          configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, Serdes.String().serializer().getClass().getName());
          configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, Serdes.String().serializer().getClass().getName());
          return new DefaultKafkaProducerFactory&lt;&gt;(configProps);
      }
  
      @Bean
      public KafkaTemplate&lt;String, String&gt; customProducer() {
          return new KafkaTemplate&lt;&gt;(customProducerFactory());
      }
  
      @KafkaListener(id = &quot;test&quot;, topics = &quot;test_topic&quot;)
      public void listen(String in) {
          System.out.println(in);
      }
  
      @Bean
      public NewTopic topic() {
          return TopicBuilder.name(&quot;test_topic&quot;).partitions(1).replicas(1).build();
      }
  
  
      @Bean
      public ApplicationRunner runner(KafkaTemplate&lt;String, String&gt; template) {
          return args -&gt; {
              template.send(&quot;test_topic&quot;, &quot;foo&quot;);
          };
      }
  }
  </code></pre>