Skip to content

Commit 2de906c

Browse files
committed
Polish "Clarify loss of defaults when adding custom mapping"
See gh-20716
1 parent 9f009e4 commit 2de906c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,18 +751,21 @@ To configure the severity order, add the following property to your application
751751
management.endpoint.health.status.order=fatal,down,out-of-service,unknown,up
752752
----
753753

754-
The HTTP status code in the response reflects the overall health status (for example, `UP` maps to 200, while `OUT_OF_SERVICE` and `DOWN` map to 503).
754+
The HTTP status code in the response reflects the overall health status.
755+
By default, `OUT_OF_SERVICE` and `DOWN` map to 503.
756+
Any unmapped health statuses, including `UP`, map to 200.
755757
You might also want to register custom status mappings if you access the health endpoint over HTTP.
756-
For example, the following property maps `FATAL` to 503 (service unavailable):
758+
Configuring a custom mapping disables the defaults mappings for `DOWN` and `OUT_OF_SERVICE`.
759+
If you want to retain the default mappings they must be configured explicitly alongside any custom mappings.
760+
For example, the following property maps `FATAL` to 503 (service unavailable) and retains the default mappings for `DOWN` and `OUT_OF_SERVICE`:
757761

758762
[source,properties,indent=0,configprops]
759763
----
764+
management.endpoint.health.status.http-mapping.down=503
760765
management.endpoint.health.status.http-mapping.fatal=503
766+
management.endpoint.health.status.http-mapping.out-of-service=503
761767
----
762768

763-
WARNING: A custom status mapping replaces whole of the default status mappings.
764-
That means the above example has only one mapping to `FATAL` and any other statuses will return the http status 200 as `UNKNOWN` health status.
765-
766769
TIP: If you need more control, you can define your own `HttpCodeStatusMapper` bean.
767770

768771
The following table shows the default status mappings for the built-in statuses:
@@ -864,7 +867,7 @@ It's also possible to override the `show-details` and `roles` properties if requ
864867
management.endpoint.health.group.custom.roles=admin
865868
management.endpoint.health.group.custom.status.order=fatal,up
866869
management.endpoint.health.group.custom.status.http-mapping.fatal=500
867-
870+
management.endpoint.health.group.custom.status.http-mapping.out-of-service=500
868871
----
869872

870873
TIP: You can use `@Qualifier("groupname")` if you need to register custom `StatusAggregator` or `HttpCodeStatusMapper` beans for use with the group.

0 commit comments

Comments
 (0)