我正在尝试通过使用Spring Boot 2实现的api向Prometheus公开计时指标。我包括以下依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
我正在通过spring-cloud-starter-parent Finchley.SR1管理依赖关系,这给我在spring-boot-starter-actuator上提供了2.0.4.RELEASE版本,在micrometer-registry-prometheus上提供了1.0.6版本。 >
/ actuator / prometheus端点正在运行并且可以访问,但是不包括我需要的指标。当我查看/ acutator / metrics时,此处未列出“ http.server.requests”指标:
{ "names": [ "jvm.memory.max", "cache.eviction.weight", "cache.gets", "process.files.max", "jvm.gc.memory.promoted", "tomcat.cache.hit", "system.load.average.1m", "tomcat.cache.access", "jvm.memory.used", "jvm.gc.max.data.size", "jvm.gc.pause", "jvm.memory.committed", "system.cpu.count", "logback.events", "tomcat.global.sent", "jvm.buffer.memory.used", "tomcat.sessions.created", "jvm.threads.daemon", "system.cpu.usage", "jvm.gc.memory.allocated", "tomcat.global.request.max", "tomcat.global.request", "tomcat.sessions.expired", "jvm.threads.live", "jvm.threads.peak", "tomcat.global.received", "process.uptime", "cache.puts", "cache.size", "cache.evictions", "tomcat.sessions.rejected", "process.cpu.usage", "tomcat.threads.config.max", "jvm.classes.loaded", "jvm.classes.unloaded", "tomcat.global.error", "tomcat.sessions.active.current", "tomcat.sessions.alive.max", "jvm.gc.live.data.size", "tomcat.servlet.request.max", "tomcat.threads.current", "tomcat.servlet.request", "process.files.open", "jvm.buffer.count", "jvm.buffer.total.capacity", "tomcat.sessions.active.max", "tomcat.threads.busy", "process.start.time", "tomcat.servlet.error" ] }
根据文档,以及我在Google搜索中所能找到的所有内容,它应该是自动配置的指标之一。
我已经尝试过将spring.metrics.web.server.auto-time-requests属性设置为true,并在要测试的端点上使用@Timed批注,但无论如何,我一无所获。
我发现这个已解决的问题,其中有人具有相同的症状,但是他们使用的是Spring Boot 1.5,并且他们的问题是我没有的不必要的额外依赖关系:
Actuator /metrics endpoint does not include http.server.requests
任何想法会导致执行器不公开http.server.requests指标吗?
我正在尝试通过Spring Boot 2实现的api向Prometheus公开计时指标。我包括以下依赖项。
访问任何一个端点后都可以吗?只需从邮递员或您的应用中尝试一下,然后检查/metrics
端点即可。我希望它应该在那里。