简体   繁体   English

Spring Boot中的指标未在Prometheus中显示

[英]Metrics from Spring Boot are not showing up in Prometheus

Followed steps given below to send Metrics from Spring Boot to Prometheus: 按照下面给出的步骤将指标从Spring Boot发送到Prometheus:

Note : I have installed Prometheus locally on my Mac using a Docker image. 注意 :我已经使用Docker映像在Mac上本地安装了Prometheus。

  1. In pom.xml added this: 在pom.xml中添加以下内容:

     <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <version>2.0.4.RELEASE</version> </dependency> <!-- Micormeter core dependecy --> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-core</artifactId> <version>1.0.6</version> </dependency> <!-- Micrometer Prometheus registry --> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> <version>1.0.6</version> </dependency> 
  2. In application.properties added this: 在application.properties中添加了以下内容:

 server.port: 9000 management.server.port: 9001 management.server.address: 127.0.0.1 management.endpoint.metrics.enabled=true management.endpoints.web.exposure.include=* management.endpoint.prometheus.enabled=true management.metrics.export.prometheus.enabled=true 
  1. Started Prometheus with following lines in configuration file: 在配置文件中以以下几行启动Prometheus:

Global configurations 全局配置

global:
  scrape_interval:     5s # Set the scrape interval to every 5 seconds.
  evaluation_interval: 5s # Evaluate rules every 5 seconds.
scrape_configs:
- job_name: 'hello-world-promethus'
  metrics_path: '/actuator/prometheus'
  static_configs:
  - targets: ['localhost:9001']

When I hit: http://localhost:9001/actuator/prometheus , I can see the metrics but they are not visible on Prometheus UI. 当我点击: http:// localhost:9001 / actuator / prometheus时 ,我可以看到指标,但是在Prometheus UI上看不到它们。

What am I missing? 我想念什么?

Solution was simple. 解决方案很简单。 You will run into this only if you're running Prometheus Docker Container. 仅在运行Prometheus Docker容器时,您才会遇到此问题。 Changed target from: 'localhost:9001' to 'docker.for.mac.localhost:9001'. 目标已从``本地主机:9001''更改为``docker.for.mac.localhost:9001''。 For example: 例如:

- job_name: hello-world-promethus
  scrape_interval: 5s
  scrape_timeout: 5s
  metrics_path: /actuator/prometheus
  scheme: http
  static_configs:
  - targets:
    - docker.for.mac.localhost:9001

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 Spring Boot 应用程序为 Prometheus 生成指标 - Generating metrics for Prometheus from Spring Boot application 普罗米修斯端点中缺少 Spring Boot Webclient 指标 - Spring Boot Webclient metrics missing in prometheus endpoint 在 Spring Boot 和 Prometheus 中监控自定义指标 - Monitor custom metrics in Spring Boot and Prometheus 如何在 Spring Boot for prometheus 中制作自己的指标 - How to make own metrics in Spring Boot for prometheus 自定义直方图指标未显示在普罗米修斯中 - Custom histogram metrics not showing up in prometheus 您如何配置prometheus.yml文件以在Spring-Boot应用程序中收集Prometheus指标? - How do you configure prometheus.yml file to collect Prometheus metrics in a Spring-Boot application? Spring Boot webapp 值未显示在控制器的 html 页面中 - Spring boot webapp values not showing up in html page from controller 使用 Sidecar/适配器模式在 Kubernestes 中为 Spring Boot 应用程序导出 Prometheus 指标 - Export Prometheus Metrics for Spring Boot Application in Kubernestes using Sidecar/ Adapter Pattern 将应用程序迁移到Spring Boot 2之后,无法将hystrix指标公开给/ actuator / prometheus - Can't expose hystrix metrics to /actuator/prometheus after migrating application to Spring boot 2 Java Spring Boot Prometheus 指标添加 log4j2_events_total 指标 - Java Spring Boot Prometheus metrics adding log4j2_events_total metric
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM