普罗米修斯执行器的自定义路径 [英] custom path for prometheus actuator

查看:213
本文介绍了普罗米修斯执行器的自定义路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将我们的prometheus lib迁移到spring boot 2.0.3.RELEASE. 我们为普罗米修斯使用了一条自定义路径,到目前为止,我们一直在努力确保这一点.由于可能为信息端点和运行状况端点设置自定义路径,因此请使用management.endpoint.<health/info>.path. 我尝试指定management.endpoint.prometheus.path,但仍只能在/actuator/prometheus下访问.

I am currently trying to migrate our prometheus lib to spring boot 2.0.3.RELEASE. We use a custom path for prometheus and so far we use a work around to ensure this. As there is the possibility for a custom path for the info- and health-endpoint, uses management.endpoint.<health/info>.path. I tried to specify management.endpoint.prometheus.path, but it was still just accessible under /actuator/prometheus.

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

How can I use a custom path or prometheus?

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

We enable prometheus using the following libs (snippet of our 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

我们非常感谢您的帮助:)

Your help is highly appreciated :)

推荐答案

来自

默认情况下,使用终结点的ID通过HTTP在/actuator路径下公开终结点.例如,bean端点显示在/actuator/beans下.如果要将端点映射到其他路径,则可以使用management.endpoints.web.path-mapping属性.另外,如果要更改基本路径,则可以使用management.endpoints.web.base-path.

By default, endpoints are exposed over HTTP under the /actuator path by using the ID of the endpoint. For example, the beans endpoint is exposed under /actuator/beans. If you want to map endpoints to a different path, you can use the management.endpoints.web.path-mapping property. Also, if you want change the base path, you can use management.endpoints.web.base-path.

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

The following example remaps /actuator/health to /healthcheck:

management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck

因此,要将prometheus端点重新映射到/actuator下的其他路径,可以使用以下属性:

So, to remap the prometheus endpoint to a different path beneath /actuator you can use the following property:

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

以上内容将使Prometheus端点在/actuator/whatever-you-want

The above will make the Prometheus endpoint available at /actuator/whatever-you-want

如果希望Prometheus端点在根目录中可用,则必须将所有端点移到那里并重新映射它:

If you want the Prometheus endpoint to be available at the root, you'll have to move all the endpoints there and remap it:

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

以上内容将使Prometheus端点可在/whatever-you-want处使用,但其副作用是,将其他所有启用的端点也移至/而不是在/actuator以下.

The above will make the Prometheus endpoint available at /whatever-you-want but with the side-effect of also moving any other enabled endpoints up to / rather than being beneath /actuator.

这篇关于普罗米修斯执行器的自定义路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆