Commit dfe41cb2 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge pull request #10830 from Jay Bryant

* gh-10830:
  Wrap production-ready-features.adoc at 90 characters
  Make editorial changes to production-ready-features.adoc
parents cf4c4909 fbfaddbd
...@@ -4,22 +4,22 @@ ...@@ -4,22 +4,22 @@
[partintro] [partintro]
-- --
Spring Boot includes a number of additional features to help you monitor and manage your Spring Boot includes a number of additional features to help you monitor and manage your
application when it's pushed to production. You can choose to manage and monitor your application when you push it to production. You can choose to manage and monitor your
application using HTTP endpoints or with JMX. Auditing, health and metrics gathering can application by using HTTP endpoints or with JMX. Auditing, health, and metrics gathering
be automatically applied to your application. can also be automatically applied to your application.
Actuator HTTP endpoints are only available with a Spring MVC-based application. In Actuator HTTP endpoints are only available with a Spring MVC-based application. In
particular, it will not work with Jersey <<howto.adoc#howto-use-actuator-with-jersey, particular, it does not work with Jersey <<howto.adoc#howto-use-actuator-with-jersey,
unless you enable Spring MVC as well.>> unless you enable Spring MVC as well.>>
-- --
[[production-ready-enabling]] [[production-ready-enabling]]
== Enabling production-ready features == Enabling Production-ready Features
The {github-code}/spring-boot-project/spring-boot-actuator[`spring-boot-actuator`] module provides all of The {github-code}/spring-boot-project/spring-boot-actuator[`spring-boot-actuator`] module
Spring Boot's production-ready features. The simplest way to enable the features is to add provides all of Spring Boot's production-ready features. The simplest way to enable the
a dependency to the `spring-boot-starter-actuator` '`Starter`'. features is to add a dependency to the `spring-boot-starter-actuator` '`Starter`'.
.Definition of Actuator .Definition of Actuator
**** ****
...@@ -28,8 +28,7 @@ controlling something. Actuators can generate a large amount of motion from a sm ...@@ -28,8 +28,7 @@ controlling something. Actuators can generate a large amount of motion from a sm
change. change.
**** ****
To add the actuator to a Maven based project, add the following '`Starter`' To add the actuator to a Maven based project, add the following '`Starter`' dependency:
dependency:
[source,xml,indent=0] [source,xml,indent=0]
---- ----
...@@ -41,7 +40,7 @@ dependency: ...@@ -41,7 +40,7 @@ dependency:
</dependencies> </dependencies>
---- ----
For Gradle, use the declaration: For Gradle, use the following declaration:
[source,groovy,indent=0] [source,groovy,indent=0]
---- ----
...@@ -54,16 +53,16 @@ For Gradle, use the declaration: ...@@ -54,16 +53,16 @@ For Gradle, use the declaration:
[[production-ready-endpoints]] [[production-ready-endpoints]]
== Endpoints == Endpoints
Actuator endpoints allow you to monitor and interact with your application. Spring Boot Actuator endpoints let you monitor and interact with your application. Spring Boot
includes a number of built-in endpoints and you can also add your own. For example the includes a number of built-in endpoints and lets you add your own. For example, the
`health` endpoint provides basic application health information. `health` endpoint provides basic application health information.
The way that endpoints are exposed will depend on the type of technology that you choose. The way that endpoints are exposed depends on the type of technology that you choose. Most
Most applications choose HTTP monitoring, where the ID of the endpoint along with a prefix of applications choose HTTP monitoring, where the ID of the endpoint along with a prefix of
`/application` is mapped to a URL. For example, by default, the `health` endpoint will be mapped `/application` is mapped to a URL. For example, by default, the `health` endpoint is
to `/application/health`. mapped to `/application/health`.
The following technology agnostic endpoints are available: The following technology-agnostic endpoints are available:
[cols="2,5"] [cols="2,5"]
|=== |===
...@@ -107,24 +106,25 @@ The following technology agnostic endpoints are available: ...@@ -107,24 +106,25 @@ The following technology agnostic endpoints are available:
|Displays a collated list of all `@RequestMapping` paths. |Displays a collated list of all `@RequestMapping` paths.
|`sessions` |`sessions`
|Allows retrieval and deletion of user's sessions from Spring Session backed session |Allows retrieval and deletion of user sessions from a Spring Session-backed session
store. store.
|`shutdown` |`shutdown`
|Allows the application to be gracefully shutdown (not enabled by default). |Lets the application be gracefully shutdown (not enabled by default).
|`status` |`status`
|Show application status information (i.e. `health` status with no additional details). |Shows application status information (that is, `health` status with no additional
details).
|`threaddump` |`threaddump`
|Performs a thread dump. |Performs a thread dump.
|`trace` |`trace`
|Displays trace information (by default the last 100 HTTP requests). |Displays trace information (by default, the last 100 HTTP requests).
|=== |===
If your application is a web application (Spring MVC, Spring WebFlux, or Jersey), the If your application is a web application (Spring MVC, Spring WebFlux, or Jersey), you can
following additional endpoints can also be used: use the following additional endpoints:
[cols="2,5"] [cols="2,5"]
|=== |===
...@@ -144,17 +144,17 @@ content. ...@@ -144,17 +144,17 @@ content.
|=== |===
[[production-ready-endpoints-security]] [[production-ready-endpoints-security]]
=== Securing endpoints === Securing Endpoints
By default all HTTP endpoints are secured such that only users that have an `ACTUATOR` By default, all HTTP endpoints are secured such that only users that have an `ACTUATOR`
role may access them. Security is enforced using the standard role may access them. Security is enforced by using the standard
`HttpServletRequest.isUserInRole` method. `HttpServletRequest.isUserInRole` method.
TIP: Use the `management.security.roles` property if you want something different to TIP: If you want to use something other than `ACTUATOR` as the role, set the
`ACTUATOR`. `management.security.roles` property to the value you want to use.
If you are deploying applications behind a firewall, you may prefer that all your actuator If you deploy applications behind a firewall, you may prefer that all your actuator
endpoints can be accessed without requiring authentication. You can do this by changing endpoints can be accessed without requiring authentication. You can do so by changing the
the `management.security.enabled` property: `management.security.enabled` property, as follows:
.application.properties .application.properties
[source,properties,indent=0] [source,properties,indent=0]
...@@ -162,21 +162,21 @@ the `management.security.enabled` property: ...@@ -162,21 +162,21 @@ the `management.security.enabled` property:
management.security.enabled=false management.security.enabled=false
---- ----
NOTE: By default, actuator endpoints are exposed on the same port that serves regular CAUTION: By default, actuator endpoints are exposed on the same port that serves regular
HTTP traffic. Take care not to accidentally expose sensitive information if you change HTTP traffic. Take care not to accidentally expose sensitive information if you change
the `management.security.enabled` property. the `management.security.enabled` property.
If you're deploying applications publicly, you may want to add '`Spring Security`' to If you deploy applications publicly, you may want to add '`Spring Security`' to handle
handle user authentication. When '`Spring Security`' is added, by default '`basic`' user authentication. When '`Spring Security`' is added, by default, '`basic`'
authentication will be used with the username `user` and a generated password (which is authentication is used. The username is`user` and the password is a random generated
printed on the console when the application starts). password (which is printed on the console when the application starts).
TIP: Generated passwords are logged as the application starts. Search for '`Using default TIP: Generated passwords are logged as the application starts. To find the password in the
security password`'. console, search for '`Using default security password`'.
You can use Spring properties to change the username and password and to change the You can use Spring properties to change the username and password and to change the
security role(s) required to access the endpoints. For example, you might set the following security role(s) required to access the endpoints. For example, you might set the
in your `application.properties`: following properties in your `application.properties`:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -187,27 +187,27 @@ in your `application.properties`: ...@@ -187,27 +187,27 @@ in your `application.properties`:
If your application has custom security configuration and you want all your actuator If your application has custom security configuration and you want all your actuator
endpoints to be accessible without authentication, you need to explicitly configure that endpoints to be accessible without authentication, you need to explicitly configure that
in your security configuration. Along with that, you need to change the in your security configuration. Also, you need to change the `management.security.enabled`
`management.security.enabled` property to `false`. property to `false`.
If your custom security configuration secures your actuator endpoints, you also need to If your custom security configuration secures your actuator endpoints, you also need to
ensure that the authenticated user has the roles specified under ensure that the authenticated user has the roles specified under
`management.security.roles`. `management.security.roles`.
TIP: If you don't have a use case for exposing basic health information to unauthenticated TIP: If you do not have a use case for exposing basic health information to
users, and you have secured the actuator endpoints with custom security, you can set unauthenticated users and you have secured the actuator endpoints with custom security,
`management.security.enabled` to `false`. This will inform Spring Boot to skip the you can set `management.security.enabled` to `false`. This tells Spring Boot to skip the
additional role check. additional role check.
[[production-ready-customizing-endpoints]] [[production-ready-customizing-endpoints]]
=== Customizing endpoints === Customizing Endpoints
Endpoints can be customized using Spring properties. You can change if an endpoint is Endpoints can be customized by using Spring properties. You can change whether an endpoint
`enabled` and its `id`. is `enabled` and its `id`.
For example, here is an `application.properties` that changes the id of the `beans` For example, the following `application.properties` changes the id of the `beans` endpoint
endpoint and also enables `shutdown`. and also enables `shutdown`:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -218,9 +218,9 @@ endpoint and also enables `shutdown`. ...@@ -218,9 +218,9 @@ endpoint and also enables `shutdown`.
NOTE: The prefix ‟`endpoints` + `.` + `name`” is used to uniquely identify the endpoint NOTE: The prefix ‟`endpoints` + `.` + `name`” is used to uniquely identify the endpoint
that is being configured. that is being configured.
By default, all endpoints except for `shutdown` are enabled. If you prefer to By default, all endpoints except for `shutdown` are enabled. If you prefer to specifically
specifically "`opt-in`" endpoint enablement you can use the `endpoints.default.enabled` "`opt-in`" endpoint enablement, you can use the `endpoints.default.enabled` property. For
property. For example, the following will disable _all_ endpoints except for `info`: example, the following settings disables _all_ endpoints except for `info`:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -231,29 +231,28 @@ property. For example, the following will disable _all_ endpoints except for `in ...@@ -231,29 +231,28 @@ property. For example, the following will disable _all_ endpoints except for `in
[[production-ready-endpoint-hypermedia]] [[production-ready-endpoint-hypermedia]]
=== Hypermedia for actuator web endpoints === Hypermedia for Actuator Web Endpoints
A "`discovery page`" is added with links to all the endpoints. The "`discovery page`" is A "`discovery page`" is added with links to all the endpoints. The "`discovery page`" is
available on `/application` by default. available on `/application` by default.
When a custom management context path is configured, the "`discovery page`" will When a custom management context path is configured, the "`discovery page`" automatically
automatically move from `/application` to the root of the management context. For example, moves from `/application` to the root of the management context. For example, if the
if the management context path is `/management` then the discovery page will be available management context path is `/management`, then the discovery page is available from
from `/management`. When the management context path is set to `/` the discovery page `/management`. When the management context path is set to `/`, the discovery page is
is disabled to prevent the possibility of a clash with other mappings. disabled to prevent the possibility of a clash with other mappings.
[[production-ready-endpoint-cors]] [[production-ready-endpoint-cors]]
=== CORS support === CORS Support
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-origin resource sharing] http://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-origin resource sharing]
(CORS) is a http://www.w3.org/TR/cors/[W3C specification] that allows you to specify in a (CORS) is a http://www.w3.org/TR/cors/[W3C specification] that allows you to specify in a
flexible way what kind of cross domain requests are authorized. If you are using Spring flexible way what kind of cross domain requests are authorized. If you use Spring MVC or
MVC or Spring WebFlux, Actuator's web endpoints can be configured to support such Spring WebFlux, Actuator's web endpoints can be configured to support such scenarios.
scenarios.
CORS support is disabled by default and is only enabled once the CORS support is disabled by default and is only enabled once the
`management.endpoints.cors.allowed-origins` property has been set. The configuration below `management.endpoints.cors.allowed-origins` property has been set. The following
permits `GET` and `POST` calls from the `example.com` domain: configuration permits `GET` and `POST` calls from the `example.com` domain:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -261,39 +260,38 @@ permits `GET` and `POST` calls from the `example.com` domain: ...@@ -261,39 +260,38 @@ permits `GET` and `POST` calls from the `example.com` domain:
management.endpoints.cors.allowed-methods=GET,POST management.endpoints.cors.allowed-methods=GET,POST
---- ----
TIP: Check {sc-spring-boot-actuator-autoconfigure}/endpoint/web/servlet/CorsEndpointProperties.{sc-ext}[CorsEndpointProperties] TIP: See {sc-spring-boot-actuator-autoconfigure}/endpoint/web/servlet/CorsEndpointProperties.{sc-ext}[CorsEndpointProperties] for a complete list of options.
for a complete list of options.
[[production-ready-customizing-endpoints-programmatically]] [[production-ready-customizing-endpoints-programmatically]]
=== Adding custom endpoints === Adding Custom Endpoints
If you add a `@Bean` annotated with `@Endpoint`, any methods annotated with If you add a `@Bean` annotated with `@Endpoint`, any methods annotated with
`@ReadOperation` or `@WriteOperation` will automatically be exposed over JMX and, in a web `@ReadOperation` or `@WriteOperation` are automatically exposed over JMX and, in a web
application, over HTTP as well. application, over HTTP as well.
TIP: If you are doing this as a library feature consider adding a configuration class TIP: If you do this as a library feature, consider adding a configuration class annotated
annotated with `@ManagementContextConfiguration` to `/META-INF/spring.factories` under the with `@ManagementContextConfiguration` to `/META-INF/spring.factories` under the key,
key `org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration`. If `org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration`. If you do
you do that then the endpoint will move to a child context with all the other web so and if your users ask for a separate management port or address, the endpoint moves to
endpoints endpoints if your users ask for a separate management port or address. a child context with all the other web endpoints.
[[production-ready-health]] [[production-ready-health]]
=== Health information === Health Information
Health information can be used to check the status of your running application. It is You can use health information to check the status of your running application. It is
often used by monitoring software to alert someone if a production system goes down. often used by monitoring software to alert someone when a production system goes down. The
The default information exposed by the `health` endpoint depends on how it is accessed. default information exposed by the `health` endpoint depends on how it is accessed. For an
For an unauthenticated connection in a secure application a simple '`status`' message is unauthenticated connection in a secure application, a simple '`status`' message is
returned, and for an authenticated connection additional details are also displayed (see returned. For an authenticated connection, additional details are also displayed. (See
<<production-ready-health-access-restrictions>> for HTTP details). <<production-ready-health-access-restrictions>> for HTTP details.)
Health information is collected from all Health information is collected from all
{sc-spring-boot-actuator}/health/HealthIndicator.{sc-ext}[`HealthIndicator`] beans defined {sc-spring-boot-actuator}/health/HealthIndicator.{sc-ext}[`HealthIndicator`] beans defined
in your `ApplicationContext`. Spring Boot includes a number of auto-configured in your `ApplicationContext`. Spring Boot includes a number of auto-configured
`HealthIndicators` and you can also write your own. By default, the final system state is `HealthIndicators`, and you can also write your own. By default, the final system state is
derived by the `HealthAggregator` which sorts the statuses from each `HealthIndicator` derived by the `HealthAggregator`, which sorts the statuses from each `HealthIndicator`
based on an ordered list of statuses. The first status in the sorted list is used as the based on an ordered list of statuses. The first status in the sorted list is used as the
overall health status. If no `HealthIndicator` returns a status that is known to the overall health status. If no `HealthIndicator` returns a status that is known to the
`HealthAggregator`, an `UNKNOWN` status is used. `HealthAggregator`, an `UNKNOWN` status is used.
...@@ -342,12 +340,13 @@ TIP: It is possible to disable them all using the `management.health.defaults.en ...@@ -342,12 +340,13 @@ TIP: It is possible to disable them all using the `management.health.defaults.en
property. property.
==== Writing custom HealthIndicators ==== Writing Custom HealthIndicators
To provide custom health information you can register Spring beans that implement the To provide custom health information, you can register Spring beans that implement the
{sc-spring-boot-actuator}/health/HealthIndicator.{sc-ext}[`HealthIndicator`] interface. {sc-spring-boot-actuator}/health/HealthIndicator.{sc-ext}[`HealthIndicator`] interface.
You need to provide an implementation of the `health()` method and return a `Health` You need to provide an implementation of the `health()` method and return a `Health`
response. The `Health` response should include a status and can optionally include response. The `Health` response should include a status and can optionally include
additional details to be displayed. additional details to be displayed. The following code shows a sample `HealthIndicator`
implementation:
[source,java,indent=0] [source,java,indent=0]
---- ----
...@@ -371,18 +370,18 @@ additional details to be displayed. ...@@ -371,18 +370,18 @@ additional details to be displayed.
---- ----
NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the
`HealthIndicator` suffix if it exists. In the example above, the health information will `HealthIndicator` suffix, if it exists. In the preceding example, the health information
be available in an entry named `my`. is available in an entry named `my`.
In addition to Spring Boot's predefined {sc-spring-boot-actuator}/health/Status.{sc-ext}[`Status`] In addition to Spring Boot's predefined {sc-spring-boot-actuator}/health/Status.{sc-ext}[`Status`]
types, it is also possible for `Health` to return a custom `Status` that represents a types, it is also possible for `Health` to return a custom `Status` that represents a new
new system state. In such cases a custom implementation of the system state. In such cases, a custom implementation of the
{sc-spring-boot-actuator}/health/HealthAggregator.{sc-ext}[`HealthAggregator`] {sc-spring-boot-actuator}/health/HealthAggregator.{sc-ext}[`HealthAggregator`] interface
interface also needs to be provided, or the default implementation has to be configured also needs to be provided, or the default implementation has to be configured by using the
using the `management.health.status.order` configuration property. `management.health.status.order` configuration property.
For example, assuming a new `Status` with code `FATAL` is being used in one of your For example, assume a new `Status` with code `FATAL` is being used in one of your
`HealthIndicator` implementations. To configure the severity order add the following `HealthIndicator` implementations. To configure the severity order, add the following
to your application properties: to your application properties:
[source,properties,indent=0] [source,properties,indent=0]
...@@ -390,19 +389,19 @@ to your application properties: ...@@ -390,19 +389,19 @@ to your application properties:
management.health.status.order=FATAL, DOWN, OUT_OF_SERVICE, UNKNOWN, UP management.health.status.order=FATAL, DOWN, OUT_OF_SERVICE, UNKNOWN, UP
---- ----
The HTTP status code in the response reflects the overall health status (e.g. `UP` The HTTP status code in the response reflects the overall health status (for example, `UP`
maps to 200, `OUT_OF_SERVICE` or `DOWN` to 503). You might also want to register custom maps to 200, while `OUT_OF_SERVICE` and `DOWN` map to 503). You might also want to
status mappings if you access the health endpoint over HTTP. For example, the following register custom status mappings if you access the health endpoint over HTTP. For example,
maps `FATAL` to 503 (service unavailable). the following property maps `FATAL` to 503 (service unavailable):
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.health.status.http-mapping.FATAL=503 management.health.status.http-mapping.FATAL=503
---- ----
TIP: If you need more control you can define your own `HealthStatusHttpMapper` bean. TIP: If you need more control, you can define your own `HealthStatusHttpMapper` bean.
The default status mappings for the built-in statuses are: The following table shows the default status mappings for the built-in statuses:
[cols="1,3"] [cols="1,3"]
|=== |===
...@@ -424,16 +423,16 @@ The default status mappings for the built-in statuses are: ...@@ -424,16 +423,16 @@ The default status mappings for the built-in statuses are:
[[production-ready-application-info]] [[production-ready-application-info]]
=== Application information === Application Information
Application information exposes various information collected from all Application information exposes various information collected from all
{sc-spring-boot-actuator}/info/InfoContributor.{sc-ext}[`InfoContributor`] beans defined {sc-spring-boot-actuator}/info/InfoContributor.{sc-ext}[`InfoContributor`] beans defined
in your `ApplicationContext`. Spring Boot includes a number of auto-configured in your `ApplicationContext`. Spring Boot includes a number of auto-configured
`InfoContributors` and you can also write your own. `InfoContributors`, and you can write your own.
[[production-ready-application-info-autoconfigure]] [[production-ready-application-info-autoconfigure]]
==== Auto-configured InfoContributors ==== Auto-configured InfoContributors
The following `InfoContributors` are auto-configured by Spring Boot when appropriate: The following `InfoContributors` are auto-configured by Spring Boot, when appropriate:
[cols="1,4"] [cols="1,4"]
|=== |===
...@@ -453,10 +452,10 @@ TIP: It is possible to disable them all using the `management.info.defaults.enab ...@@ -453,10 +452,10 @@ TIP: It is possible to disable them all using the `management.info.defaults.enab
property. property.
[[production-ready-application-info-env]] [[production-ready-application-info-env]]
==== Custom application info information ==== Custom Application Information
You can customize the data exposed by the `info` endpoint by setting `+info.*+` Spring You can customize the data exposed by the `info` endpoint by setting `+info.*+` Spring
properties. All `Environment` properties under the info key will be automatically properties. All `Environment` properties under the info key are automatically exposed. For
exposed. For example, you could add the following to your `application.properties`: example, you could add the following settings to your `application.properties` file:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -467,10 +466,10 @@ exposed. For example, you could add the following to your `application.propertie ...@@ -467,10 +466,10 @@ exposed. For example, you could add the following to your `application.propertie
[TIP] [TIP]
==== ====
Rather than hardcoding those values you could also Rather than hardcoding those values, you could also
<<howto.adoc#howto-automatic-expansion,expand info properties at build time>>. <<howto.adoc#howto-automatic-expansion,expand info properties at build time>>.
Assuming you are using Maven, you could rewrite the example above as follows: Assuming you use Maven, you could rewrite the preceding example as follows:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -483,18 +482,18 @@ Assuming you are using Maven, you could rewrite the example above as follows: ...@@ -483,18 +482,18 @@ Assuming you are using Maven, you could rewrite the example above as follows:
[[production-ready-application-info-git]] [[production-ready-application-info-git]]
==== Git commit information ==== Git Commit Information
Another useful feature of the `info` endpoint is its ability to publish information Another useful feature of the `info` endpoint is its ability to publish information about
about the state of your `git` source code repository when the project was built. If a the state of your `git` source code repository when the project was built. If a
`GitProperties` bean is available, the `git.branch`, `git.commit.id` and `GitProperties` bean is available, the `git.branch`, `git.commit.id` and `git.commit.time`
`git.commit.time` properties will be exposed. properties are exposed.
TIP: A `GitProperties` bean is auto-configured if a `git.properties` file is available TIP: A `GitProperties` bean is auto-configured if a `git.properties` file is available at
at the root of the classpath. See the root of the classpath. See
<<howto.adoc#howto-git-info,Generate git information>> for more details. "<<howto.adoc#howto-git-info,Generate git information>>" for more details.
If you want to display the full git information (i.e. the full content of If you want to display the full git information (that is, the full content of
`git.properties`), use the `management.info.git.mode` property: `git.properties`), use the `management.info.git.mode` property, as follows:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -504,21 +503,21 @@ If you want to display the full git information (i.e. the full content of ...@@ -504,21 +503,21 @@ If you want to display the full git information (i.e. the full content of
[[production-ready-application-info-build]] [[production-ready-application-info-build]]
==== Build information ==== Build Information
The `info` endpoint can also publish information about your build if a `BuildProperties` If a `BuildProperties` bean is available, the `info` endpoint can also publish information
bean is available. This happens if a `META-INF/build-info.properties` file is available about your build. This happens if a `META-INF/build-info.properties` file is available in
in the classpath. the classpath.
TIP: The Maven and Gradle plugins can both generate that file, see TIP: The Maven and Gradle plugins can both generate that file. See
<<howto.adoc#howto-build-info,Generate build information>> for more details. "<<howto.adoc#howto-build-info,Generate build information>>" for more details.
[[production-ready-application-info-custom]] [[production-ready-application-info-custom]]
==== Writing custom InfoContributors ==== Writing Custom InfoContributors
To provide custom application information you can register Spring beans that implement To provide custom application information, you can register Spring beans that implement
the {sc-spring-boot-actuator}/info/InfoContributor.{sc-ext}[`InfoContributor`] interface. the {sc-spring-boot-actuator}/info/InfoContributor.{sc-ext}[`InfoContributor`] interface.
The example below contributes an `example` entry with a single value: The following example contributes an `example` entry with a single value:
[source,java,indent=0] [source,java,indent=0]
---- ----
...@@ -540,7 +539,7 @@ The example below contributes an `example` entry with a single value: ...@@ -540,7 +539,7 @@ The example below contributes an `example` entry with a single value:
} }
---- ----
If you hit the `info` endpoint you should see a response that contains the following If you reach the `info` endpoint, you should see a response that contains the following
additional entry: additional entry:
[source,json,indent=0] [source,json,indent=0]
...@@ -555,69 +554,72 @@ additional entry: ...@@ -555,69 +554,72 @@ additional entry:
[[production-ready-monitoring]] [[production-ready-monitoring]]
== Monitoring and management over HTTP == Monitoring and Management over HTTP
If you are developing a Spring MVC application, Spring Boot Actuator will auto-configure If you are developing a Spring MVC application, Spring Boot Actuator auto-configures all
all enabled endpoints to be exposed over HTTP. The default convention is to use the enabled endpoints to be exposed over HTTP. The default convention is to use the `id` of
`id` of the endpoint with a prefix of `/application` as the URL path. For example, `health` the endpoint with a prefix of `/application` as the URL path. For example, `health` is
is exposed as `/application/health`. exposed as `/application/health`.
[[production-ready-customizing-management-server-context-path]] [[production-ready-customizing-management-server-context-path]]
=== Customizing the management endpoint paths === Customizing the Management Endpoint Paths
Sometimes it is useful to customize the prefix for the management endpoints. Sometimes, it is useful to customize the prefix for the management endpoints. For example,
For example, your application might already use `/application` for another purpose. your application might already use `/application` for another purpose. You can use the
You can use the `management.endpoints.web.base-path` property to change the prefix for your `management.endpoints.web.base-path` property to change the prefix for your management
management endpoint: endpoint, as shown in the following example:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.endpoints.web.base-path=/manage management.endpoints.web.base-path=/manage
---- ----
The `application.properties` example above will change the endpoint from `/application/{id}` to The preceding `application.properties` example changes the endpoint from
`/manage/{id}` (e.g. `/manage/info`). `/application/{id}` to `/manage/{id}` (e.g. `/manage/info`).
NOTE: Unless the management port has been configured to NOTE: Unless the management port has been configured to
<<production-ready-customizing-management-server-port,expose endpoints using a different <<production-ready-customizing-management-server-port,expose endpoints using a different
HTTP port>>, `management.endpoints.web.base-path` is relative to `server.context-path`. If `management.server.port` HTTP port>>, `management.endpoints.web.base-path` is relative to `server.context-path`.
is configured, `management.endpoints.web.base-path`, is relative to `management.server.servlet.context-path`. If `management.server.port` is configured, `management.endpoints.web.base-path` is
relative to `management.server.servlet.context-path`.
[[production-ready-customizing-management-server-port]] [[production-ready-customizing-management-server-port]]
=== Customizing the management server port === Customizing the Management Server Port
Exposing management endpoints using the default HTTP port is a sensible choice for cloud Exposing management endpoints by using the default HTTP port is a sensible choice for
based deployments. If, however, your application runs inside your own data center you cloud based deployments. If, however, your application runs inside your own data center,
may prefer to expose endpoints using a different HTTP port. you may prefer to expose endpoints by using a different HTTP port.
The `management.server.port` property can be used to change the HTTP port. You can set the `management.server.port` property to change the HTTP port, as shown in the
following example:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.server.port=8081 management.server.port=8081
---- ----
Since your management port is often protected by a firewall, and not exposed to the public Since your management port is often protected by a firewall and not exposed to the public,
you might not need security on the management endpoints, even if your main application is you might not need security on the management endpoints, even if your main application is
secure. In that case you will have Spring Security on the classpath, and you can disable secure. In that case, you should have Spring Security on the classpath, and you can
management security like this: disable management security as follows:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.security.enabled=false management.security.enabled=false
---- ----
(If you don't have Spring Security on the classpath then there is no need to explicitly (If you do not have Spring Security on the classpath, there is no need to explicitly
disable the management security in this way, and it might even break the application.) disable the management security in this way. Doing so might even break the application.)
[[production-ready-management-specific-ssl]] [[production-ready-management-specific-ssl]]
=== Configuring management-specific SSL === Configuring Management-specific SSL
When configured to use a custom port, the management server can also be configured with When configured to use a custom port, the management server can also be configured with
its own SSL using the various `management.server.ssl.*` properties. For example, this allows a its own SSL by using the various `management.server.ssl.*` properties. For example, doing
management server to be available via HTTP while the main application uses HTTPS: so lets a management server be available via HTTP while the main application uses HTTPS,
as shown in the following property settings:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -630,7 +632,7 @@ management server to be available via HTTP while the main application uses HTTPS ...@@ -630,7 +632,7 @@ management server to be available via HTTP while the main application uses HTTPS
---- ----
Alternatively, both the main server and the management server can use SSL but with Alternatively, both the main server and the management server can use SSL but with
different key stores: different key stores, as follows:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -647,16 +649,16 @@ different key stores: ...@@ -647,16 +649,16 @@ different key stores:
[[production-ready-customizing-management-server-address]] [[production-ready-customizing-management-server-address]]
=== Customizing the management server address === Customizing the Management Server Address
You can customize the address that the management endpoints are available on by You can customize the address that the management endpoints are available on by setting
setting the `management.server.address` property. This can be useful if you want to the `management.server.address` property. Doing so can be useful if you want to listen
listen only on an internal or ops-facing network, or to only listen for connections from only on an internal or ops-facing network or to listen only for connections from
`localhost`. `localhost`.
NOTE: You can only listen on a different address if the port is different to the NOTE: You can only listen on a different address if the port is different from the main
main server port. server port.
Here is an example `application.properties` that will not allow remote management The following example `application.properties` does not allow remote management
connections: connections:
[source,properties,indent=0] [source,properties,indent=0]
...@@ -668,8 +670,9 @@ connections: ...@@ -668,8 +670,9 @@ connections:
[[production-ready-disabling-http-endpoints]] [[production-ready-disabling-http-endpoints]]
=== Disabling HTTP endpoints === Disabling HTTP Endpoints
If you don't want to expose endpoints over HTTP you can set the management port to `-1`: If you do not want to expose endpoints over HTTP, you can set the management port to
`-1`, as shown in the following example:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -678,14 +681,13 @@ If you don't want to expose endpoints over HTTP you can set the management port ...@@ -678,14 +681,13 @@ If you don't want to expose endpoints over HTTP you can set the management port
[[production-ready-health-access-restrictions]] [[production-ready-health-access-restrictions]]
=== HTTP health endpoint format and access restrictions === HTTP Health Endpoint Format and Access Restrictions
The information exposed by the health endpoint varies depending on whether or not it's The information exposed by the health endpoint varies, depending on whether it is accessed
accessed anonymously, and whether or not the enclosing application is secure. anonymously and whether the enclosing application is secure. By default, when accessed
By default, when accessed anonymously in a secure application, any details about the anonymously in a secure application, any details about the server's health are hidden and
server's health are hidden and the endpoint will simply indicate whether or not the server the endpoint indicates whether the server is up or down.
is up or down.
Sample summarized HTTP response (default for anonymous request): The following example shows a summarized HTTP response (default for anonymous request):
[source,indent=0] [source,indent=0]
---- ----
...@@ -698,7 +700,8 @@ Sample summarized HTTP response (default for anonymous request): ...@@ -698,7 +700,8 @@ Sample summarized HTTP response (default for anonymous request):
{"status":"UP"} {"status":"UP"}
---- ----
Sample summarized HTTP response for status "DOWN" (notice the 503 status code): The following example shows a summarized HTTP response for status "DOWN" (notice the 503
status code):
[source,indent=0] [source,indent=0]
---- ----
...@@ -711,7 +714,7 @@ Sample summarized HTTP response for status "DOWN" (notice the 503 status code): ...@@ -711,7 +714,7 @@ Sample summarized HTTP response for status "DOWN" (notice the 503 status code):
{"status":"DOWN"} {"status":"DOWN"}
---- ----
Sample detailed HTTP response: The following example shows a detailed HTTP response:
[source,indent=0] [source,indent=0]
---- ----
...@@ -740,24 +743,25 @@ Sample detailed HTTP response: ...@@ -740,24 +743,25 @@ Sample detailed HTTP response:
[[production-ready-jmx]] [[production-ready-jmx]]
== Monitoring and management over JMX == Monitoring and Management over JMX
Java Management Extensions (JMX) provide a standard mechanism to monitor and manage Java Management Extensions (JMX) provide a standard mechanism to monitor and manage
applications. By default Spring Boot will expose management endpoints as JMX MBeans applications. By default, Spring Boot exposes management endpoints as JMX MBeans under the
under the `org.springframework.boot` domain. `org.springframework.boot` domain.
[[production-ready-custom-mbean-names]] [[production-ready-custom-mbean-names]]
=== Customizing MBean names === Customizing MBean Names
The name of the MBean is usually generated from the `id` of the endpoint. For example The name of the MBean is usually generated from the `id` of the endpoint. For example the
the `health` endpoint is exposed as `org.springframework.boot:type=Endpoint,name=Health`. `health` endpoint is exposed as `org.springframework.boot:type=Endpoint,name=Health`.
If your application contains more than one Spring `ApplicationContext` you may find that If your application contains more than one Spring `ApplicationContext`, you may find that
names clash. To solve this problem you can set the `management.endpoints.jmx.unique-names` names clash. To solve this problem, you can set the
property to `true` so that MBean names are always unique. `management.endpoints.jmx.unique-names` property to `true` so that MBean names are always
unique.
You can also customize the JMX domain under which endpoints are exposed. Here is an You can also customize the JMX domain under which endpoints are exposed. The following
example `application.properties`: settings show an example of doing so in `application.properties`:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -768,9 +772,9 @@ example `application.properties`: ...@@ -768,9 +772,9 @@ example `application.properties`:
[[production-ready-disable-jmx-endpoints]] [[production-ready-disable-jmx-endpoints]]
=== Disabling JMX endpoints === Disabling JMX Endpoints
If you don't want to expose endpoints over JMX you can set the `endpoints.default.jmx.enabled` If you do not want to expose endpoints over JMX, you can set the
property to `false`: `endpoints.default.jmx.enabled` property to `false`, as shown in the following example:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -781,9 +785,9 @@ property to `false`: ...@@ -781,9 +785,9 @@ property to `false`:
[[production-ready-jolokia]] [[production-ready-jolokia]]
=== Using Jolokia for JMX over HTTP === Using Jolokia for JMX over HTTP
Jolokia is a JMX-HTTP bridge giving an alternative method of accessing JMX beans. To Jolokia is a JMX-HTTP bridge that provides an alternative method of accessing JMX beans.
use Jolokia, simply include a dependency to `org.jolokia:jolokia-core`. For example, To use Jolokia, include a dependency to `org.jolokia:jolokia-core`. For example, with
using Maven you would add the following: Maven, you would add the following dependency:
[source,xml,indent=0] [source,xml,indent=0]
---- ----
...@@ -793,15 +797,16 @@ using Maven you would add the following: ...@@ -793,15 +797,16 @@ using Maven you would add the following:
</dependency> </dependency>
---- ----
Jolokia can then be accessed using `/application/jolokia` on your management HTTP server. Jolokia can then be accessed by using `/application/jolokia` on your management HTTP
server.
[[production-ready-customizing-jolokia]] [[production-ready-customizing-jolokia]]
==== Customizing Jolokia ==== Customizing Jolokia
Jolokia has a number of settings that you would traditionally configure using servlet Jolokia has a number of settings that you would traditionally configure using servlet
parameters. With Spring Boot you can use your `application.properties`, simply prefix the parameters. With Spring Boot, you can use your `application.properties`. Prefix the
parameter with `management.jolokia.config.`: parameter with `management.jolokia.config.`, as shown in the following example:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -812,8 +817,8 @@ parameter with `management.jolokia.config.`: ...@@ -812,8 +817,8 @@ parameter with `management.jolokia.config.`:
[[production-ready-disabling-jolokia]] [[production-ready-disabling-jolokia]]
==== Disabling Jolokia ==== Disabling Jolokia
If you are using Jolokia but you don't want Spring Boot to configure it, simply set the If you use Jolokia but do not want Spring Boot to configure it, set the
`management.jolokia.enabled` property to `false`: `management.jolokia.enabled` property to `false`, as follows:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
...@@ -826,8 +831,9 @@ If you are using Jolokia but you don't want Spring Boot to configure it, simply ...@@ -826,8 +831,9 @@ If you are using Jolokia but you don't want Spring Boot to configure it, simply
== Loggers == Loggers
Spring Boot Actuator includes the ability to view and configure the log levels of your Spring Boot Actuator includes the ability to view and configure the log levels of your
application at runtime. You can view either the entire list or an individual logger's application at runtime. You can view either the entire list or an individual logger's
configuration which is made up of both the explicitly configured logging level as well as configuration, which is made up of both the explicitly configured logging level as well as
the effective logging level given to it by the logging framework. These levels can be: the effective logging level given to it by the logging framework. These levels can be one
of:
* `TRACE` * `TRACE`
* `DEBUG` * `DEBUG`
...@@ -838,13 +844,14 @@ the effective logging level given to it by the logging framework. These levels ...@@ -838,13 +844,14 @@ the effective logging level given to it by the logging framework. These levels
* `OFF` * `OFF`
* `null` * `null`
with `null` indicating that there is no explicit configuration. `null` indicates that there is no explicit configuration.
[[production-ready-logger-configuration]] [[production-ready-logger-configuration]]
=== Configure a Logger === Configure a Logger
In order to configure a given logger, you `POST` a partial entity to the resource's URI: In order to configure a given logger, you `POST` a partial entity to the resource's URI,
as shown in the following example:
[source,json,indent=0] [source,json,indent=0]
---- ----
...@@ -853,8 +860,8 @@ In order to configure a given logger, you `POST` a partial entity to the resourc ...@@ -853,8 +860,8 @@ In order to configure a given logger, you `POST` a partial entity to the resourc
} }
---- ----
TIP: You can also pass a `null` `configuredLevel` to "reset" the specific level of the TIP: To "reset" the specific level of the logger (and use the default configuration
logger (and use the default configuration instead). instead), you can pass a value of `null` as the `configuredLevel`.
...@@ -872,91 +879,91 @@ monitoring systems: ...@@ -872,91 +879,91 @@ monitoring systems:
- https://prometheus.io[Prometheus] - https://prometheus.io[Prometheus]
Micrometer provides a separate module for each supported monitoring system. Depending on Micrometer provides a separate module for each supported monitoring system. Depending on
one (or more) of these modules is sufficient to get started with Micrometer in your one (or more) of these modules is sufficient to get started with Micrometer in your Spring
Spring Boot application. To learn more about Micrometer's capabilities, please refer to Boot application. To learn more about Micrometer's capabilities, please refer to its
its https://micrometer.io/docs[reference documentation]. https://micrometer.io/docs[reference documentation].
[[production-ready-metrics-spring-mvc]] [[production-ready-metrics-spring-mvc]]
=== Spring MVC metrics === Spring MVC Metrics
Auto-configuration will enable the instrumentation of requests handled by Spring MVC. Auto-configuration enables the instrumentation of requests handled by Spring MVC. When
When `spring.metrics.web.server.auto-time-requests` is `true`, this instrumentation will `spring.metrics.web.server.auto-time-requests` is `true`, this instrumentation occurs for
occur for all requests. Alternatively, when set to `false`, instrumentation can be enabled all requests. Alternatively, when set to `false`, you can enable instrumentation by adding
by adding `@Timed` to a request-handling method. `@Timed` to a request-handling method.
Metrics will, by default, be generated with the name `http.server.requests`. The name By default, metrics are generated with the name, `http.server.requests`. The name can be
can be customized using the `spring.metrics.web.server.requests-metric-name` property. customized by setting the `spring.metrics.web.server.requests-metrics-name` property.
[[production-ready-metrics-spring-mvc-tags]] [[production-ready-metrics-spring-mvc-tags]]
==== Spring MVC metric tags ==== Spring MVC Metric Tags
Spring MVC-related metrics will, by default, be tagged with the following: By default, Spring MVC-related metrics are tagged with the following information:
- Request's method, - The request's method.
- Request's URI (templated if possible) - The request's URI (templated if possible).
- Simple class name of any exception that was thrown while handling the request - The simple class name of any exception that was thrown while handling the request.
- Response's status - The response's status.
To customize the tags, provide a `@Bean` that implements `WebMvcTagsProvider`. To customize the tags, provide a `@Bean` that implements `WebMvcTagsProvider`.
[[production-ready-metrics-web-flux]] [[production-ready-metrics-web-flux]]
=== WebFlux metrics === WebFlux Metrics
Auto-configuration will enable the instrumentation of all requests handled by WebFlux Auto-configuration enables the instrumentation of all requests handled by WebFlux
controllers. A helper class, `RouterFunctionMetrics`, is also provided that can be controllers. You can also use a helper class, `RouterFunctionMetrics`, to instrument
used to instrument applications using WebFlux's functional programming model. applications that use WebFlux's functional programming model.
Metrics will, by default, be generated with the name `http.server.requests`. The name By default, metrics are generated with the name `http.server.requests`. You can customize
can be customized using the `spring.metrics.web.server.requests-metric-name` property. the name by setting the `spring.metrics.web.server.requests-metrics-name` property.
[[production-ready-metrics-web-flux-tags]] [[production-ready-metrics-web-flux-tags]]
==== WebFlux metric tags ==== WebFlux Metric Tags
WebFlux-related metrics for the annotation-based programming model will, by default, By default, WebFlux-related metrics for the annotation-based programming model are tagged
be tagged with the following: with the following information:
- Request's method, - The request's method.
- Request's URI (templated if possible) - The request's URI (templated if possible).
- Simple class name of any exception that was thrown while handling the request - The simple class name of any exception that was thrown while handling the request.
- Response's status - The response's status.
To customize the tags, provide a `@Bean` that implements `WebFluxTagsProvider`. To customize the tags, provide a `@Bean` that implements `WebFluxTagsProvider`.
Metrics for the functional programming model will, by default, be tagged with the By default, metrics for the functional programming model are tagged with the following
following: information:
- Request's method, - The request's method
- Request's URI (templated if possible) - The request's URI (templated if possible).
- Response's status - The esponse's status.
To customize the tags, use the `defaultTags` method on the `RouterFunctionMetrics` To customize the tags, use the `defaultTags` method on your `RouterFunctionMetrics`
instance that you are using. instance.
[[production-ready-metrics-rest-template]] [[production-ready-metrics-rest-template]]
=== RestTemplate metrics === RestTemplate Metrics
Auto-configuration will customize the auto-configured `RestTemplate` to enable the Auto-configuration customizes the auto-configured `RestTemplate` to enable the
instrumentation of its requests. `MetricsRestTemplateCustomizer` can be used to instrumentation of its requests. `MetricsRestTemplateCustomizer` can be used to customize
customize your own `RestTemplate` instances. your own `RestTemplate` instances.
Metrics will, by default, be generated with the name `http.client.requests`. The name By default, metrics are generated with the name, `http.client.requests`. The name can be
can be customized using the `spring.metrics.web.client.requests-metric-name` property. customized by setting the `spring.metrics.web.client.requests-metrics-name` property.
[[production-ready-metrics-rest-template-tags]] [[production-ready-metrics-rest-template-tags]]
==== RestTemplate metric tags ==== RestTemplate Metric Tags
Metrics generated by an instrumented `RestTemplate` will, by default, be tagged with By default, metrics generated by an instrumented `RestTemplate` are tagged with the
the following: following information:
- Request's method - The request's method.
- Request's URI (templated if possible) - The request's URI (templated if possible).
- Response's status - The response's status.
- Request URI's host - The request URI's host.
...@@ -974,9 +981,8 @@ name. ...@@ -974,9 +981,8 @@ name.
[[production-ready-metrics-integration]] [[production-ready-metrics-integration]]
=== Spring Integration metrics === Spring Integration Metrics
Auto-configuration will enable binding of a number of Spring Integration-related Auto-configuration enables binding of a number of Spring Integration-related metrics:
metrics:
.General metrics .General metrics
|=== |===
...@@ -1035,24 +1041,25 @@ metrics: ...@@ -1035,24 +1041,25 @@ metrics:
[[production-ready-auditing]] [[production-ready-auditing]]
== Auditing == Auditing
Spring Boot Actuator has a flexible audit framework that will publish events once Spring Once Spring Security is in play Spring Boot Actuator has a flexible audit framework that
Security is in play ('`authentication success`', '`failure`' and '`access denied`' publishes events (by default, '`authentication success`', '`failure`' and
exceptions by default). This can be very useful for reporting, and also to implement a '`access denied`' exceptions). This feature can be very useful for reporting and for
lock-out policy based on authentication failures. To customize published security events implementing a lock-out policy based on authentication failures. To customize published
you can provide your own implementations of `AbstractAuthenticationAuditListener` and security events, you can provide your own implementations of
`AbstractAuthorizationAuditListener`. `AbstractAuthenticationAuditListener` and `AbstractAuthorizationAuditListener`.
You can also choose to use the audit services for your own business events. To do that You can also use the audit services for your own business events. To do so, either inject
you can either inject the existing `AuditEventRepository` into your own components and the existing `AuditEventRepository` into your own components and use that directly or
use that directly, or you can simply publish `AuditApplicationEvent` via the Spring publish an `AuditApplicationEvent` with the Spring `ApplicationEventPublisher` (by
`ApplicationEventPublisher` (using `ApplicationEventPublisherAware`). implementing `ApplicationEventPublisherAware`).
[[production-ready-tracing]] [[production-ready-tracing]]
== Tracing == Tracing
Tracing is automatically enabled for all HTTP requests. You can view the `trace` endpoint Tracing is automatically enabled for all HTTP requests. You can view the `trace` endpoint
and obtain basic information about the last 100 requests: and obtain basic information about the last 100 requests. The following listing shows
sample output:
[source,json,indent=0] [source,json,indent=0]
---- ----
...@@ -1086,7 +1093,7 @@ and obtain basic information about the last 100 requests: ...@@ -1086,7 +1093,7 @@ and obtain basic information about the last 100 requests:
}] }]
---- ----
The following are included in the trace by default: By default, the trace includes the following information:
[cols="1,2"] [cols="1,2"]
|=== |===
...@@ -1112,38 +1119,38 @@ The following are included in the trace by default: ...@@ -1112,38 +1119,38 @@ The following are included in the trace by default:
[[production-ready-custom-tracing]] [[production-ready-custom-tracing]]
=== Custom tracing === Custom tracing
If you need to trace additional events you can inject a If you need to trace additional events, you can inject a
{sc-spring-boot-actuator}/trace/TraceRepository.{sc-ext}[`TraceRepository`] into your {sc-spring-boot-actuator}/trace/TraceRepository.{sc-ext}[`TraceRepository`] into your
Spring beans. The `add` method accepts a single `Map` structure that will be converted to Spring beans. The `add` method accepts a single `Map` structure that is converted to JSON
JSON and logged. and logged.
By default an `InMemoryTraceRepository` will be used that stores the last 100 events. You By default, an `InMemoryTraceRepository` that stores the last 100 events is used. If you
can define your own instance of the `InMemoryTraceRepository` bean if you need to expand need to expand the capacity, you can define your own instance of the
the capacity. You can also create your own alternative `TraceRepository` implementation `InMemoryTraceRepository` bean. You can also create your own alternative `TraceRepository`
if needed. implementation.
[[production-ready-process-monitoring]] [[production-ready-process-monitoring]]
== Process monitoring == Process Monitoring
In the `spring-boot` module you can find a couple of classes to create files that are In the `spring-boot` module, you can find two classes to create files that are often
useful for process monitoring: useful for process monitoring:
* `ApplicationPidFileWriter` creates a file containing the application PID (by default in * `ApplicationPidFileWriter` creates a file containing the application PID (by default, in
the application directory with the file name `application.pid`). the application directory with the file name, `application.pid`).
* `EmbeddedServerPortFileWriter` creates a file (or files) containing the ports of the * `EmbeddedServerPortFileWriter` creates a file (or files) containing the ports of the
embedded server (by default in the application directory with the file name embedded server (by default, in the application directory with the file name
`application.port`). `application.port`).
These writers are not activated by default, but you can enable them in one of the ways By default, these writers are not activated, but you can enable them in one of the ways
described below. described in the next section.
[[production-ready-process-monitoring-configuration]] [[production-ready-process-monitoring-configuration]]
=== Extend configuration === Extend Configuration
In `META-INF/spring.factories` file you can activate the listener(s) that In the `META-INF/spring.factories` file, you can activate the listener(s) that writes a
writes a PID file. Example: PID file, as shown in the following example:
[indent=0] [indent=0]
---- ----
...@@ -1157,31 +1164,31 @@ writes a PID file. Example: ...@@ -1157,31 +1164,31 @@ writes a PID file. Example:
[[production-ready-process-monitoring-programmatically]] [[production-ready-process-monitoring-programmatically]]
=== Programmatically === Programmatically
You can also activate a listener by invoking the `SpringApplication.addListeners(...)` You can also activate a listener by invoking the `SpringApplication.addListeners(...)`
method and passing the appropriate `Writer` object. This method also allows you to method and passing the appropriate `Writer` object. This method also lets you customize
customize the file name and path via the `Writer` constructor. the file name and path in the `Writer` constructor.
[[production-ready-cloudfoundry]] [[production-ready-cloudfoundry]]
== Cloud Foundry support == Cloud Foundry Support
Spring Boot's actuator module includes additional support that is activated when you Spring Boot's actuator module includes additional support that is activated when you
deploy to a compatible Cloud Foundry instance. The `/cloudfoundryapplication` path deploy to a compatible Cloud Foundry instance. The `/cloudfoundryapplication` path
provides an alternative secured route to all `@Endpoint` beans. provides an alternative secured route to all `@Endpoint` beans.
The extended support allows Cloud Foundry management UIs (such as the web The extended support lets Cloud Foundry management UIs (such as the web application that
application that you can use to view deployed applications) to be augmented with Spring you can use to view deployed applications) be augmented with Spring Boot actuator
Boot actuator information. For example, an application status page may include full health information. For example, an application status page may include full health information
information instead of the typical "`running`" or "`stopped`" status. instead of the typical "`running`" or "`stopped`" status.
NOTE: The `/cloudfoundryapplication` path is not directly accessible to regular users. NOTE: The `/cloudfoundryapplication` path is not directly accessible to regular users.
In order to use the endpoint a valid UAA token must be passed with the request. In order to use the endpoint, a valid UAA token must be passed with the request.
[[production-ready-cloudfoundry-disable]] [[production-ready-cloudfoundry-disable]]
=== Disabling extended Cloud Foundry actuator support === Disabling Extended Cloud Foundry Actuator Support
If you want to fully disable the `/cloudfoundryapplication` endpoints you can add the If you want to fully disable the `/cloudfoundryapplication` endpoints, you can add the
following to your `application.properties` file: following setting to your `application.properties` file:
.application.properties .application.properties
...@@ -1193,10 +1200,10 @@ following to your `application.properties` file: ...@@ -1193,10 +1200,10 @@ following to your `application.properties` file:
[[production-ready-cloudfoundry-ssl]] [[production-ready-cloudfoundry-ssl]]
=== Cloud Foundry self signed certificates === Cloud Foundry Self-signed Certificates
By default, the security verification for `/cloudfoundryapplication` endpoints makes SSL By default, the security verification for `/cloudfoundryapplication` endpoints makes SSL
calls to various Cloud Foundry services. If your Cloud Foundry UAA or Cloud Controller calls to various Cloud Foundry services. If your Cloud Foundry UAA or Cloud Controller
services use self-signed certificates you will need to set the following property: services use self-signed certificates, you need to set the following property:
.application.properties .application.properties
[source,properties,indent=0] [source,properties,indent=0]
...@@ -1207,14 +1214,15 @@ services use self-signed certificates you will need to set the following propert ...@@ -1207,14 +1214,15 @@ services use self-signed certificates you will need to set the following propert
[[production-ready-cloudfoundry-custom-security]] [[production-ready-cloudfoundry-custom-security]]
=== Custom security configuration === Custom Security Configuration
If you define custom security configuration, and you want extended Cloud Foundry actuator If you define custom security configuration and you want extended Cloud Foundry actuator
support, you'll should ensure that `/cloudfoundryapplication/**` paths are open. Without support, you should ensure that `/cloudfoundryapplication/**` paths are open. Without a
a direct open route, your Cloud Foundry application manager will not be able to obtain direct open route, your Cloud Foundry application manager is not able to obtain endpoint
endpoint data. data.
For Spring Security, you'll typically include something like For Spring Security, you typically include something like
`mvcMatchers("/cloudfoundryapplication/**").permitAll()` in your configuration: `mvcMatchers("/cloudfoundryapplication/**").permitAll()` in your configuration, as shown
in the following example:
[source,java,indent=0] [source,java,indent=0]
---- ----
...@@ -1224,12 +1232,11 @@ include::{code-examples}/cloudfoundry/CloudFoundryIgnorePathsExample.java[tag=se ...@@ -1224,12 +1232,11 @@ include::{code-examples}/cloudfoundry/CloudFoundryIgnorePathsExample.java[tag=se
[[production-ready-whats-next]] [[production-ready-whats-next]]
== What to read next == What to Read Next
If you want to explore some of the concepts discussed in this chapter, you can take a If you want to explore some of the concepts discussed in this chapter, you can take a
look at the actuator {github-code}/spring-boot-samples[sample applications]. You also look at the actuator {github-code}/spring-boot-samples[sample applications]. You also
might want to read about graphing tools such as http://graphite.wikidot.com/[Graphite]. might want to read about graphing tools such as http://graphite.wikidot.com/[Graphite].
Otherwise, you can continue on, to read about <<deployment.adoc#deployment, Otherwise, you can continue on, to read about <<deployment.adoc#deployment, '`deployment
'`deployment options`'>> or jump ahead options`'>> or jump ahead for some in-depth information about Spring Boot's
for some in-depth information about Spring Boot's
_<<build-tool-plugins.adoc#build-tool-plugins, build tool plugins>>_. _<<build-tool-plugins.adoc#build-tool-plugins, build tool plugins>>_.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment