eclipse - 运行 Prometheus 时,我的所有端点都开始返回 404
问题描述
我有运行良好的 SpringBoot 应用程序,当我使用 Postman 访问我的 API 端点时,我的端点会返回正确的响应。
与我的执行器相同。他们工作正常。
我还添加了 spring 依赖项micrometer-core
,并将micrometer-registry-prometheus
其添加到我的 Actuators 新路径“/prometheus”中。此路径也可以正常工作并返回指标。
由于我想查看图形,我从官方网站(zip 文件)下载了独立的 Prometheus 应用程序(所以没有 docker 映像)并将其解压缩。
里面有 prometheus.exe 和 prometheus.yaml 文件。
即使根本没有修改这个 yaml 文件,只要我双击 prometheus.exe 启动它(它会正确启动它),我的所有端点都会停止返回 200 OK 并开始返回 404 Not Found 响应。
然后我修改它以添加我的工作名称和路径
-job_name: 'spring-actuators'
metric_path: '/myappname/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
即使更改为现在从“myappname”中抓取指标,每次我尝试使用 Postman 向我的 API 发送请求时,只要我启动 prometheus,我仍然会收到 404 响应。
我注意到 postman.exe 控制台在服务器准备好请求后也立即显示错误:
level=info ts=2021-06-02T15:42:03.421Z caller=main.go:775 msg="Server is ready to receive web requests."
level=error ts=2021-06-02T15:42:10.374Z caller=db.go:780 component=tsdb msg="compaction failed" err="compact head: persist head block: rename block dir: rename data\\01F76P79CQDPFVGZS5XNTDTK4P.tmp-for-creation data\\01F76P79CQDPFVGZS5XNTDTK4P: Access is denied."
解决方案
您的应用在 Prometheus 的同一端口上公开端点9090
。更改您的 Spring Boot 应用程序以在8080
除9090
. 然后在该端口抓取您的应用程序。
-job_name: 'spring-actuators'
metric_path: '/myappname/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:8080']
推荐阅读
- android - “从 PlaceSelectionListener 派生的匿名类”类必须声明为抽象或实现抽象方法
- selenium - 当我尝试使用自动化代码时,为什么字段集不能自动填充?
- windows - 主题中以“ST”作为状态的证书破坏了 MSIX 打包工具...如何为状态生成带有“s”而不是“st”的证书
- facebook - 如何禁用 FB 页面 API
- amazon-web-services - Redshift 分配键 NULL 约束
- google-cloud-platform - 在项目之间共享 GCP KMS 密钥
- c++ - 我的 while 循环和 else if 循环不起作用
- java - HashMap 抛出 NullException 甚至 Map.containsKey 返回 true
- javascript - 导出 excel 并拉伸列长度以适合单元格上的文本
- php - 如何从 Controller 调用 Mailable 函数?