我们将Spring Boot的版本从2.2.2升级到了2.3.0,但所有的指标都消失了。kafka_consumer_*
2.2.2 中在 Prometheus 端点中看到的指标在 2.3.0 中不可见。
例如,下面所有的指标都不见了。
kafka_consumer_records_consumed_total_records_total
kafka_consumer_records_lag_records
kafka_consumer_fetch_latency_max_seconds
kafka_consumer_bytes_consumed_total_bytes_total
不知道是我们缺少了某种配置还是文档中的某些东西...
以下是我们的 build.gradle.kts
变化之前。
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.2.2.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
kotlin("jvm") version "1.3.72"
kotlin("plugin.spring") version "1.3.72"
}
group = "ourGroup"
version = "0.0.1"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
extra["springCloudVersion"] = "Hoxton.RELEASE"
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
dependencies {
implementation("org.springframework.cloud:spring-cloud-starter-stream-kafka")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.springframework.security:spring-security-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
现在,如果我们只是更新我们的 build.gradle.kts
在新的spring boot版本下,我们的kafka指标消失了。
id("org.springframework.boot") version "2.3.0.RELEASE"
以下是我们在改变前后看到的prometheus指标的截图。
先谢谢你的帮助! 如果你需要任何其他细节,请告诉我!
对于普通的spring-kafka消费者来说,它可以工作
@SpringBootApplication
public class So62292889Application {
public static void main(String[] args) {
SpringApplication.run(So62292889Application.class, args);
}
@KafkaListener(id = "so62292889", topics = "so62292889")
public void listen(String in) {
System.out.println(in);
}
@Bean
public NewTopic topic() {
return TopicBuilder.name("so62292889").partitions(1).replicas(1).build();
}
@Bean
public ApplicationRunner runner(MeterRegistry registry) {
return args -> {
registry.getMeters().forEach(meter -> System.out.println(meter.getId()));
};
}
}
MeterId{name='kafka.consumer.outgoing.byte.total'...
我看你用的是spring-cloud-stream。问题是这个项目自己创建了producterconsumer工厂,没有添加Micrometer监听器。
和 @jumping_monkey 类似,我也有一个。spring-kafka
应用程序使用Spring Boot 2.3.0.RELEASE和 kafka_consumer_*
指标没有显示在 /actuator/prometheus
. 他们 做了 当我降级到Spring Boot 2.2.7.RELEASE时,出现了一些问题。
已经确定,对于使用 spring-cloud-stream
有一个计划来解决这个问题。我的应用程序不使用 spring-cloud-stream
然而,它使用的是 spring-kafka
.
解决办法是按照《指南》上的指导意见。春天-卡夫卡参考文献 添加 MicrometerConsumerListener
到消费工厂。做完这些,指标就会如期显示出来。