当前位置: 首页 > 知识库问答 >
问题:

prometheus执行器的自定义路径

杨高翰
2023-03-14

我目前正在尝试将我们的prometheus lib迁移到spring Boot2.0.3版本。我们使用普罗米修斯的自定义路径,到目前为止,我们使用一个工作来确保这一点。由于信息endpoint和健康endpoint可能有自定义路径,因此使用management.endpoint. .path 。我尝试指定management.endpoint.prometheus.path,但它仍然只能在/acture/prometheus下访问。

如何使用自定义路径或普罗米修斯?

我们使用以下库启用prometheus(我们的build.gradle的片段)

compile "org.springframework.boot:spring-boot-starter-actuator:2.0.3.RELEASE"
compile "io.micrometer:micrometer-core:2.0.5"
compile "io.micrometer:micrometer-registry-prometheus:2.0.5"

我们还使用类PrometheusMetricSexPortautoConfiguration的导入

非常感谢您的帮助:)

共有1个答案

呼延化
2023-03-14

参考文档中:

默认情况下,通过使用endpoint的ID通过HTTP在/actulator路径下公开endpoint。例如,beansendpoint暴露在/acturet/beans下。如果要将终结点映射到不同的路径,可以使用Management.endpoints.Web.Path-Mapping属性。此外,如果要更改基路径,可以使用management.endpoints.web.base-path。

以下示例将/acture/health重新映射到/healthcheck:

management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck
management.endpoints.web.path-mapping.prometheus=whatever-you-want

如果希望Prometheusendpoint在根目录中可用,则必须将所有endpoint移动到根目录中并重新映射:

management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.prometheus=whatever-you-want

上述操作将使Prometheusendpoint在/whatery-you-want上可用,但副作用是将任何其他启用的endpoint移动到/上,而不是位于/acture下。

 类似资料:
  • 我已经激活了Spring执行器普罗米修斯endpont<代码>/执行器/普罗米修斯。通过增加对千分尺和执行器的依赖,并启用prometheus Endpont。我如何获得自定义度量?

  • 从spring-boot v1.3迁移到最新的spring-boot v2.2.4后,我们失去了在管理端口下拥有自定义endpoint的能力。 在我们将自定义endpoint声明为: 由于已从Spring引导执行器中删除了MvcEndpoint,现在我们需要执行以下操作: 不幸的是,我们失去了一个为自定义管理endpoint提供自定义根路径的选项(在它出现之前) 对于背部兼容性,我们仍然希望有默认

  • 我正在编写一个定制的ThreadPoolExecutor,具有以下额外功能:- > 如果有理想的线程,并且随着任务的到来,将该任务分配到队列中,而不是将其添加到队列中。 如果所有线程(最大池大小)都忙,则在新任务到来时,使用RejectionHandler的reject方法将它们添加到队列中 我已经重写了线程池执行程序的java 1.5版本的执行方法。 新守则如下:- 遗留代码如下所示:- 现在正

  • 我正在尝试为Spring启动应用程序编写自定义终结点。我编写了自定义终结点实现,如下所示。我没有包括额外的内容,如导入以减少代码的大小。 编写完以上代码后,我重新启动了应用程序并尝试从/test访问endpoint。但是,endpoint不可用。以下是Spring Boot start应用程序。 除此之外,我有一切运行Spring Boot致动器。我可以访问默认endpoint,如/info、/m

  • 我正在我的项目中使用模块,该模块公开了要监视的RESTendpointURL 默认情况下,仅公开 和 终结点。 根据我的使用案例,我正在通过< code > application . properties 文件自定义endpoint。 我想了解,Spring启动究竟在哪里为和创建实际的endpoint,以及它如何通过HTTP公开它们?

  • 春奴B:好的。我从一个STS Spring Starter项目/Maven/Java8/Spring Boot2.0开始,并选择Web和致动器依赖项。它构建和运行良好,并转发到http://localhost:8080/acturet/health。我在主应用程序类中添加了一个“endpoint”,使其看起来像这样。