【发布时间】:2026-02-14 09:05:02
【问题描述】:
我使用的是 spring boot 2.0 并在 POM 中添加了以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
我的 application.yml 看起来像这样
management.endpoints.web.base-path = /manage
management.endpoints.web.exposure.include = "*"
endpoints.prometheus.enabled = true
当我在
访问 Prometheus 时本地主机/管理/普罗米修斯
我可以看到所有指标。
接下来,我的目标是在 Prometheus UI 中查看上述指标。为此,我在我的 POM 中添加了以下依赖项
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId>
<version>${prometheus.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>${prometheus.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_servlet</artifactId>
<version>${prometheus.version}</version>
</dependency>
在 Prometheus UI 中查看指标的下一步是什么,最终目标是将 Prometheus 集成到 Grafana。
PS:我在 google 上进行了搜索,并尝试添加 prometheus.yml 并添加诸如 @EnablePrometheusEndpoint 之类的注释,因为所有文章都是旧的,所以没有任何效果。
编辑:如果 spring boot jar 托管在不同的主机(Azure/AWS)并且 prometheus 服务器在不同的主机中,如何配置 prometheus.yml(metrics_path,targets)。
【问题讨论】:
标签: spring spring-boot prometheus spring-boot-actuator micrometer