Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom path for prometheus actuator

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?

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"

we also use the import of the class PrometheusMetricsExportAutoConfiguration

Your help is highly appreciated :)

like image 482
Ruth Avatar asked Jul 05 '18 15:07

Ruth


1 Answers

From the reference documentation:

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.

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

application.properties:

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

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

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

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

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.

like image 66
Andy Wilkinson Avatar answered Sep 20 '22 23:09

Andy Wilkinson