use*_*256 3 spring spring-boot spring-boot-actuator prometheus micrometer
我正在使用 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>
Run Code Online (Sandbox Code Playgroud)
我的 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>
Run Code Online (Sandbox Code Playgroud)
在 Prometheus UI 中查看指标的下一步是什么,最终目标是将 Prometheus 集成到 Grafana。
PS:我在 google 上进行了搜索,并尝试添加 prometheus.yml 并添加诸如 @EnablePrometheusEndpoint 之类的注释,因为所有文章都是旧的,因此没有任何效果。
编辑:如果 spring boot jar 托管在不同的主机(Azure/AWS)和 prometheus 服务器在不同的主机中,那么如何配置 prometheus.yml(metrics_path,targets)。
如果您使用的是 Spring Boot 2 和 micrometer,则不需要添加额外的依赖项,它们会在您添加micrometer-registry-prometheus
. 如果您能够在 localhost/manage/prometheus 上看到指标,那么您在 spring-boot 端的配置就可以了。无需再配置任何东西。
要查看 Prometheus 中的指标,您需要:
刮配置: - 工作名称:'mySpringBoot' 指标路径:'/管理/普罗米修斯' 静态配置: - 目标:['springBootHost:springBootPort']
UP
- http://localhost:9090/targets(假设 Prometheus 在 localhost 上运行)DOWN
存在配置或网络问题。以下步骤很简单,其他地方有很多文档:
归档时间: |
|
查看次数: |
940 次 |
最近记录: |