From 9f009e4445fce2192626bbf772109423f7f31782 Mon Sep 17 00:00:00 2001 From: Norio <59291150+norio-io@users.noreply.github.com> Date: Sun, 29 Mar 2020 18:07:38 +0900 Subject: [PATCH 1/2] Clarify loss of defaults when adding custom mapping See gh-20716 --- .../src/main/asciidoc/production-ready-features.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 21f7498e16..f29bdf6d68 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -760,6 +760,9 @@ For example, the following property maps `FATAL` to 503 (service unavailable): management.endpoint.health.status.http-mapping.fatal=503 ---- +WARNING: A custom status mapping replaces whole of the default status mappings. +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. + TIP: If you need more control, you can define your own `HttpCodeStatusMapper` bean. The following table shows the default status mappings for the built-in statuses: From 2de906caf705aa2ef6879ece6e46e99df735cbc6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 8 Jun 2020 17:33:26 +0100 Subject: [PATCH 2/2] Polish "Clarify loss of defaults when adding custom mapping" See gh-20716 --- .../main/asciidoc/production-ready-features.adoc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index f29bdf6d68..b4a722ee87 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -751,18 +751,21 @@ To configure the severity order, add the following property to your application management.endpoint.health.status.order=fatal,down,out-of-service,unknown,up ---- -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). +The HTTP status code in the response reflects the overall health status. +By default, `OUT_OF_SERVICE` and `DOWN` map to 503. +Any unmapped health statuses, including `UP`, map to 200. You might also want to register custom status mappings if you access the health endpoint over HTTP. -For example, the following property maps `FATAL` to 503 (service unavailable): +Configuring a custom mapping disables the defaults mappings for `DOWN` and `OUT_OF_SERVICE`. +If you want to retain the default mappings they must be configured explicitly alongside any custom mappings. +For example, the following property maps `FATAL` to 503 (service unavailable) and retains the default mappings for `DOWN` and `OUT_OF_SERVICE`: [source,properties,indent=0,configprops] ---- + management.endpoint.health.status.http-mapping.down=503 management.endpoint.health.status.http-mapping.fatal=503 + management.endpoint.health.status.http-mapping.out-of-service=503 ---- -WARNING: A custom status mapping replaces whole of the default status mappings. -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. - TIP: If you need more control, you can define your own `HttpCodeStatusMapper` bean. 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 management.endpoint.health.group.custom.roles=admin management.endpoint.health.group.custom.status.order=fatal,up management.endpoint.health.group.custom.status.http-mapping.fatal=500 - + management.endpoint.health.group.custom.status.http-mapping.out-of-service=500 ---- TIP: You can use `@Qualifier("groupname")` if you need to register custom `StatusAggregator` or `HttpCodeStatusMapper` beans for use with the group.