我想监控 Kafka 指标,但不幸的是 /actuator/prometheus 端点下没有任何与 Kafka 相关的内容。我的设置中有什么遗漏吗?
应用程序依赖项:Kotlin 1.4.31、Spring Boot 2.3.9、Spring Kafka 2.6.7、Reactor Kafka 1.2.5、Kafka Clients 2.5.1
应用程序配置:
management:
server:
port: 8081
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
spring:
jmx:
enabled: true
kafka:
bootstrap-servers: ...
consumer:
group-id: my-service
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
listener:
ack-mode: manual
ssl:
key-store-location: ...
key-store-password: ...
security:
protocol: SSL
我的接收器看起来像:
@Bean
fun someEventReceiver(): SomeEventReceiver =
KafkaReceiver.create(
ReceiverOptions.create<String, SomeEvent>(kafkaProperties.buildConsumerProperties())
.withValueDeserializer(SomeEvenDeserializer())
.subscription(listOf(serviceProperties.kafka.topics.someevent))
)
和听众:
@EventListener(ApplicationStartedEvent::class)
fun onSomeEvent() {
someEventReceiver
.receive()
.groupBy { it.receiverOffset().topicPartition() }
.publishOn(Schedulers.boundedElastic())
.flatMap { someEvent ->
someEvent
.publishOn(Schedulers.boundedElastic())
.delayUntil(::handleEvent)
.doOnNext { it.receiverOffset().acknowledge() }
.retryWhen(Retry.backoff(10, Duration.ofMillis(100)))
}
.retryWhen(Retry.indefinitely())
.subscribe()
}