How to override actuator's default /health response status code based on its state:DOWN, UP, UNKNOWN so and so ? For example, if the health state is "UP", the response code should be 200. If DOWN: 400, unknown 300. Is there any work around to achieve this ?
Note: I do not want my own health endpoint. Instead, the existing one needs to be overriden .
In Spring boot 2.x these are the built in status and their defaults, which you can override to the relevant code you want.
management.endpoint.health.status.http-mapping.UP=200
management.endpoint.health.status.http-mapping.UNKNOWN=200
management.endpoint.health.status.http-mapping.DOWN=503
management.endpoint.health.status.http-mapping.OUT_OF_SERVICE=503
or a custom mapping
management.endpoint.health.status.http-mapping.DOWN=400
or in yaml,
management:
endpoint:
health:
status:
http-mapping:
UP: 200
UNKNOWN: 200
DOWN: 503
OUT_OF_SERVICE: 503
In Spring boot 1.x these are the properties with custom status applied,
endpoints.health.mapping.DOWN=400
endpoints.health.mapping.UP=200
endpoints.health.mapping.UNKNOWN=300
or in yaml,
endpoints:
health:
mapping:
UP: 200
DOWN: 400
UNKNOWN: 300