Update Actuator to use the new endpoint infrastructure

This commit migrates the Actuator onto the new endpoint infrastruture.
In addition to the existing support for accessing the endpoints via
JMX and HTTP using Spring MVC, support for access via HTTP using
Jersey and WebFlux has been added. This includes using a separate
management port where we now spin up an additional, appropriately
configured servlet or reactive web server to expose the management
context on a different HTTP port to the main application.

Closes gh-2921
Closes gh-5389
Closes gh-9796
This commit is contained in:
Andy Wilkinson
2017-07-12 09:08:43 +01:00
parent e92cb115e3
commit ee16332745
195 changed files with 7762 additions and 11963 deletions

View File

@@ -1085,63 +1085,31 @@ content into your application; rather pick only the properties that you need.
# ENDPOINTS ({sc-spring-boot-actuator}/endpoint/AbstractEndpoint.{sc-ext}[AbstractEndpoint] subclasses)
endpoints.enabled=true # Enable endpoints.
endpoints.auditevents.enabled= # Enable the endpoint.
endpoints.auditevents.path= # Endpoint path.
endpoints.autoconfig.enabled= # Enable the endpoint.
endpoints.autoconfig.id= # Endpoint identifier.
endpoints.autoconfig.path= # Endpoint path.
endpoints.beans.enabled= # Enable the endpoint.
endpoints.beans.id= # Endpoint identifier.
endpoints.beans.path= # Endpoint path.
endpoints.configprops.enabled= # Enable the endpoint.
endpoints.configprops.id= # Endpoint identifier.
endpoints.configprops.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions.
endpoints.configprops.path= # Endpoint path.
endpoints.docs.curies.enabled=false # Enable the curie generation.
endpoints.docs.enabled=true # Enable actuator docs endpoint.
endpoints.docs.path=/docs #
endpoints.dump.enabled= # Enable the endpoint.
endpoints.dump.id= # Endpoint identifier.
endpoints.dump.path= # Endpoint path.
endpoints.env.enabled= # Enable the endpoint.
endpoints.env.id= # Endpoint identifier.
endpoints.env.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions.
endpoints.env.path= # Endpoint path.
endpoints.flyway.enabled= # Enable the endpoint.
endpoints.flyway.id= # Endpoint identifier.
endpoints.health.enabled= # Enable the endpoint.
endpoints.health.id= # Endpoint identifier.
endpoints.health.mapping.*= # Mapping of health statuses to HttpStatus codes. By default, registered health statuses map to sensible defaults (i.e. UP maps to 200).
endpoints.health.path= # Endpoint path.
endpoints.health.time-to-live=1000 # Time to live for cached result, in milliseconds.
endpoints.heapdump.enabled= # Enable the endpoint.
endpoints.heapdump.path= # Endpoint path.
endpoints.info.enabled= # Enable the endpoint.
endpoints.info.id= # Endpoint identifier.
endpoints.info.path= # Endpoint path.
endpoints.liquibase.enabled= # Enable the endpoint.
endpoints.liquibase.id= # Endpoint identifier.
endpoints.logfile.enabled=true # Enable the endpoint.
endpoints.logfile.external-file= # External Logfile to be accessed.
endpoints.logfile.path=/logfile # Endpoint URL path.
endpoints.loggers.enabled=true # Enable the endpoint.
endpoints.loggers.id= # Endpoint identifier.
endpoints.loggers.path=/logfile # Endpoint path.
endpoints.mappings.enabled= # Enable the endpoint.
endpoints.mappings.id= # Endpoint identifier.
endpoints.mappings.path= # Endpoint path.
endpoints.metrics.enabled= # Enable the endpoint.
endpoints.metrics.filter.enabled=true # Enable the metrics servlet filter.
endpoints.metrics.filter.gauge-submissions=merged # Http filter gauge submissions (merged, per-http-method)
endpoints.metrics.filter.counter-submissions=merged # Http filter counter submissions (merged, per-http-method)
endpoints.metrics.id= # Endpoint identifier.
endpoints.metrics.path= # Endpoint path.
endpoints.shutdown.enabled= # Enable the endpoint.
endpoints.shutdown.id= # Endpoint identifier.
endpoints.shutdown.path= # Endpoint path.
endpoints.threaddump.enabled= # Enable the endpoint.
endpoints.trace.enabled= # Enable the endpoint.
endpoints.trace.filter.enabled=true # Enable the trace servlet filter.
endpoints.trace.id= # Endpoint identifier.
endpoints.trace.path= # Endpoint path.
# ENDPOINTS CORS CONFIGURATION ({sc-spring-boot-actuator}/autoconfigure/EndpointCorsProperties.{sc-ext}[EndpointCorsProperties])
endpoints.cors.allow-credentials= # Set whether credentials are supported. When not set, credentials are not supported.

View File

@@ -65,8 +65,8 @@ rules of thumb:
`+@Conditional*+` annotations to find out what features they enable and when. Add
`--debug` to the command line or a System property `-Ddebug` to get a log on the
console of all the auto-configuration decisions that were made in your app. In a running
Actuator app look at the `autoconfig` endpoint ('`/autoconfig`' or the JMX equivalent) for
the same information.
Actuator app look at the `autoconfig` endpoint (`/application/autoconfig` or the JMX
equivalent) for the same information.
* Look for classes that are `@ConfigurationProperties` (e.g.
{sc-spring-boot-autoconfigure}/web/ServerProperties.{sc-ext}[`ServerProperties`])
and read from there the available external configuration options. The

View File

@@ -82,9 +82,6 @@ The following technology agnostic endpoints are available:
|`configprops`
|Displays a collated list of all `@ConfigurationProperties`.
|`dump`
|Performs a thread dump.
|`env`
|Exposes properties from Spring's `ConfigurableEnvironment`.
@@ -112,11 +109,15 @@ The following technology agnostic endpoints are available:
|`shutdown`
|Allows the application to be gracefully shutdown (not enabled by default).
|`threaddump`
|Performs a thread dump.
|`trace`
|Displays trace information (by default the last 100 HTTP requests).
|===
If you are using Spring MVC, the following additional endpoints can also be used:
If your application is a web application (Spring MVC, Spring WebFlux, or Jersey), the
following additional endpoints can also be used:
[cols="2,5"]
|===
@@ -234,8 +235,9 @@ from `/management`.
=== CORS support
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
flexible way what kind of cross domain requests are authorized. Actuator's MVC endpoints
can be configured to support such scenarios.
flexible way what kind of cross domain requests are authorized. If you are using Spring
MVC or Spring WebFlux, Actuator's web endpoints can be configured to support such
scenarios.
CORS support is disabled by default and is only enabled once the
`endpoints.cors.allowed-origins` property has been set. The configuration below permits
@@ -254,18 +256,15 @@ for a complete list of options.
[[production-ready-customizing-endpoints-programmatically]]
=== Adding custom endpoints
If you add a `@Bean` of type `Endpoint` then it will automatically be exposed over JMX and
HTTP (if there is an server available). An HTTP endpoints can be customized further by
creating a bean of type `MvcEndpoint`. Your `MvcEndpoint` is not a `@Controller` but it
can use `@RequestMapping` (and `@Managed*`) to expose resources.
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
application, over HTTP as well.
TIP: If you are doing this as a library feature consider adding a configuration class
annotated with `@ManagementContextConfiguration` to `/META-INF/spring.factories` under the
key `org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration`. If
you do that then the endpoint will move to a child context with all the other MVC
endpoints if your users ask for a separate management port or address. A configuration
declared this way can be a `WebConfigurerAdapter` if it wants to add static resources (for
instance) to the management endpoints.
you do that then the endpoint will move to a child context with all the other web
endpoints endpoints if your users ask for a separate management port or address.
@@ -289,13 +288,6 @@ overall health status. If no `HealthIndicator` returns a status that is known to
=== Security with HealthIndicators
Health responses are also cached to prevent "`denial of service`" attacks. Use the
`endpoints.health.time-to-live` property if you want to change the default cache period
of 1000 milliseconds.
==== Auto-configured HealthIndicators
The following `HealthIndicators` are auto-configured by Spring Boot when appropriate:
@@ -561,7 +553,8 @@ is exposed as `/application/health`.
=== Customizing the management endpoint paths
Sometimes it is useful to customize the prefix for the management endpoints.
For example, your application might already use `/application` for another purpose.
You can use the `management.context-path` property to change the prefix for your management endpoint:
You can use the `management.context-path` property to change the prefix for your
management endpoint:
[source,properties,indent=0]
----
@@ -571,21 +564,9 @@ You can use the `management.context-path` property to change the prefix for your
The `application.properties` example above will change the endpoint from `/application/{id}` to
`/manage/{id}` (e.g. `/manage/info`).
You can also change the "`path`" of an endpoint (using `endpoints.{name}.path`) which then
changes the default resource path for the MVC endpoint. There is no validation on
those values (so you can use anything that is legal in a URL path). For example, to change
the location of the `/health` endpoint to `/ping/me` you can set
`endpoints.health.path=/ping/me`.
NOTE: Even if an endpoint path is configured separately, it is still relative to the
`management.context-path`.
TIP: If you provide a custom `MvcEndpoint` remember to include a settable `path` property,
and default it to `/{id}` if you want your code to behave like the standard MVC endpoints.
(Take a look at the `HealthMvcEndpoint` to see how you might do that.) If your custom
endpoint is an `Endpoint` (not an `MvcEndpoint`) then Spring Boot will take care of the
path for you.
[[production-ready-customizing-management-server-port]]
@@ -686,10 +667,7 @@ The information exposed by the health endpoint varies depending on whether or no
accessed anonymously, and whether or not the enclosing application is secure.
By default, when accessed anonymously in a secure application, any details about the
server's health are hidden and the endpoint will simply indicate whether or not the server
is up or down. Furthermore the response is cached for a configurable period to prevent the
endpoint being used in a denial of service attack. The `endpoints.health.time-to-live`
property is used to configure the caching period in milliseconds. It defaults to 1000,
i.e. one second.
is up or down.
Sample summarized HTTP response (default for anonymous request):
@@ -1429,7 +1407,7 @@ customize the file name and path via the `Writer` constructor.
== Cloud Foundry support
Spring Boot's actuator module includes additional support that is activated when you
deploy to a compatible Cloud Foundry instance. The `/cloudfoundryapplication` path
provides an alternative secured route to all `NamedMvcEndpoint` beans.
provides an alternative secured route to all `@Endpoint` beans.
The extended support allows Cloud Foundry management UIs (such as the web
application that you can use to view deployed applications) to be augmented with Spring

View File

@@ -1219,8 +1219,8 @@ early instantiation. There is a
validation sample] so you can see how to set things up.
TIP: The `spring-boot-actuator` module includes an endpoint that exposes all
`@ConfigurationProperties` beans. Simply point your web browser to `/configprops`
or use the equivalent JMX endpoint. See the
`@ConfigurationProperties` beans. Simply point your web browser to
`/application/configprops` or use the equivalent JMX endpoint. See the
_<<production-ready-features.adoc#production-ready-endpoints, Production ready features>>_.
section for details.