2

I have a requirement to expose a health endpoint on the root path on the specific port.

However, root path is reserved for the actuator endpoints overview and I could not find a way to overwrite that overview functionality with the specific endpoint functionality.

This DOES NOT work:

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

As a workaround, I created a rest controller which redirects "/" to "/actuator/health". But it looks ugly. Does anybody know a better solution?

santik
  • 346
  • 1
  • 12
  • you were almost there with your solution, see my answer for that 1 character you missed :D tl;dr provide `/` instead of empty string – spamove Nov 18 '22 at 10:12

2 Answers2

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

setting the base-path to / disables the discovery endpoint as per doc,

When the management context path is set to /, the discovery page is disabled to prevent the possibility of a clash with other mappings.

This allows you to set the path mapping for any single actuator endpoint to /. You might use it for health, you might as well use it for any other one.

Note this is only possible when base-path is /. For any other base-path, trying to do path-mapping to / for any of the endpoints will give you

IllegalStateException: Ambiguous mapping. Cannot map 'Actuator root web endpoint' method

instead.

spamove
  • 345
  • 3
  • 12
-1

After conversations with multiple engineers, it seems like my solution with redirect is the only possible one.

santik
  • 346
  • 1
  • 12