我正在使用 Spring boot 2、Kafka 2.1.4,我想在 Spring Boot 执行器的执行器/指标端点中公开 kafka Producer 指标
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${boot.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>${micrometer.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus
</artifactId>
<version>${micrometer.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在我的属性文件中,如下所示 # application.properties
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
management.endpoint.metrics.enabled=true
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
Run Code Online (Sandbox Code Playgroud)
结果没有kafka生产者指标只有Jvm和Tomcat
http://localhost:8080/actuator/metrics
0 "jvm.memory.max"
1 "jvm.threads.states"
2 "jvm.gc.memory.promoted"
3 "tomcat.cache.hit"
4 "tomcat.servlet.error"
5 "tomcat.cache.access"
6 "jvm.memory.used"
7 "jvm.gc.max.data.size"
8 "jvm.gc.pause"
9 "jvm.memory.committed"
10 "system.cpu.count"
11 "logback.events"
12 "tomcat.global.sent"
13 "jvm.buffer.memory.used"
14 "tomcat.sessions.created"
15 "jvm.threads.daemon"
16 "system.cpu.usage"
17 "jvm.gc.memory.allocated"
18 "tomcat.global.request.max"
19 "tomcat.global.request"
20 "tomcat.sessions.expired" …Run Code Online (Sandbox Code Playgroud) metrics spring-boot-actuator prometheus kafka-producer-api spring-micrometer