I'd like to create a custom endpoint which gives out some customized info. I know that there are two ways to achieve that: HealthIndicator and @Endpoint. But I'd like to put my endpoint under another path instead of default /health/xxx, moreover, the original health info which returned from default /health endpoint much be included in my custom endpoint as well. What should I do on this special case? Appreciate it.
Asked
Active
Viewed 670 times
0
-
Why not use `@RestController` to implement your own endpoint? The custom data retrieval you need will come from the `HealthIndicator` interface implementation. – Fermi-4 Oct 15 '21 at 01:07
-
The /actuator/ endpoint should be there once included, or you just want to redirect /actuator/health to /health? – Book Of Zeus Oct 15 '21 at 01:47
-
@Ferimi-4 Thanks. You mean I hit /actuator/health and retrieve its response manually? – Oct 15 '21 at 02:10
-
@BookOfZeus Thanks. I mean I'd like create a new endpoint like /actuator/myCustomHealth instead of putting it directly under the default /health path like /actuator/health/myCustomHealth. But I also need to include all data which returned from default /actuator/health in my new endpoint – Oct 15 '21 at 02:15
-
https://duckduckgo.com/?t=ffab&q=how+to+create+custom+actuator+endpoint&ia=web – Book Of Zeus Oct 16 '21 at 04:39
1 Answers
0
You can rewrite the url path in the application.properties
.
Once, I needed to have the health endpoint at localhost:8080/rest/status
instead of localhost:8080/actuator/health
.
In order to to this, I added these two settings in the application.properties
files which did the trick for me.
# Change actuator -> rest
management.endpoints.web.base-path=/rest/
# Change health -> status
management.endpoints.web.path-mapping.health=status

Hans-Christian
- 542
- 4
- 6