无法在 spring 启动 2(版本 2.0.0.M7)中包含 Prometheus 指标
Cannot include Prometheus metrics in spring boot 2 (version 2.0.0.M7)
无法在 spring boot 2(版本 2.0.0.M7)项目中包含 Prometheus 指标。
根据 micrometer docs 添加了 spring-boot-starter-actuator 依赖项并在 application.yaml 添加了 management.endpoints.web.expose: prometheus 但是当调用 /actuator/prometheus get
{
"timestamp": 1518159066052,
"path": "/actuator/prometheus",
"message": "Response status 404 with reason \"No matching handler\"",
"status": 404,
"error": "Not Found"
}
请告诉我为什么我没有获得普罗米修斯指标?
您是否将 micrometer-registry-prometheus
添加到您的依赖项中?
Micrometer 有一个可插入的架构,您需要在其中定义(通过插入依赖项)您想要使用的监控系统。 (您甚至可以添加多个,而不仅仅是一个。)
顺便说一句,您应该切换到 Spring 引导 2.0.0.RC1
。这是撰写本文时的最新版本。
编辑:自从我给出这个答案以来,发生了很多变化。它对 2.0.0.RC1 有效。请阅读文档 https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html
如果上述解决方案对某人不起作用,请尝试以下操作:
Spring Boot 2.0.0.RC1,spring-boot-starter-web,当然还有 spring-boot-starter-actuator.
也有同样的问题
我的 application.properties 文件读取:
management.endpoints.web.expose=prometheus,metrics,info,health
在我的 pom 文件中我还有:
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>0.12.0.RELEASE</version>
</dependency>
/actuator/prometheus 下的 Prometheus 指标仅在我切换到最新版本的 micrometer-registry-prometheus 后显示:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.0.0-rc.9</version>
</dependency>
我在使用 Springboot 2.x 启动千分尺时遇到了问题。
我的项目中的这些更改帮助我在actuator/prometheus
端点
公开指标
这些是我的 application.properties 文件
中的更改
management.endpoints.web.exposure.include=*
management.endpoint.metrics.enabled=true
包含我的build.gradle文件
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.micrometer:micrometer-registry-prometheus')
无法在 spring boot 2(版本 2.0.0.M7)项目中包含 Prometheus 指标。
根据 micrometer docs 添加了 spring-boot-starter-actuator 依赖项并在 application.yaml 添加了 management.endpoints.web.expose: prometheus 但是当调用 /actuator/prometheus get
{
"timestamp": 1518159066052,
"path": "/actuator/prometheus",
"message": "Response status 404 with reason \"No matching handler\"",
"status": 404,
"error": "Not Found"
}
请告诉我为什么我没有获得普罗米修斯指标?
您是否将 micrometer-registry-prometheus
添加到您的依赖项中?
Micrometer 有一个可插入的架构,您需要在其中定义(通过插入依赖项)您想要使用的监控系统。 (您甚至可以添加多个,而不仅仅是一个。)
顺便说一句,您应该切换到 Spring 引导 2.0.0.RC1
。这是撰写本文时的最新版本。
编辑:自从我给出这个答案以来,发生了很多变化。它对 2.0.0.RC1 有效。请阅读文档 https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html
如果上述解决方案对某人不起作用,请尝试以下操作: Spring Boot 2.0.0.RC1,spring-boot-starter-web,当然还有 spring-boot-starter-actuator.
也有同样的问题我的 application.properties 文件读取:
management.endpoints.web.expose=prometheus,metrics,info,health
在我的 pom 文件中我还有:
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>0.12.0.RELEASE</version>
</dependency>
/actuator/prometheus 下的 Prometheus 指标仅在我切换到最新版本的 micrometer-registry-prometheus 后显示:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.0.0-rc.9</version>
</dependency>
我在使用 Springboot 2.x 启动千分尺时遇到了问题。
我的项目中的这些更改帮助我在actuator/prometheus
端点
这些是我的 application.properties 文件
中的更改management.endpoints.web.exposure.include=*
management.endpoint.metrics.enabled=true
包含我的build.gradle文件
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.micrometer:micrometer-registry-prometheus')