Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add prefix to all Spring Boot actuator endpoints

Tags:

Is there an easy way to add a prefix to all the Actuator endpoints?

/env ->     /secure/env /health ->  /secure/health /info ->    /secure/info ... 
like image 240
codependent Avatar asked Jul 08 '16 07:07

codependent


People also ask

How do you specify prefix for all controllers in spring boot?

Then, we only need to apply the annotation to each controller we want to prefix: @Controller @ApiPrefixController public class SomeController { @RequestMapping("/users") @ReponseBody public String getAll(){ // ... } }

How do you turn on all actuator endpoints in spring boot?

To enable Spring Boot actuator endpoints to your Spring Boot application, we need to add the Spring Boot Starter actuator dependency in our build configuration file. Maven users can add the below dependency in your pom. xml file. Gradle users can add the below dependency in your build.

How do I customize my spring boot actuator?

To create a custom actuator endpoints, Use @Endpoint annotation on a class. Then leverage @ReadOperation / @WriteOperation / @DeleteOperation annotations on the methods to expose them as actuator endpoint bean as needed.


1 Answers

Jesper's answer is completely right, but I was looking for a more straightforward way of prefixing all endpoints, and it can be done with management.context-path, e.g.:

management:   context-path: /secure  -> /secure/env -> /secure/health ... 
like image 179
codependent Avatar answered Sep 28 '22 08:09

codependent