* pr/27759:
Make editorial changes to actuator documentation
Update actuator docs to prefer "You can..."
Improve actuator example lead-in text
Polish actuator docs markup and formatting
Closes gh-27759
Once Spring Security is in play, Spring Boot Actuator has a flexible audit framework that publishes events (by default, "`authentication success`", "`failure`" and "`access denied`" exceptions).
Once Spring Security is in play, Spring Boot Actuator has a flexible audit framework that publishes events (by default, "`authentication success`", "`failure`" and "`access denied`" exceptions).
This feature can be very useful for reporting and for implementing a lock-out policy based on authentication failures.
This feature can be very useful for reporting and for implementing a lock-out policy based on authentication failures.
Auditing can be enabled by providing a bean of type `AuditEventRepository` in your application's configuration.
You can enable auditing by providing a bean of type `AuditEventRepository` in your application's configuration.
For convenience, Spring Boot offers an `InMemoryAuditEventRepository`.
For convenience, Spring Boot offers an `InMemoryAuditEventRepository`.
`InMemoryAuditEventRepository` has limited capabilities and we recommend using it only for development environments.
`InMemoryAuditEventRepository` has limited capabilities, and we recommend using it only for development environments.
For production environments, consider creating your own alternative `AuditEventRepository` implementation.
For production environments, consider creating your own alternative `AuditEventRepository` implementation.
@ -4,10 +4,10 @@ Spring Boot's actuator module includes additional support that is activated when
The `/cloudfoundryapplication` path provides an alternative secured route to all `@Endpoint` beans.
The `/cloudfoundryapplication` path provides an alternative secured route to all `@Endpoint` beans.
The extended support lets Cloud Foundry management UIs (such as the web application that you can use to view deployed applications) be augmented with Spring Boot actuator information.
The extended support lets Cloud Foundry management UIs (such as the web application that you can use to view deployed applications) be augmented with Spring Boot actuator information.
For example, an application status page may include full health information instead of the typical "`running`" or "`stopped`" status.
For example, an application status page can include full health information 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.
To use the endpoint, you must pass a valid UAA token with the request.
@ -15,7 +15,6 @@ In order to use the endpoint, a valid UAA token must be passed with the request.
=== 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 following setting to your `application.properties` file:
If you want to fully disable the `/cloudfoundryapplication` endpoints, you can add the following setting to your `application.properties` file:
@ -41,12 +40,12 @@ If your Cloud Foundry UAA or Cloud Controller services use self-signed certifica
[[actuator.cloud-foundry.custom-context-path]]
[[actuator.cloud-foundry.custom-context-path]]
=== Custom Context Path
=== Custom Context Path
If the server's context-path has been configured to anything other than `/`, the Cloud Foundry endpoints will not be available at the root of the application.
If the server's context-path has been configured to anything other than `/`, the Cloud Foundry endpoints are not available at the root of the application.
For example, if `server.servlet.context-path=/app`, Cloud Foundry endpoints will be available at `/app/cloudfoundryapplication/*`.
For example, if `server.servlet.context-path=/app`, Cloud Foundry endpoints are available at `/app/cloudfoundryapplication/*`.
If you expect the Cloud Foundry endpoints to always be available at `/cloudfoundryapplication/*`, regardless of the server's context-path, you will need to explicitly configure that in your application.
If you expect the Cloud Foundry endpoints to always be available at `/cloudfoundryapplication/*`, regardless of the server's context-path, you need to explicitly configure that in your application.
The configuration will differ depending on the web server in use.
The configuration differs, depending on the web server in use.
For Tomcat, the following configuration can be added:
For Tomcat, you can add the following configuration:
The {spring-boot-code}/spring-boot-project/spring-boot-actuator[`spring-boot-actuator`] module provides all of Spring Boot's production-ready features.
The {spring-boot-code}/spring-boot-project/spring-boot-actuator[`spring-boot-actuator`] module provides all of Spring Boot's production-ready features.
The recommended way to enable the features is to add a dependency on the `spring-boot-starter-actuator` '`Starter`'.
The recommended way to enable the features is to add a dependency on the `spring-boot-starter-actuator` "`Starter`".
.Definition of Actuator
.Definition of Actuator
****
****
@ -9,7 +9,7 @@ An actuator is a manufacturing term that refers to a mechanical device for movin
Actuators can generate a large amount of motion from a small change.
Actuators can generate a large amount of motion from a small change.
****
****
To add the actuator to a Mavenbased project, add the following '`Starter`' dependency:
To add the actuator to a Maven-based project, add the following '`Starter`' dependency:
@ -4,13 +4,13 @@ Actuator endpoints let you monitor and interact with your application.
Spring Boot includes a number of built-in endpoints and lets you add your own.
Spring Boot includes a number of built-in endpoints and lets you add your own.
For example, the `health` endpoint provides basic application health information.
For example, the `health` endpoint provides basic application health information.
Each individual endpoint can be <<actuator#actuator.endpoints.enabling, enabled or disabled>> and <<actuator#actuator.endpoints.exposing, exposed (made remotely accessible) over HTTP or JMX>>.
You can <<actuator#actuator.endpoints.enabling, enable or disable>> each individual endpoint and <<actuator#actuator.endpoints.exposing, expose them (make them remotely accessible) over HTTP or JMX>>.
An endpoint is considered to be available when it is both enabled and exposed.
An endpoint is considered to be available when it is both enabled and exposed.
The built-in endpoints will only be auto-configured when they are available.
The built-in endpoints are auto-configured only when they are available.
Most applications choose exposure via HTTP, where the ID of the endpoint along with a prefix of `/actuator` is mapped to a URL.
Most applications choose exposure over HTTP, where the ID of the endpoint and a prefix of `/actuator` is mapped to a URL.
For example, by default, the `health` endpoint is mapped to `/actuator/health`.
For example, by default, the `health` endpoint is mapped to `/actuator/health`.
TIP: To learn more about the Actuator's endpoints and their request and response formats, please refer to the separate API documentation ({spring-boot-actuator-restapi-docs}[HTML] or {spring-boot-actuator-restapi-pdfdocs}[PDF]).
TIP: To learn more about the Actuator's endpoints and their request and response formats, see the separate API documentation ({spring-boot-actuator-restapi-docs}[HTML] or {spring-boot-actuator-restapi-pdfdocs}[PDF]).
The following technology-agnostic endpoints are available:
The following technology-agnostic endpoints are available:
@ -63,7 +63,7 @@ The following technology-agnostic endpoints are available:
Requires one or more `Liquibase` beans.
Requires one or more `Liquibase` beans.
| `metrics`
| `metrics`
| Shows '`metrics`' information for the current application.
| Shows "`metrics`" information for the current application.
| `mappings`
| `mappings`
| Displays a collated list of all `@RequestMapping` paths.
| Displays a collated list of all `@RequestMapping` paths.
@ -76,7 +76,7 @@ The following technology-agnostic endpoints are available:
| `sessions`
| `sessions`
| Allows retrieval and deletion of user sessions from a Spring Session-backed session store.
| Allows retrieval and deletion of user sessions from a Spring Session-backed session store.
Requires a Servlet-based web application using Spring Session.
Requires a servlet-based web application that uses Spring Session.
| `shutdown`
| `shutdown`
| Lets the application be gracefully shutdown.
| Lets the application be gracefully shutdown.
@ -102,11 +102,11 @@ If your application is a web application (Spring MVC, Spring WebFlux, or Jersey)
On an OpenJ9 JVM, a `PHD`-format file is returned.
On an OpenJ9 JVM, a `PHD`-format file is returned.
| `jolokia`
| `jolokia`
| Exposes JMX beans over HTTP (when Jolokia is on the classpath, not available for WebFlux).
| Exposes JMX beans over HTTP when Jolokia is on the classpath (not available for WebFlux).
Requires a dependency on `jolokia-core`.
Requires a dependency on `jolokia-core`.
| `logfile`
| `logfile`
| Returns the contents of the logfile (if `logging.file.name` or `logging.file.path` properties have been set).
| Returns the contents of the logfile (if the `logging.file.name` or the `logging.file.path` property has been set).
Supports the use of the HTTP `Range` header to retrieve part of the log file's content.
Supports the use of the HTTP `Range` header to retrieve part of the log file's content.
| `prometheus`
| `prometheus`
@ -150,7 +150,7 @@ If you want to change only the technologies over which an endpoint is exposed, u
[[actuator.endpoints.exposing]]
[[actuator.endpoints.exposing]]
=== Exposing Endpoints
=== Exposing Endpoints
Since Endpoints may contain sensitive information, careful consideration should be given about when to expose them.
Since Endpoints may contain sensitive information, you should carefully consider when to expose them.
The following table shows the default exposure for the built-in endpoints:
The following table shows the default exposure for the built-in endpoints:
[cols="1,1,1"]
[cols="1,1,1"]
@ -280,7 +280,7 @@ To change which endpoints are exposed, use the following technology-specific `in
The `include` property lists the IDs of the endpoints that are exposed.
The `include` property lists the IDs of the endpoints that are exposed.
The `exclude` property lists the IDs of the endpoints that should not be exposed.
The `exclude` property lists the IDs of the endpoints that should not be exposed.
The `exclude` property takes precedence over the `include` property.
The `exclude` property takes precedence over the `include` property.
Both `include` and `exclude` properties can be configured with a list of endpoint IDs.
You can configure both the `include` and the `exclude` properties with a list of endpoint IDs.
For example, to stop exposing all endpoints over JMX and only expose the `health` and `info` endpoints, use the following property:
For example, to stop exposing all endpoints over JMX and only expose the `health` and `info` endpoints, use the following property:
@ -306,7 +306,7 @@ For example, to expose everything over HTTP except the `env` and `beans` endpoin
exclude: "env,beans"
exclude: "env,beans"
----
----
NOTE: `*` has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints.
NOTE: `*` has a special meaning in YAML, so be sure to add quotation marks if you want to include (or exclude) all endpoints.
NOTE: If your application is exposed publicly, we strongly recommend that you also <<actuator#actuator.endpoints.security, secure your endpoints>>.
NOTE: If your application is exposed publicly, we strongly recommend that you also <<actuator#actuator.endpoints.security, secure your endpoints>>.
@ -317,14 +317,14 @@ TIP: If you want to implement your own strategy for when endpoints are exposed,
[[actuator.endpoints.security]]
[[actuator.endpoints.security]]
=== Security
=== Security
For security purposes, all actuators other than `/health` are disabled by default.
For security purposes, all actuators other than `/health` are disabled by default.
The configprop:management.endpoints.web.exposure.include[] property can be used to enable the actuators.
You can use the configprop:management.endpoints.web.exposure.include[] property to enable the actuators.
NOTE: Before setting the `management.endpoints.web.exposure.include`, ensure that the exposed actuators do not contain sensitive information and/or are secured by placing them behind a firewall or by something like Spring Security.
NOTE: Before setting the `management.endpoints.web.exposure.include`, ensure that the exposed actuators do not contain sensitive information, are secured by placing them behind a firewall, or are secured by something like Spring Security.
If Spring Security is on the classpath and no other `WebSecurityConfigurerAdapter` or `SecurityFilterChain` bean is present, all actuators other than `/health` are secured by Spring Boot auto-configuration.
If Spring Security is on the classpath and no other `WebSecurityConfigurerAdapter` or `SecurityFilterChain` bean is present, all actuators other than `/health` are secured by Spring Boot auto-configuration.
If you define a custom `WebSecurityConfigurerAdapter` or `SecurityFilterChain` bean, Spring Boot auto-configuration will back off and you will be in full control of actuator access rules.
If you define a custom `WebSecurityConfigurerAdapter` or `SecurityFilterChain` bean, Spring Boot auto-configuration backs off and lets you fully control the actuator access rules.
If you wish to configure custom security for HTTP endpoints, for example, only allow users with a certain role to access them, Spring Boot provides some convenient `RequestMatcher` objects that can be used in combination with Spring Security.
If you wish to configure custom security for HTTP endpoints (for example, to allow only users with a certain role to access them), Spring Boot provides some convenient `RequestMatcher` objects that you can use in combination with Spring Security.
A typical Spring Security configuration might look something like the following example:
A typical Spring Security configuration might look something like the following example:
@ -349,31 +349,33 @@ You can do so by changing the configprop:management.endpoints.web.exposure.inclu
include: "*"
include: "*"
----
----
Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints as shown in the following example:
Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints, as the following example shows:
NOTE: In both the examples above, the configuration applies only to the actuator endpoints.
NOTE: In both of the preceding examples, the configuration applies only to the actuator endpoints.
Since Spring Boot's security configuration backs off completely in the presence of any `SecurityFilterChain` bean, you will need to configure an additional `SecurityFilterChain` bean with rules that apply to the rest of the application.
Since Spring Boot's security configuration backs off completely in the presence of any `SecurityFilterChain` bean, you need to configure an additional `SecurityFilterChain` bean with rules that apply to the rest of the application.
[[actuator.endpoints.security.csrf]]
[[actuator.endpoints.security.csrf]]
==== Cross Site Request Forgery Protection
==== Cross Site Request Forgery Protection
Since Spring Boot relies on Spring Security's defaults, CSRF protection is turned on by default.
Since Spring Boot relies on Spring Security's defaults, CSRF protection is turned on by default.
This means that the actuator endpoints that require a `POST` (shutdown and loggers endpoints), `PUT` or `DELETE` will get a 403 forbidden error when the default security configuration is in use.
This means that the actuator endpoints that require a `POST` (shutdown and loggers endpoints), a `PUT`, or a `DELETE` get a 403 (forbidden) error when the default security configuration is in use.
NOTE: We recommend disabling CSRF protection completely only if you are creating a service that is used by non-browser clients.
NOTE: We recommend disabling CSRF protection completely only if you are creating a service that is used by non-browser clients.
Additional information about CSRF protection can be found in the {spring-security-docs}#csrf[Spring Security Reference Guide].
You can find additional information about CSRF protection in the {spring-security-docs}#csrf[Spring Security Reference Guide].
[[actuator.endpoints.caching]]
[[actuator.endpoints.caching]]
=== Configuring Endpoints
=== Configuring Endpoints
Endpoints automatically cache responses to read operations that do not take any parameters.
Endpoints automatically cache responses to read operations that do not take any parameters.
To configure the amount of time for which an endpoint will cache a response, use its `cache.time-to-live` property.
To configure the amount of time for which an endpoint caches a response, use its `cache.time-to-live` property.
The following example sets the time-to-live of the `beans` endpoint's cache to 10 seconds:
The following example sets the time-to-live of the `beans` endpoint's cache to 10 seconds:
@ -385,7 +387,7 @@ The following example sets the time-to-live of the `beans` endpoint's cache to 1
time-to-live: "10s"
time-to-live: "10s"
----
----
NOTE: The prefix `management.endpoint.<name>` is used to uniquely identify the endpoint that is being configured.
NOTE: The `management.endpoint.<name>` prefix uniquely identifies the endpoint that is being configured.
@ -406,7 +408,7 @@ To disable the "`discovery page`", add the following property to your applicatio
----
----
When a custom management context path is configured, the "`discovery page`" automatically moves from `/actuator` to the root of the management context.
When a custom management context path is configured, the "`discovery page`" automatically moves from `/actuator` to the root of the management context.
For example, if the management context path is `/management`, then the discovery page is available from `/management`.
For example, if the management context path is `/management`, the discovery page is available from `/management`.
When the management context path is set to `/`, the discovery page is disabled to prevent the possibility of a clash with other mappings.
When the management context path is set to `/`, the discovery page is disabled to prevent the possibility of a clash with other mappings.
@ -414,9 +416,9 @@ When the management context path is set to `/`, the discovery page is disabled t
[[actuator.endpoints.cors]]
[[actuator.endpoints.cors]]
=== CORS Support
=== CORS Support
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-origin resource sharing] (CORS) is a https://www.w3.org/TR/cors/[W3C specification] that lets you specify in a flexible way what kind of cross-domain requests are authorized.
https://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-origin resource sharing] (CORS) is a https://www.w3.org/TR/cors/[W3C specification] that lets you specify in a flexible way what kind of cross-domain requests are authorized.
If you use Spring MVC or Spring WebFlux, Actuator's web endpoints can be configured to support such scenarios.
If you use Spring MVC or Spring WebFlux, you can configure Actuator's web endpoints to support such scenarios.
CORS support is disabled by default and is only enabled once the configprop:management.endpoints.web.cors.allowed-origins[] property has been set.
CORS support is disabled by default and is only enabled once you have set the configprop:management.endpoints.web.cors.allowed-origins[] property.
The following configuration permits `GET` and `POST` calls from the `example.com` domain:
The following configuration permits `GET` and `POST` calls from the `example.com` domain:
@ -429,15 +431,15 @@ The following configuration permits `GET` and `POST` calls from the `example.com
allowed-methods: "GET,POST"
allowed-methods: "GET,POST"
----
----
TIP: See {spring-boot-actuator-autoconfigure-module-code}/endpoint/web/CorsEndpointProperties.java[CorsEndpointProperties] for a complete list of options.
TIP: See {spring-boot-actuator-autoconfigure-module-code}/endpoint/web/CorsEndpointProperties.java[`CorsEndpointProperties`] for a complete list of options.
[[actuator.endpoints.implementing-custom]]
[[actuator.endpoints.implementing-custom]]
=== Implementing Custom Endpoints
=== Implementing Custom Endpoints
If you add a `@Bean` annotated with `@Endpoint`, any methods annotated with `@ReadOperation`, `@WriteOperation`, or `@DeleteOperation` are automatically exposed over JMX and, in a web application, over HTTP as well.
If you add a `@Bean` annotated with `@Endpoint`, any methods annotated with `@ReadOperation`, `@WriteOperation`, or `@DeleteOperation` are automatically exposed over JMX and, in a web application, over HTTP as well.
Endpoints can be exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
Endpoints can be exposed over HTTP by using Jersey, Spring MVC, or Spring WebFlux.
If both Jersey and Spring MVC are available, Spring MVC will be used.
If both Jersey and Spring MVC are available, Spring MVC is used.
The following example exposes a read operation that returns a custom object:
The following example exposes a read operation that returns a custom object:
@ -459,13 +461,13 @@ Finally, if you need access to web-framework-specific functionality, you can imp
[[actuator.endpoints.implementing-custom.input]]
[[actuator.endpoints.implementing-custom.input]]
==== Receiving Input
==== Receiving Input
Operations on an endpoint receive input via their parameters.
Operations on an endpoint receive input through their parameters.
When exposed via the web, the values for these parameters are taken from the URL's query parameters and from the JSON request body.
When exposed over the web, the values for these parameters are taken from the URL's query parameters and from the JSON request body.
When exposed via JMX, the parameters are mapped to the parameters of the MBean's operations.
When exposed over JMX, the parameters are mapped to the parameters of the MBean's operations.
Parameters are required by default.
Parameters are required by default.
They can be made optional by annotating them with either `@javax.annotation.Nullable` or `@org.springframework.lang.Nullable`.
They can be made optional by annotating them with either `@javax.annotation.Nullable` or `@org.springframework.lang.Nullable`.
Each root property in the JSON request body can be mapped to a parameter of the endpoint.
You can map each root property in the JSON request body to a parameter of the endpoint.
Consider the following JSON request body:
Consider the following JSON request body:
[source,json,indent=0,subs="verbatim"]
[source,json,indent=0,subs="verbatim"]
@ -476,7 +478,7 @@ Consider the following JSON request body:
}
}
----
----
This can be used to invoke a write operation that takes `String name` and `int counter` parameters, as shown in the following example:
You can use this to invoke a write operation that takes `String name` and `int counter` parameters, as the following example shows:
TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature.
TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature.
In particular declaring a single parameter with a `CustomData` type defining a `name` and `counter` properties is not supported.
In particular, declaring a single parameter with a `CustomData` type that defines a `name` and `counter` properties is not supported.
NOTE: To allow the input to be mapped to the operation method's parameters, Java code implementing an endpoint should be compiled with `-parameters`, and Kotlin code implementing an endpoint should be compiled with `-java-parameters`.
NOTE: To let the input be mapped to the operation method's parameters, Java code that implements an endpoint should be compiled with `-parameters`, and Kotlin code that implements an endpoint should be compiled with `-java-parameters`.
This will happen automatically if you are using Spring Boot's Gradle plugin or if you are using Maven and `spring-boot-starter-parent`.
This will happen automatically if you use Spring Boot's Gradle plugin or if you use Maven and `spring-boot-starter-parent`.
The parameters passed to endpoint operation methods are, if necessary, automatically converted to the required type.
The parameters passed to endpoint operation methods are, if necessary, automatically converted to the required type.
Before calling an operation method, the input received via JMX or an HTTP request is converted to the required types using an instance of `ApplicationConversionService` as well as any `Converter` or `GenericConverter` beans qualified with `@EndpointConverter`.
Before calling an operation method, the input received over JMX or HTTP is converted to the required types by using an instance of `ApplicationConversionService` as well as any `Converter` or `GenericConverter` beans qualified with `@EndpointConverter`.
[[actuator.endpoints.implementing-custom.web]]
[[actuator.endpoints.implementing-custom.web]]
==== Custom Web Endpoints
==== Custom Web Endpoints
Operations on an `@Endpoint`, `@WebEndpoint`, or `@EndpointWebExtension` are automatically exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
Operations on an `@Endpoint`, `@WebEndpoint`, or `@EndpointWebExtension` are automatically exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
If both Jersey and Spring MVC are available, Spring MVC will be used.
If both Jersey and Spring MVC are available, Spring MVC is used.
@ -513,14 +515,14 @@ A request predicate is automatically generated for each operation on a web-expos
The path of the predicate is determined by the ID of the endpoint and the base path of web-exposed endpoints.
The path of the predicate is determined by the ID of the endpoint and the base path of the web-exposed endpoints.
The default base path is `/actuator`.
The default base path is `/actuator`.
For example, an endpoint with the ID `sessions` will use `/actuator/sessions` as its path in the predicate.
For example, an endpoint with an ID of `sessions` uses `/actuator/sessions` as its path in the predicate.
The path can be further customized by annotating one or more parameters of the operation method with `@Selector`.
You can further customize the path by annotating one or more parameters of the operation method with `@Selector`.
Such a parameter is added to the path predicate as a path variable.
Such a parameter is added to the path predicate as a path variable.
The variable's value is passed into the operation method when the endpoint operation is invoked.
The variable's value is passed into the operation method when the endpoint operation is invoked.
If you want to capture all remaining path elements, you can add `@Selector(Match=ALL_REMAINING)` to the last parameter and make it a type that is conversioncompatible with a `String[]`.
If you want to capture all remaining path elements, you can add `@Selector(Match=ALL_REMAINING)` to the last parameter and make it a type that is conversion-compatible with a `String[]`.
@ -546,20 +548,20 @@ The HTTP method of the predicate is determined by the operation type, as shown i
For a `@WriteOperation` (HTTP `POST`) that uses the request body, the consumes clause of the predicate is `application/vnd.spring-boot.actuator.v2+json, application/json`.
For a `@WriteOperation` (HTTP `POST`) that uses the request body, the `consumes` clause of the predicate is `application/vnd.spring-boot.actuator.v2+json, application/json`.
For all other operations the consumes clause is empty.
For all other operations, the `consumes` clause is empty.
The produces clause of the predicate can be determined by the `produces` attribute of the `@DeleteOperation`, `@ReadOperation`, and `@WriteOperation` annotations.
The `produces` clause of the predicate can be determined by the `produces` attribute of the `@DeleteOperation`, `@ReadOperation`, and `@WriteOperation` annotations.
The attribute is optional.
The attribute is optional.
If it is not used, the produces clause is determined automatically.
If it is not used, the `produces` clause is determined automatically.
If the operation method returns `void` or `Void` the produces clause is empty.
If the operation method returns `void` or `Void`, the `produces` clause is empty.
If the operation method returns a `org.springframework.core.io.Resource`, the produces clause is `application/octet-stream`.
If the operation method returns a `org.springframework.core.io.Resource`, the `produces` clause is `application/octet-stream`.
For all other operations the produces clause is `application/vnd.spring-boot.actuator.v2+json, application/json`.
For all other operations, the `produces` clause is `application/vnd.spring-boot.actuator.v2+json, application/json`.
@ -567,19 +569,19 @@ For all other operations the produces clause is `application/vnd.spring-boot.act
===== Web Endpoint Response Status
===== Web Endpoint Response Status
The default response status for an endpoint operation depends on the operation type (read, write, or delete) and what, if anything, the operation returns.
The default response status for an endpoint operation depends on the operation type (read, write, or delete) and what, if anything, the operation returns.
A `@ReadOperation` returns a value, the response status will be 200 (OK).
If a `@ReadOperation` returns a value, the response status will be 200 (OK).
If it does not return a value, the response status will be 404 (Not Found).
If it does not return a value, the response status will be 404 (Not Found).
If a `@WriteOperation` or `@DeleteOperation` returns a value, the response status will be 200 (OK).
If a `@WriteOperation` or `@DeleteOperation` returns a value, the response status will be 200 (OK).
If it does not return a value the response status will be 204 (No Content).
If it does not return a value, the response status will be 204 (No Content).
If an operation is invoked without a required parameter, or with a parameter that cannot be converted to the required type, the operation method will not be called and the response status will be 400 (Bad Request).
If an operation is invoked without a required parameter or with a parameter that cannot be converted to the required type, the operation method is not called, and the response status will be 400 (Bad Request).
An HTTP range request can be used to request part of an HTTP resource.
You can use an HTTP range request to request part of an HTTP resource.
When using Spring MVC or Spring Web Flux, operations that return a `org.springframework.core.io.Resource` automatically support range requests.
When using Spring MVC or Spring Web Flux, operations that return a `org.springframework.core.io.Resource` automatically support range requests.
NOTE: Range requests are not supported when using Jersey.
NOTE: Range requests are not supported when using Jersey.
@ -590,14 +592,14 @@ NOTE: Range requests are not supported when using Jersey.
===== Web Endpoint Security
===== Web Endpoint Security
An operation on a web endpoint or a web-specific endpoint extension can receive the current `java.security.Principal` or `org.springframework.boot.actuate.endpoint.SecurityContext` as a method parameter.
An operation on a web endpoint or a web-specific endpoint extension can receive the current `java.security.Principal` or `org.springframework.boot.actuate.endpoint.SecurityContext` as a method parameter.
The former is typically used in conjunction with `@Nullable` to provide different behavior for authenticated and unauthenticated users.
The former is typically used in conjunction with `@Nullable` to provide different behavior for authenticated and unauthenticated users.
The latter is typically used to perform authorization checks using its `isUserInRole(String)` method.
The latter is typically used to perform authorization checks by using its `isUserInRole(String)` method.
`@ControllerEndpoint` and `@RestControllerEndpoint` can be used to implement an endpoint that is only exposed by Spring MVC or Spring WebFlux.
You can use `@ControllerEndpoint` and `@RestControllerEndpoint` to implement an endpoint that is exposed only by Spring MVC or Spring WebFlux.
Methods are mapped using the standard annotations for Spring MVC and Spring WebFlux such as `@RequestMapping` and `@GetMapping`, with the endpoint's ID being used as a prefix for the path.
Methods are mapped by using the standard annotations for Spring MVC and Spring WebFlux, such as `@RequestMapping` and `@GetMapping`, with the endpoint's ID being used as a prefix for the path.
Controller endpoints provide deeper integration with Spring's web frameworks but at the expense of portability.
Controller endpoints provide deeper integration with Spring's web frameworks but at the expense of portability.
The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible.
The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible.
@ -616,7 +618,7 @@ The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever poss
=== Health Information
=== Health Information
You can use health information to check the status of your running application.
You can use health information to check the status of your running application.
It is often used by monitoring software to alert someone when a production system goes down.
It is often used by monitoring software to alert someone when a production system goes down.
The information exposed by the `health` endpoint depends on the configprop:management.endpoint.health.show-details[] and configprop:management.endpoint.health.show-components[] properties which can be configured with one of the following values:
The information exposed by the `health` endpoint depends on the configprop:management.endpoint.health.show-details[] and configprop:management.endpoint.health.show-components[] properties, which can be configured with one of the following values:
[cols="1, 3"]
[cols="1, 3"]
|===
|===
@ -626,8 +628,8 @@ The information exposed by the `health` endpoint depends on the configprop:manag
| Details are never shown.
| Details are never shown.
| `when-authorized`
| `when-authorized`
| Details are only shown to authorized users.
| Details are shown only to authorized users.
Authorized roles can be configured using `management.endpoint.health.roles`.
Authorized roles can be configured by using `management.endpoint.health.roles`.
| `always`
| `always`
| Details are shown to all users.
| Details are shown to all users.
@ -635,32 +637,32 @@ The information exposed by the `health` endpoint depends on the configprop:manag
The default value is `never`.
The default value is `never`.
A user is considered to be authorized when they are in one or more of the endpoint's roles.
A user is considered to be authorized when they are in one or more of the endpoint's roles.
If the endpoint has no configured roles (the default) all authenticated users are considered to be authorized.
If the endpoint has no configured roles (the default), all authenticated users are considered to be authorized.
The roles can be configured using the configprop:management.endpoint.health.roles[] property.
You can configure the roles by using the configprop:management.endpoint.health.roles[] property.
NOTE: If you have secured your application and wish to use `always`, your security configuration must permit access to the health endpoint for both authenticated and unauthenticated users.
NOTE: If you have secured your application and wish to use `always`, your security configuration must permit access to the health endpoint for both authenticated and unauthenticated users.
Health information is collected from the content of a {spring-boot-actuator-module-code}/health/HealthContributorRegistry.java[`HealthContributorRegistry`] (by default all {spring-boot-actuator-module-code}/health/HealthContributor.java[`HealthContributor`] instances defined in your `ApplicationContext`).
Health information is collected from the content of a {spring-boot-actuator-module-code}/health/HealthContributorRegistry.java[`HealthContributorRegistry`] (by default, all {spring-boot-actuator-module-code}/health/HealthContributor.java[`HealthContributor`] instances defined in your `ApplicationContext`).
Spring Boot includes a number of auto-configured `HealthContributors` and you can also write your own.
Spring Boot includes a number of auto-configured `HealthContributors`, and you can also write your own.
A `HealthContributor` can either be a `HealthIndicator` or a `CompositeHealthContributor`.
A `HealthContributor` can be either a `HealthIndicator` or a `CompositeHealthContributor`.
A `HealthIndicator` provides actual health information, including a `Status`.
A `HealthIndicator` provides actual health information, including a `Status`.
A `CompositeHealthContributor` provides a composite of other `HealthContributors`.
A `CompositeHealthContributor` provides a composite of other `HealthContributors`.
Taken together, contributors form a tree structure to represent the overall system health.
Taken together, contributors form a tree structure to represent the overall system health.
By default, the final system health is derived by a `StatusAggregator` which sorts the statuses from each `HealthIndicator` based on an ordered list of statuses.
By default, the final system health is derived by a `StatusAggregator`, 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 overall health status.
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 `StatusAggregator`, an `UNKNOWN` status is used.
If no `HealthIndicator` returns a status that is known to the `StatusAggregator`, an `UNKNOWN` status is used.
TIP: The `HealthContributorRegistry` can be used to register and unregister health indicators at runtime.
TIP: You can use the `HealthContributorRegistry` to register and unregister health indicators at runtime.
NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the `HealthIndicator` suffix, if it exists.
NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the `HealthIndicator` suffix, if it exists.
In the preceding example, the health information is available in an entry named `my`.
In the preceding example, the health information is available in an entry named `my`.
In addition to Spring Boot's predefined {spring-boot-actuator-module-code}/health/Status.java[`Status`] types, it is also possible for `Health` to return a custom `Status` that represents a new system state.
In addition to Spring Boot's predefined {spring-boot-actuator-module-code}/health/Status.java[`Status`] types, `Health` can return a custom `Status` that represents a new system state.
In such cases, a custom implementation of the {spring-boot-actuator-module-code}/health/StatusAggregator.java[`StatusAggregator`] interface also needs to be provided, or the default implementation has to be configured by using the configprop:management.endpoint.health.status.order[] configuration property.
In such cases, you also need to provide a custom implementation of the {spring-boot-actuator-module-code}/health/StatusAggregator.java[`StatusAggregator`] interface, or you must configure the default implementation by using the configprop:management.endpoint.health.status.order[] configuration property.
For example, assume a new `Status` with code `FATAL` is being used in one of your `HealthIndicator` implementations.
For example, assume a new `Status` with a code of `FATAL` is being used in one of your `HealthIndicator` implementations.
To configure the severity order, add the following property to your application properties:
To configure the severity order, add the following property to your application properties:
For reactive applications, such as those using Spring WebFlux, `ReactiveHealthContributor` provides a non-blocking contract for getting application health.
For reactive applications, such as those that use Spring WebFlux, `ReactiveHealthContributor` provides a non-blocking contract for getting application health.
Similar to a traditional `HealthContributor`, health information is collected from the content of a {spring-boot-actuator-module-code}/health/ReactiveHealthContributorRegistry.java[`ReactiveHealthContributorRegistry`] (by default all {spring-boot-actuator-module-code}/health/HealthContributor.java[`HealthContributor`] and {spring-boot-actuator-module-code}/health/ReactiveHealthContributor.java[`ReactiveHealthContributor`] instances defined in your `ApplicationContext`).
Similar to a traditional `HealthContributor`, health information is collected from the content of a {spring-boot-actuator-module-code}/health/ReactiveHealthContributorRegistry.java[`ReactiveHealthContributorRegistry`] (by default, all {spring-boot-actuator-module-code}/health/HealthContributor.java[`HealthContributor`] and {spring-boot-actuator-module-code}/health/ReactiveHealthContributor.java[`ReactiveHealthContributor`] instances defined in your `ApplicationContext`).
Regular `HealthContributors` that do not check against a reactive API are executed on the elastic scheduler.
Regular `HealthContributors` that do not check against a reactive API are executed on the elastic scheduler.
TIP: In a reactive application, The `ReactiveHealthContributorRegistry` should be used to register and unregister health indicators at runtime.
TIP: In a reactive application, you should use the `ReactiveHealthContributorRegistry` to register and unregister health indicators at runtime.
If you need to register a regular `HealthContributor`, you should wrap it using `ReactiveHealthContributor#adapt`.
If you need to register a regular `HealthContributor`, you should wrap it with `ReactiveHealthContributor#adapt`.
To provide custom health information from a reactive API, you can register Spring beans that implement the {spring-boot-actuator-module-code}/health/ReactiveHealthIndicator.java[`ReactiveHealthIndicator`] interface.
To provide custom health information from a reactive API, you can register Spring beans that implement the {spring-boot-actuator-module-code}/health/ReactiveHealthIndicator.java[`ReactiveHealthIndicator`] interface.
The following code shows a sample `ReactiveHealthIndicator` implementation:
The following code shows a sample `ReactiveHealthIndicator` implementation:
@ -846,7 +848,7 @@ TIP: To handle the error automatically, consider extending from `AbstractReactiv
The following `ReactiveHealthIndicators` are auto-configured by Spring Boot when appropriate:
When appropriate, Spring Boot auto-configures the following `ReactiveHealthIndicators`:
[cols="2,4,6"]
[cols="2,4,6"]
|===
|===
@ -884,9 +886,9 @@ Also, any `HealthIndicator` that is not handled explicitly is wrapped automatica
[[actuator.endpoints.health.groups]]
[[actuator.endpoints.health.groups]]
==== Health Groups
==== Health Groups
It's sometimes useful to organize health indicators into groups that can be used for different purposes.
It is sometimes useful to organize health indicators into groups that you can use for different purposes.
To create a health indicator group you can use the `management.endpoint.health.group.<name>` property and specify a list of health indicator IDs to `include` or `exclude`.
To create a health indicator group, you can use the `management.endpoint.health.group.<name>` property and specify a list of health indicator IDs to `include` or `exclude`.
For example, to create a group that includes only database indicators you can define the following:
For example, to create a group that includes only database indicators you can define the following:
@ -913,8 +915,9 @@ Similarly, to create a group that excludes the database indicators from the grou
exclude: "db"
exclude: "db"
----
----
By default groups will inherit the same `StatusAggregator` and `HttpCodeStatusMapper` settings as the system health, however, these can also be defined on a per-group basis.
By default, groups inherit the same `StatusAggregator` and `HttpCodeStatusMapper` settings as the system health.
It's also possible to override the `show-details` and `roles` properties if required:
However, you can also define these on a per-group basis.
You can also override the `show-details` and `roles` properties if required:
@ -966,9 +969,9 @@ The path must be a single path segment.
[[actuator.endpoints.health.datasource]]
[[actuator.endpoints.health.datasource]]
==== DataSource Health
==== DataSource Health
The `DataSource` health indicator shows the health of both standard data source and routing data source beans.
The `DataSource` health indicator shows the health of both standard data sources and routing data source beans.
The health of a routing data source includes the health of each of its target data sources.
The health of a routing data source includes the health of each of its target data sources.
In the health endpoint's response, each of a routing data source's targets is named using its routing key.
In the health endpoint's response, each of a routing data source's targets is named by using its routing key.
If you prefer not to include routing data sources in the indicator's output, set configprop:management.health.db.ignore-routing-data-sources[] to `true`.
If you prefer not to include routing data sources in the indicator's output, set configprop:management.health.db.ignore-routing-data-sources[] to `true`.
@ -976,12 +979,12 @@ If you prefer not to include routing data sources in the indicator's output, set
[[actuator.endpoints.kubernetes-probes]]
[[actuator.endpoints.kubernetes-probes]]
=== Kubernetes Probes
=== Kubernetes Probes
Applications deployed on Kubernetes can provide information about their internal state with https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes[Container Probes].
Applications deployed on Kubernetes can provide information about their internal state with https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes[Container Probes].
Depending on https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/[your Kubernetes configuration], the kubelet will call those probes and react to the result.
Depending on https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/[your Kubernetes configuration], the kubelet calls those probes and reacts to the result.
Spring Boot manages your <<features#features.spring-application.application-availability,Application Availability State>> out-of-the-box.
By default, Spring Boot manages your <<features#features.spring-application.application-availability,Application Availability State>>.
If deployed in a Kubernetes environment, actuator will gather the "Liveness" and "Readiness" information from the `ApplicationAvailability` interface and use that information in dedicated <<actuator#actuator.endpoints.health.auto-configured-health-indicators,Health Indicators>>: `LivenessStateHealthIndicator` and `ReadinessStateHealthIndicator`.
If deployed in a Kubernetes environment, actuator gathers the "`Liveness`" and "`Readiness`" information from the `ApplicationAvailability` interface and uses that information in dedicated <<actuator#actuator.endpoints.health.auto-configured-health-indicators,health indicators>>: `LivenessStateHealthIndicator` and `ReadinessStateHealthIndicator`.
These indicators will be shown on the global health endpoint (`"/actuator/health"`).
These indicators are shown on the global health endpoint (`"/actuator/health"`).
They will also be exposed as separate HTTP Probes using <<actuator#actuator.endpoints.health.groups, Health Groups>>: `"/actuator/health/liveness"` and `"/actuator/health/readiness"`.
They are also exposed as separate HTTP Probes by using <<actuator#actuator.endpoints.health.groups, health groups>>: `"/actuator/health/liveness"` and `"/actuator/health/readiness"`.
You can then configure your Kubernetes infrastructure with the following endpoint information:
You can then configure your Kubernetes infrastructure with the following endpoint information:
@ -1003,13 +1006,13 @@ readinessProbe:
----
----
NOTE: `<actuator-port>` should be set to the port that the actuator endpoints are available on.
NOTE: `<actuator-port>` should be set to the port that the actuator endpoints are available on.
It could be the main web server port, or a separate management port if the `"management.server.port"` property has been set.
It could be the main web server port or a separate management port if the `"management.server.port"` property has been set.
These health groups are only enabled automatically if the application is <<deployment#deployment.cloud.kubernetes,running in a Kubernetes environment>>.
These health groups are automatically enabled only if the application <<deployment#deployment.cloud.kubernetes,runs in a Kubernetes environment>>.
You can enable them in any environment using the configprop:management.endpoint.health.probes.enabled[] configuration property.
You can enable them in any environment by using the configprop:management.endpoint.health.probes.enabled[] configuration property.
NOTE: If an application takes longer to start than the configured liveness period, Kubernetes mention the `"startupProbe"` as a possible solution.
NOTE: If an application takes longer to start than the configured liveness period, Kubernetes mentions the `"startupProbe"` as a possible solution.
The `"startupProbe"` is not necessarily needed here as the `"readinessProbe"` fails until all startup tasks are done, see <<actuator#actuator.endpoints.kubernetes-probes.lifecycle,how Probes behave during the application lifecycle>>.
The `"startupProbe"` is not necessarily needed here, as the `"readinessProbe"` fails until all startup tasks are done. See the section that describes <<actuator#actuator.endpoints.kubernetes-probes.lifecycle,how probes behave during the application lifecycle>>.
If your Actuator endpoints are deployed on a separate management context, the endpoints do not use the same web infrastructure (port, connection pools, framework components) as the main application.
If your Actuator endpoints are deployed on a separate management context, the endpoints do not use the same web infrastructure (port, connection pools, framework components) as the main application.
In this case, a probe check could be successful even if the main application does not work properly (for example, it cannot accept new connections).
In this case, a probe check could be successful even if the main application does not work properly (for example, it cannot accept new connections).
@ -1028,7 +1031,8 @@ This would make `liveness` available at `/livez` and `readiness` at `readyz` on
==== Checking External State with Kubernetes Probes
==== Checking External State with Kubernetes Probes
Actuator configures the "liveness" and "readiness" probes as Health Groups; this means that all the <<actuator#actuator.endpoints.health.groups, Health Groups features>> are available for them.
Actuator configures the "`liveness`" and "`readiness`" probes as Health Groups.
This means that all the <<actuator#actuator.endpoints.health.groups, health groups features>> are available for them.
You can, for example, configure additional Health Indicators:
You can, for example, configure additional Health Indicators:
@ -1041,36 +1045,38 @@ You can, for example, configure additional Health Indicators:
include: "readinessState,customCheck"
include: "readinessState,customCheck"
----
----
By default, Spring Boot does not add other Health Indicators to these groups.
By default, Spring Boot does not add other health indicators to these groups.
The "`liveness`" Probe should not depend on health checks for external systems.
The "`liveness`" probe should not depend on health checks for external systems.
If the <<features#features.spring-application.application-availability.liveness,Liveness State of an application>> is broken, Kubernetes will try to solve that problem by restarting the application instance.
If the <<features#features.spring-application.application-availability.liveness,liveness state of an application>> is broken, Kubernetes tries to solve that problem by restarting the application instance.
This means that if an external system fails (e.g. a database, a Web API, an external cache), Kubernetes might restart all application instances and create cascading failures.
This means that if an external system (such as a database, a Web API, or an external cache) fails, Kubernetes might restart all application instances and create cascading failures.
As for the "`readiness`" Probe, the choice of checking external systems must be made carefully by the application developers, i.e. Spring Boot does not include any additional health checks in the readiness probe.
As for the "`readiness`" probe, the choice of checking external systems must be made carefully by the application developers.
If the <<features#features.spring-application.application-availability.readiness,Readiness State of an application instance>> is unready, Kubernetes will not route traffic to that instance.
For this reason, Spring Boot does not include any additional health checks in the readiness probe.
Some external systems might not be shared by application instances, in which case they could quite naturally be included in a readiness probe.
If the <<features#features.spring-application.application-availability.readiness,readiness state of an application instance>> is unready, Kubernetes does not route traffic to that instance.
Some external systems might not be shared by application instances, in which case they could be included in a readiness probe.
Other external systems might not be essential to the application (the application could have circuit breakers and fallbacks), in which case they definitely should not be included.
Other external systems might not be essential to the application (the application could have circuit breakers and fallbacks), in which case they definitely should not be included.
Unfortunately, an external system that is shared by all application instances is common, and you have to make a judgement call: include it in the readiness probe and expect that the application is taken out of service when the external service is down, or leave it out and deal with failures higher up the stack, e.g. using a circuit breaker in the caller.
Unfortunately, an external system that is shared by all application instances is common, and you have to make a judgement call: Include it in the readiness probe and expect that the application is taken out of service when the external service is down or leave it out and deal with failures higher up the stack, perhaps by using a circuit breaker in the caller.
NOTE: If all instances of an application are unready, a Kubernetes Service with `type=ClusterIP` or `NodePort` will not accept any incoming connections.
NOTE: If all instances of an application are unready, a Kubernetes Service with `type=ClusterIP` or `NodePort` does not accept any incoming connections.
There is no HTTP error response (503 etc.) since there is no connection.
There is no HTTP error response (503 and so on), since there is no connection.
A Service with `type=LoadBalancer` might or might not accept connections, depending on the provider.
A service with `type=LoadBalancer` might or might not accept connections, depending on the provider.
A Service that has an explicit https://kubernetes.io/docs/concepts/services-networking/ingress/[Ingress] will also respond in a way that depends on the implementation - the ingress service itself will have to decide how to handle the "connection refused" from downstream.
A service that has an explicit https://kubernetes.io/docs/concepts/services-networking/ingress/[ingress] also responds in a way that depends on the implementation -- the ingress service itself has to decide how to handle the "`connection refused`" from downstream.
HTTP 503 is quite likely in the case of both load balancer and ingress.
HTTP 503 is quite likely in the case of both load balancer and ingress.
Also, if an application is using Kubernetes https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/[autoscaling] it may react differently to applications being taken out of the load-balancer, depending on its autoscaler configuration.
Also, if an application uses Kubernetes https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/[autoscaling], it may react differently to applications being taken out of the load-balancer, depending on its autoscaler configuration.
An important aspect of the Kubernetes Probes support is its consistency with the application lifecycle.
An important aspect of the Kubernetes Probes support is its consistency with the application lifecycle.
There is a significant difference between the `AvailabilityState` which is the in-memory, internal state of the application
There is a significant difference between the `AvailabilityState` (which is the in-memory, internal state of the application)
and the actual Probe which exposes that state: depending on the phase of application lifecycle, the Probe might not be available.
and the actual probe (which exposes that state).
Depending on the phase of application lifecycle, the probe might not be available.
Spring Boot publishes <<features#features.spring-application.application-events-and-listeners,Application Events during startup and shutdown>>,
Spring Boot publishes <<features#features.spring-application.application-events-and-listeners,application events during startup and shutdown>>,
and Probes can listen to such events and expose the `AvailabilityState` information.
and probes can listen to such events and expose the `AvailabilityState` information.
The following tables show the `AvailabilityState` and the state of HTTP connectors at different stages.
The following tables show the `AvailabilityState` and the state of HTTP connectors at different stages.
@ -1124,7 +1130,7 @@ When a Spring Boot application shuts down:
|The application context is closed and the application is shut down.
|The application context is closed and the application is shut down.
|===
|===
TIP: Check out the <<deployment#deployment.cloud.kubernetes.container-lifecycle,Kubernetes container lifecycle section>> for more information about Kubernetes deployment.
TIP: See <<deployment#deployment.cloud.kubernetes.container-lifecycle,Kubernetes container lifecycle section>> for more information about Kubernetes deployment.
@ -1137,7 +1143,7 @@ Spring Boot includes a number of auto-configured `InfoContributor` beans, and yo
Another useful feature of the `info` endpoint is its ability to publish information about the state of your `git` source code repository when the project was built.
Another useful feature of the `info` endpoint is its ability to publish information about the state of your `git` source code repository when the project was built.
If a `GitProperties` bean is available, the `info` endpoint can be used to expose these properties.
If a `GitProperties` bean is available, you can use the `info` endpoint to expose these properties.
TIP: A `GitProperties` bean is auto-configured if a `git.properties` file is available at the root of the classpath.
TIP: A `GitProperties` bean is auto-configured if a `git.properties` file is available at the root of the classpath.
See "<<howto#howto.build.generate-git-info,Generate git information>>" for more details.
See "<<howto#howto.build.generate-git-info,how to generate git information>>" for more detail.
By default, the endpoint exposes `git.branch`, `git.commit.id`, and `git.commit.time` properties, if present.
By default, the endpoint exposes `git.branch`, `git.commit.id`, and `git.commit.time` properties, if present.
If you don't want any of these properties in the endpoint response, they need to be excluded from the `git.properties` file.
If you do not want any of these properties in the endpoint response, they need to be excluded from the `git.properties` file.
If you want to display the full git information (that is, the full content of `git.properties`), use the configprop:management.info.git.mode[] property, as follows:
If you want to display the full git information (that is, the full content of `git.properties`), use the configprop:management.info.git.mode[] property, as follows:
Java Management Extensions (JMX) provide a standard mechanism to monitor and manage applications.
Java Management Extensions (JMX) provide a standard mechanism to monitor and manage applications.
By default, this feature is not enabled and can be turned on by setting the configuration property configprop:spring.jmx.enabled[] to `true`.
By default, this feature is not enabled.
You can turn it on by setting the configprop:spring.jmx.enabled[] configuration property to `true`.
Spring Boot exposes the most suitable `MBeanServer` as a bean with an ID of `mbeanServer`.
Spring Boot exposes the most suitable `MBeanServer` as a bean with an ID of `mbeanServer`.
Any of your beans that are annotated with Spring JMX annotations (`@ManagedResource`, `@ManagedAttribute`, or `@ManagedOperation`) are exposed to it.
Any of your beans that are annotated with Spring JMX annotations (`@ManagedResource`, `@ManagedAttribute`, or `@ManagedOperation`) are exposed to it.
If your platform provides a standard `MBeanServer`, Spring Boot will use that and default to the VM `MBeanServer` if necessary.
If your platform provides a standard `MBeanServer`, Spring Boot uses that and defaults to the VM `MBeanServer`, if necessary.
If all that fails, a new `MBeanServer` will be created.
If all that fails, a new `MBeanServer` is created.
See the {spring-boot-autoconfigure-module-code}/jmx/JmxAutoConfiguration.java[`JmxAutoConfiguration`] class for more details.
See the {spring-boot-autoconfigure-module-code}/jmx/JmxAutoConfiguration.java[`JmxAutoConfiguration`] class for more details.
Spring Boot also exposes management endpoints as JMX MBeans under the `org.springframework.boot` domain by default.
By default, Spring Boot also exposes management endpoints as JMX MBeans under the `org.springframework.boot` domain.
To Take full control over endpoints registration in the JMX domain, consider registering your own `EndpointObjectNameFactory` implementation.
To take full control over endpoint registration in the JMX domain, consider registering your own `EndpointObjectNameFactory` implementation.
@ -41,7 +42,7 @@ The following settings show an example of doing so in `application.properties`:
[[actuator.jmx.disable-jmx-endpoints]]
[[actuator.jmx.disable-jmx-endpoints]]
=== Disabling JMX Endpoints
=== Disabling JMX Endpoints
If you do not want to expose endpoints over JMX, you can set the configprop:management.endpoints.jmx.exposure.exclude[] property to `*`, as shown in the following example:
If you do not want to expose endpoints over JMX, you can set the configprop:management.endpoints.jmx.exposure.exclude[] property to `*`, as the following example shows:
TIP: To learn more about Micrometer's capabilities, please refer to its https://micrometer.io/docs[reference documentation], in particular the {micrometer-concepts-docs}[concepts section].
TIP: To learn more about Micrometer's capabilities, see its https://micrometer.io/docs[reference documentation], in particular the {micrometer-concepts-docs}[concepts section].
@ -32,7 +32,7 @@ Having a dependency on `micrometer-registry-\{system}` in your runtime classpath
Most registries share common features.
Most registries share common features.
For instance, you can disable a particular registry even if the Micrometer registry implementation is on the classpath.
For instance, you can disable a particular registry even if the Micrometer registry implementation is on the classpath.
@ -54,7 +54,7 @@ You can also disable all registries unless stated otherwise by the registry-spec
enabled: false
enabled: false
----
----
Spring Boot will also add any auto-configured registries to the global static composite registry on the `Metrics` class unless you explicitly tell it not to:
Spring Boot also adds any auto-configured registries to the global static composite registry on the `Metrics` class, unless you explicitly tell it not to:
Spring Boot also <<actuator#actuator.metrics.supported,configures built-in instrumentation>> that you can control via configuration or dedicated annotation markers.
Spring Boot also <<actuator#actuator.metrics.supported,configures built-in instrumentation>> that you can control through configuration or dedicated annotation markers.
[[actuator.metrics.export]]
[[actuator.metrics.export]]
=== Supported Monitoring Systems
=== Supported Monitoring Systems
This section briefly describes each of the supported monitoring systems.
[[actuator.metrics.export.appoptics]]
[[actuator.metrics.export.appoptics]]
==== AppOptics
==== AppOptics
By default, the AppOptics registry pushes metrics to `https://api.appoptics.com/v1/measurements` periodically.
By default, the AppOptics registry periodically pushes metrics to `https://api.appoptics.com/v1/measurements`.
To export metrics to SaaS {micrometer-registry-docs}/appOptics[AppOptics], your API token must be provided:
To export metrics to SaaS {micrometer-registry-docs}/appOptics[AppOptics], your API token must be provided:
@ -148,26 +149,26 @@ You can also change the interval at which metrics are sent to Datadog:
[[actuator.metrics.export.dynatrace]]
[[actuator.metrics.export.dynatrace]]
==== Dynatrace
==== Dynatrace
Dynatrace offers two metrics ingest APIs, both of which are implemented for {micrometer-registry-docs}/dynatrace[Micrometer].
Dynatrace offers two metrics ingest APIs, both of which are implemented for {micrometer-registry-docs}/dynatrace[Micrometer].
Config properties in the `v1` namespace only apply when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API].
Configuration properties in the `v1` namespace apply only when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API].
Config properties in the `v2` namespace only apply when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API].
Configuration properties in the `v2` namespace apply only when exporting to the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API].
Please note that this integration can only export to either the `v1` or `v2` version of the API at a time.
Note that this integration can export only to either the `v1` or `v2` version of the API at a time.
If the `device-id` (required for v1, but not used in v2) is set in the `v1` namespace, metrics will be exported to the `v1` endpoint.
If the `device-id` (required for v1 but not used in v2) is set in the `v1` namespace, metrics are exported to the `v1` endpoint.
Otherwise, `v2` is assumed.
Otherwise, `v2` is assumed.
[[actuator.metrics.export.dynatrace.v2-api]]
[[actuator.metrics.export.dynatrace.v2-api]]
===== v2 API
===== v2 API
The v2 API can be used in two ways.
You can use the v2 API in two ways.
If a local OneAgent is running on the host, metrics will be automatically exported to the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/local-api/[local OneAgent ingest endpoint].
If a local OneAgent is running on the host, metrics are automatically exported to the {dynatrace-help}/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/local-api/[local OneAgent ingest endpoint].
The ingest endpoint forwards the metrics to the Dynatrace backend.
The ingest endpoint forwards the metrics to the Dynatrace backend.
This is the default behaviour and requires no special setup beyond a dependency on `io.micrometer:micrometer-registry-dynatrace`.
This is the default behavior and requires no special setup beyond a dependency on `io.micrometer:micrometer-registry-dynatrace`.
If no local OneAgent is running, the endpoint of the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API] and an API token are required.
If no local OneAgent is running, the endpoint of the {dynatrace-help}/dynatrace-api/environment-api/metric-v2/post-ingest-metrics/[Metrics v2 API] and an API token are required.
The {dynatrace-help}/dynatrace-api/basics/dynatrace-api-authentication/[API token] must have the "Ingest metrics" (`metrics.ingest`) permission set.
The {dynatrace-help}/dynatrace-api/basics/dynatrace-api-authentication/[API token] must have the "`Ingest metrics`" (`metrics.ingest`) permission set.
It is recommended to limit the scope of the token to this one permission.
We recommend limiting the scope of the token to this one permission.
Please ensure that the endpoint URI contains the path (e.g. `/api/v2/metrics/ingest`).
You must ensure that the endpoint URI contains the path (for example, `/api/v2/metrics/ingest`):
@ -182,11 +183,10 @@ Please ensure that the endpoint URI contains the path (e.g. `/api/v2/metrics/ing
When using the Dynatrace v2 API, the following optional features are available:
When using the Dynatrace v2 API, the following optional features are available:
* Metric key prefix: sets a prefix that will be prepended to all exported metric keys.
* Metric key prefix: Sets a prefix that is prepended to all exported metric keys.
* Enrich with Dynatrace metadata: if a OneAgent or Dynatrace operator is running, enrich metrics with additional metadata (e.g. about the host, process or pod).
* Enrich with Dynatrace metadata: If a OneAgent or Dynatrace operator is running, enrich metrics with additional metadata (for example, about the host, process, or pod).
* Default dimensions: specify key-value pairs that are added to all exported metrics.
* Default dimensions: Specify key-value pairs that are added to all exported metrics.
If tags with the same key are specified using Micrometer, they overwrite the default dimensions.
If tags with the same key are specified with Micrometer, they overwrite the default dimensions.
@ -207,8 +207,8 @@ When using the Dynatrace v2 API, the following optional features are available:
[[actuator.metrics.export.dynatrace.v1-api]]
[[actuator.metrics.export.dynatrace.v1-api]]
===== v1 API (Legacy)
===== v1 API (Legacy)
The Dynatrace v1 API metrics registry pushes metrics to the configured URI periodically using the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API].
The Dynatrace v1 API metrics registry pushes metrics to the configured URI periodically by using the {dynatrace-help}/dynatrace-api/environment-api/metric-v1/[Timeseries v1 API].
For backwards-compatibility with existing setups, when `device-id` is set (required for v1, but not used in v2), metrics will be exported to the Timeseries v1 endpoint.
For backwards-compatibility with existing setups, when `device-id` is set (required for v1, but not used in v2), metrics are exported to the Timeseries v1 endpoint.
To export metrics to {micrometer-registry-docs}/dynatrace[Dynatrace], your API token, device ID, and URI must be provided:
To export metrics to {micrometer-registry-docs}/dynatrace[Dynatrace], your API token, device ID, and URI must be provided:
@ -242,14 +243,14 @@ The default export interval is `60s`.
step: "30s"
step: "30s"
----
----
More information on how to set up the Dynatrace exporter for Micrometer can be found in {micrometer-registry-docs}/dynatrace[the Micrometer documentation].
You can find more information on how to set up the Dynatrace exporter for Micrometer in {micrometer-registry-docs}/dynatrace[the Micrometer documentation].
[[actuator.metrics.export.elastic]]
[[actuator.metrics.export.elastic]]
==== Elastic
==== Elastic
By default, metrics are exported to {micrometer-registry-docs}/elastic[Elastic] running on your local machine.
By default, metrics are exported to {micrometer-registry-docs}/elastic[Elastic] running on your local machine.
The location of the Elastic server to use can be provided using the following property:
You can provide the location of the Elastic server to use by using the following property:
@ -292,22 +293,25 @@ The https://graphiteapp.org[Graphite server] host and port to use can be provide
port: 9004
port: 9004
----
----
Micrometer provides a default `HierarchicalNameMapper` that governs how a dimensional meter id is {micrometer-registry-docs}/graphite#_hierarchical_name_mapping[mapped to flat hierarchical names].
Micrometer provides a default `HierarchicalNameMapper` that governs how a dimensional meter ID is {micrometer-registry-docs}/graphite#_hierarchical_name_mapping[mapped to flat hierarchical names].
TIP: To take control over this behavior, define your `GraphiteMeterRegistry` and supply your own `HierarchicalNameMapper`.
[TIP]
====
To take control over this behavior, define your `GraphiteMeterRegistry` and supply your own `HierarchicalNameMapper`.
An auto-configured `GraphiteConfig` and `Clock` beans are provided unless you define your own:
An auto-configured `GraphiteConfig` and `Clock` beans are provided unless you define your own:
@ -337,7 +341,7 @@ You should also configure one or more tags to identify the data source to which
==== Influx
==== Influx
By default, metrics are exported to an {micrometer-registry-docs}/influx[Influx] v1 instance running on your local machine with the default configuration.
By default, metrics are exported to an {micrometer-registry-docs}/influx[Influx] v1 instance running on your local machine with the default configuration.
To export metrics to InfluxDB v2, configure the `org`, `bucket`, and authentication `token` for writing metrics.
To export metrics to InfluxDB v2, configure the `org`, `bucket`, and authentication `token` for writing metrics.
The location of the https://www.influxdata.com[Influx server] to use can be provided using:
You can provide the location of the https://www.influxdata.com[Influx server] to use by using:
@ -365,22 +369,25 @@ The domain to use can be provided using:
domain: "com.example.app.metrics"
domain: "com.example.app.metrics"
----
----
Micrometer provides a default `HierarchicalNameMapper` that governs how a dimensional meter id is {micrometer-registry-docs}/jmx#_hierarchical_name_mapping[mapped to flat hierarchical names].
Micrometer provides a default `HierarchicalNameMapper` that governs how a dimensional meter ID is {micrometer-registry-docs}/jmx#_hierarchical_name_mapping[mapped to flat hierarchical names].
TIP: To take control over this behavior, define your `JmxMeterRegistry` and supply your own `HierarchicalNameMapper`.
[TIP]
====
To take control over this behavior, define your `JmxMeterRegistry` and supply your own `HierarchicalNameMapper`.
An auto-configured `JmxConfig` and `Clock` beans are provided unless you define your own:
An auto-configured `JmxConfig` and `Clock` beans are provided unless you define your own:
@ -436,12 +443,12 @@ Finally, you can take full control by defining your own `NewRelicClientProvider`
[[actuator.metrics.export.prometheus]]
[[actuator.metrics.export.prometheus]]
==== Prometheus
==== Prometheus
{micrometer-registry-docs}/prometheus[Prometheus] expects to scrape or poll individual app instances for metrics.
{micrometer-registry-docs}/prometheus[Prometheus] expects to scrape or poll individual application instances for metrics.
Spring Boot provides an actuator endpoint available at `/actuator/prometheus` to present a https://prometheus.io[Prometheus scrape] with the appropriate format.
Spring Boot provides an actuator endpoint at `/actuator/prometheus` to present a https://prometheus.io[Prometheus scrape] with the appropriate format.
TIP: The endpoint is not available by default and must be exposed, see <<actuator#actuator.endpoints.exposing,exposing endpoints>> for more details.
TIP: By default, the endpoint is not available and must be exposed. See <<actuator#actuator.endpoints.exposing,exposing endpoints>> for more details.
Here is an example `scrape_config` to add to `prometheus.yml`:
The following example `scrape_config` adds to `prometheus.yml`:
[source,yaml,indent=0,subs="verbatim"]
[source,yaml,indent=0,subs="verbatim"]
----
----
@ -452,7 +459,7 @@ Here is an example `scrape_config` to add to `prometheus.yml`:
- targets: ['HOST:PORT']
- targets: ['HOST:PORT']
----
----
For ephemeral or batch jobs which may not exist long enough to be scraped, https://github.com/prometheus/pushgateway[Prometheus Pushgateway] support can be used to expose their metrics to Prometheus.
For ephemeral or batch jobs that may not exist long enough to be scraped, you can use https://github.com/prometheus/pushgateway[Prometheus Pushgateway] support to expose the metrics to Prometheus.
To enable Prometheus Pushgateway support, add the following dependency to your project:
To enable Prometheus Pushgateway support, add the following dependency to your project:
[source,xml,indent=0,subs="verbatim"]
[source,xml,indent=0,subs="verbatim"]
@ -466,15 +473,15 @@ To enable Prometheus Pushgateway support, add the following dependency to your p
When the Prometheus Pushgateway dependency is present on the classpath and the configprop:management.metrics.export.prometheus.pushgateway.enabled[] property is set to `true`, a `PrometheusPushGatewayManager` bean is auto-configured.
When the Prometheus Pushgateway dependency is present on the classpath and the configprop:management.metrics.export.prometheus.pushgateway.enabled[] property is set to `true`, a `PrometheusPushGatewayManager` bean is auto-configured.
This manages the pushing of metrics to a Prometheus Pushgateway.
This manages the pushing of metrics to a Prometheus Pushgateway.
The `PrometheusPushGatewayManager` can be tuned using properties under `management.metrics.export.prometheus.pushgateway`.
You can tune the `PrometheusPushGatewayManager` by using properties under `management.metrics.export.prometheus.pushgateway`.
For advanced configuration, you can also provide your own `PrometheusPushGatewayManager` bean.
For advanced configuration, you can also provide your own `PrometheusPushGatewayManager` bean.
[[actuator.metrics.export.signalfx]]
[[actuator.metrics.export.signalfx]]
==== SignalFx
==== SignalFx
SignalFx registry pushes metrics to {micrometer-registry-docs}/signalFx[SignalFx] periodically.
SignalFx registry periodically pushes metrics to {micrometer-registry-docs}/signalFx[SignalFx].
To export metrics to https://www.signalfx.com[SignalFx], your access token must be provided:
To export metrics to https://www.signalfx.com[SignalFx], you must provide your access token:
@ -599,7 +606,7 @@ Alternatively, you may use a Wavefront sidecar or an internal proxy set up in yo
uri: "proxy://localhost:2878"
uri: "proxy://localhost:2878"
----
----
TIP: If publishing metrics to a Wavefront proxy (as described in https://docs.wavefront.com/proxies_installing.html[the documentation]), the host must be in the `proxy://HOST:PORT` format.
NOTE: If you publish metrics to a Wavefront proxy (as described in https://docs.wavefront.com/proxies_installing.html[the Wavefront documentation]), the host must be in the `proxy://HOST:PORT` format.
You can also change the interval at which metrics are sent to Wavefront:
You can also change the interval at which metrics are sent to Wavefront:
@ -617,34 +624,34 @@ You can also change the interval at which metrics are sent to Wavefront:
[[actuator.metrics.supported]]
[[actuator.metrics.supported]]
=== Supported Metrics and Meters
=== Supported Metrics and Meters
Spring Boot provides automatic meter registration for a wide variety of technologies.
Spring Boot provides automatic meter registration for a wide variety of technologies.
In most situations, the out-of-the-box defaults will provide sensible metrics that can be published to any of the supported monioring systems.
In most situations, the defaults provide sensible metrics that can be published to any of the supported monitoring systems.
[[actuator.metrics.supported.jvm]]
[[actuator.metrics.supported.jvm]]
==== JVM Metrics
==== JVM Metrics
Auto-configuration will enable JVM Metrics using core Micrometer classes.
Auto-configuration enables JVM Metrics by using core Micrometer classes.
JVM metrics are published under the `jvm.` meter name.
JVM metrics are published under the `jvm.` meter name.
The following JVM metrics are provided:
The following JVM metrics are provided:
* Various memory and buffer pool details
* Various memory and buffer pool details
* Statistics related to garbage collection
* Statistics related to garbage collection
* Threads utilization
* Thread utilization
* The Number of classes loaded/unloaded
* The number of classes loaded and unloaded
[[actuator.metrics.supported.system]]
[[actuator.metrics.supported.system]]
==== System Metrics
==== System Metrics
Auto-configuration will enable system metrics using core Micrometer classes.
Auto-configuration enables system metrics by using core Micrometer classes.
System metrics are published under the `system.`, `process.`, and `disk.` meter names.
System metrics are published under the `system.`, `process.`, and `disk.` meter names.
The following system metrics are provided:
The following system metrics are provided:
* CPU metrics
* CPU metrics
* File descriptor metrics
* File descriptor metrics
* Uptime metrics (both the amount of time the application has been running as well as a fixed gauge of the absolute start time)
* Uptime metrics (both the amount of time the application has been running and a fixed gauge of the absolute start time)
* Disk space available
* Disk space available
@ -652,14 +659,14 @@ The following system metrics are provided:
[[actuator.metrics.supported.logger]]
[[actuator.metrics.supported.logger]]
==== Logger Metrics
==== Logger Metrics
Auto-configuration enables the event metrics for both Logback and Log4J2.
Auto-configuration enables the event metrics for both Logback and Log4J2.
Details are published under the `log4j2.events.` or `logback.events.` meter names.
The details are published under the `log4j2.events.` or `logback.events.` meter names.
[[actuator.metrics.supported.tasks]]
[[actuator.metrics.supported.tasks]]
==== Task Execution and Scheduling Metrics
==== Task Execution and Scheduling Metrics
Auto-configuration enables the instrumentation of all available `ThreadPoolTaskExecutor` and `ThreadPoolTaskScheduler` beans, as long as the underling `ThreadPoolExecutor` is available.
Auto-configuration enables the instrumentation of all available `ThreadPoolTaskExecutor` and `ThreadPoolTaskScheduler` beans, as long as the underling `ThreadPoolExecutor` is available.
Metrics are tagged by the name of the executor that is derived from the bean name.
Metrics are tagged by the name of the executor, which is derived from the bean name.
@ -667,10 +674,10 @@ Metrics are tagged by the name of the executor that is derived from the bean nam
==== Spring MVC Metrics
==== Spring MVC Metrics
Auto-configuration enables the instrumentation of all requests handled by Spring MVC controllers and functional handlers.
Auto-configuration enables the instrumentation of all requests handled by Spring MVC controllers and functional handlers.
By default, metrics are generated with the name, `http.server.requests`.
By default, metrics are generated with the name, `http.server.requests`.
The name can be customized by setting the configprop:management.metrics.web.server.request.metric-name[] property.
You can customized the name by setting the configprop:management.metrics.web.server.request.metric-name[] property.
`@Timed` annotations are supported on `@Controller` classes and `@RequestMapping` methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
`@Timed` annotations are supported on `@Controller` classes and `@RequestMapping` methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
If you don't want to record metrics for all Spring MVC requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
If you do not want to record metrics for all Spring MVC requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
By default, Spring MVC related metrics are tagged with the following information:
By default, Spring MVC related metrics are tagged with the following information:
@ -678,27 +685,27 @@ By default, Spring MVC related metrics are tagged with the following information
| Tag | Description
| Tag | Description
| `exception`
| `exception`
| 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.
| `method`
| `method`
| Request's method (for example, `GET` or `POST`)
| The request's method (for example, `GET` or `POST`)
| `outcome`
| `outcome`
| Request's outcome based on the status code of the response.
| The request's outcome, based on the status code of the response.
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx is `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
| `status`
| `status`
| Response's HTTP status code (for example, `200` or `500`)
| The response's HTTP status code (for example, `200` or `500`)
| `uri`
| `uri`
| Request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
| The request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
|===
|===
To add to the default tags, provide one or more ``@Bean``s that implement `WebMvcTagsContributor`.
To add to the default tags, provide one or more ``@Bean``s that implement `WebMvcTagsContributor`.
To replace the default tags, provide a `@Bean` that implements `WebMvcTagsProvider`.
To replace the default tags, provide a `@Bean` that implements `WebMvcTagsProvider`.
TIP: In some cases, exceptions handled in Web controllers are not recorded as request metrics tags.
TIP: In some cases, exceptions handled in web controllers are not recorded as request metrics tags.
Applications can opt-in and record exceptions by <<web#web.servlet.spring-mvc.error-handling, setting handled exceptions as request attributes>>.
Applications can optin and record exceptions by <<web#web.servlet.spring-mvc.error-handling, setting handled exceptions as request attributes>>.
@ -706,10 +713,10 @@ Applications can opt-in and record exceptions by <<web#web.servlet.spring-mvc.er
==== Spring WebFlux Metrics
==== Spring WebFlux Metrics
Auto-configuration enables the instrumentation of all requests handled by Spring WebFlux controllers and functional handlers.
Auto-configuration enables the instrumentation of all requests handled by Spring WebFlux controllers and functional handlers.
By default, metrics are generated with the name, `http.server.requests`.
By default, metrics are generated with the name, `http.server.requests`.
The name can be customized by setting the configprop:management.metrics.web.server.request.metric-name[] property.
You can customize the name by setting the configprop:management.metrics.web.server.request.metric-name[] property.
`@Timed` annotations are supported on `@Controller` classes and `@RequestMapping` methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
`@Timed` annotations are supported on `@Controller` classes and `@RequestMapping` methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
If you don't want to record metrics for all Spring WebFlux requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
If you do not want to record metrics for all Spring WebFlux requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
By default, WebFlux related metrics are tagged with the following information:
By default, WebFlux related metrics are tagged with the following information:
@ -717,27 +724,27 @@ By default, WebFlux related metrics are tagged with the following information:
| Tag | Description
| Tag | Description
| `exception`
| `exception`
| 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.
| `method`
| `method`
| Request's method (for example, `GET` or `POST`)
| The request's method (for example, `GET` or `POST`)
| `outcome`
| `outcome`
| Request's outcome based on the status code of the response.
| The request's outcome, based on the status code of the response.
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx is `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
| `status`
| `status`
| Response's HTTP status code (for example, `200` or `500`)
| The response's HTTP status code (for example, `200` or `500`)
| `uri`
| `uri`
| Request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
| The request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
|===
|===
To add to the default tags, provide one or more ``@Bean``s that implement `WebFluxTagsContributor`.
To add to the default tags, provide one or more beans that implement `WebFluxTagsContributor`.
To replace the default tags, provide a `@Bean` that implements `WebFluxTagsProvider`.
To replace the default tags, provide a bean that implements `WebFluxTagsProvider`.
TIP: In some cases, exceptions handled in controllers and handler functions are not recorded as request metrics tags.
TIP: In some cases, exceptions handled in controllers and handler functions are not recorded as request metrics tags.
Applications can opt-in and record exceptions by <<web#web.reactive.webflux.error-handling, setting handled exceptions as request attributes>>.
Applications can optin and record exceptions by <<web#web.reactive.webflux.error-handling, setting handled exceptions as request attributes>>.
@ -745,10 +752,10 @@ Applications can opt-in and record exceptions by <<web#web.reactive.webflux.erro
==== Jersey Server Metrics
==== Jersey Server Metrics
Auto-configuration enables the instrumentation of all requests handled by the Jersey JAX-RS implementation whenever Micrometer's `micrometer-jersey2` module is on the classpath.
Auto-configuration enables the instrumentation of all requests handled by the Jersey JAX-RS implementation whenever Micrometer's `micrometer-jersey2` module is on the classpath.
By default, metrics are generated with the name, `http.server.requests`.
By default, metrics are generated with the name, `http.server.requests`.
The name can be customized by setting the configprop:management.metrics.web.server.request.metric-name[] property.
You can customize the name by setting the configprop:management.metrics.web.server.request.metric-name[] property.
`@Timed` annotations are supported on request-handling classes and methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
`@Timed` annotations are supported on request-handling classes and methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
If you don't want to record metrics for all Jersey requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
If you do not want to record metrics for all Jersey requests, you can set configprop:management.metrics.web.server.request.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
By default, Jersey server metrics are tagged with the following information:
By default, Jersey server metrics are tagged with the following information:
@ -756,20 +763,20 @@ By default, Jersey server metrics are tagged with the following information:
| Tag | Description
| Tag | Description
| `exception`
| `exception`
| 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.
| `method`
| `method`
| Request's method (for example, `GET` or `POST`)
| The request's method (for example, `GET` or `POST`)
| `outcome`
| `outcome`
| Request's outcome based on the status code of the response.
| The request's outcome, based on the status code of the response.
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx is `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`
| `status`
| `status`
| Response's HTTP status code (for example, `200` or `500`)
| The response's HTTP status code (for example, `200` or `500`)
| `uri`
| `uri`
| Request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
| The request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
|===
|===
To customize the tags, provide a `@Bean` that implements `JerseyTagsProvider`.
To customize the tags, provide a `@Bean` that implements `JerseyTagsProvider`.
@ -784,10 +791,10 @@ For that, you have to inject the auto-configured builder and use it to create in
* `RestTemplateBuilder` for `RestTemplate`
* `RestTemplateBuilder` for `RestTemplate`
* `WebClient.Builder` for `WebClient`
* `WebClient.Builder` for `WebClient`
It is also possible to apply manually the customizers responsible for this instrumentation, namely `MetricsRestTemplateCustomizer` and `MetricsWebClientCustomizer`.
You can also manually apply the customizers responsible for this instrumentation, namely `MetricsRestTemplateCustomizer` and `MetricsWebClientCustomizer`.
By default, metrics are generated with the name, `http.client.requests`.
By default, metrics are generated with the name, `http.client.requests`.
The name can be customized by setting the configprop:management.metrics.web.client.request.metric-name[] property.
You can customize the name by setting the configprop:management.metrics.web.client.request.metric-name[] property.
By default, metrics generated by an instrumented client are tagged with the following information:
By default, metrics generated by an instrumented client are tagged with the following information:
@ -795,20 +802,20 @@ By default, metrics generated by an instrumented client are tagged with the foll
| Tag | Description
| Tag | Description
| `clientName`
| `clientName`
| Host portion of the URI
| The host portion of the URI
| `method`
| `method`
| Request's method (for example, `GET` or `POST`)
| The request's method (for example, `GET` or `POST`)
| `outcome`
| `outcome`
| Request's outcome based on the status code of the response.
| The request's outcome, based on the status code of the response.
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`, `UNKNOWN` otherwise
1xx is `INFORMATIONAL`, 2xx is `SUCCESS`, 3xx is `REDIRECTION`, 4xx is `CLIENT_ERROR`, and 5xx is `SERVER_ERROR`. Otherwise, it is `UNKNOWN`.
| `status`
| `status`
| Response's HTTP status code if available (for example, `200` or `500`), or `IO_ERROR` in case of I/O issues, `CLIENT_ERROR` otherwise
| The response's HTTP status code if available (for example, `200` or `500`) or `IO_ERROR` in case of I/O issues. Otherwise, it is `CLIENT_ERROR`.
| `uri`
| `uri`
| Request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
| The request's URI template prior to variable substitution, if possible (for example, `/api/person/\{id}`)
|===
|===
To customize the tags, and depending on your choice of client, you can provide a `@Bean` that implements `RestTemplateExchangeTagsProvider` or `WebClientExchangeTagsProvider`.
To customize the tags, and depending on your choice of client, you can provide a `@Bean` that implements `RestTemplateExchangeTagsProvider` or `WebClientExchangeTagsProvider`.
@ -818,7 +825,7 @@ There are convenience static functions in `RestTemplateExchangeTags` and `WebCli
[[actuator.metrics.supported.tomcat]]
[[actuator.metrics.supported.tomcat]]
==== Tomcat Metrics
==== Tomcat Metrics
Auto-configuration will enable the instrumentation of Tomcat only when an `MBeanRegistry` is enabled.
Auto-configuration enables the instrumentation of Tomcat only when an `MBeanRegistry` is enabled.
By default, the `MBeanRegistry` is disabled, but you can enable it by setting configprop:server.tomcat.mbeanregistry.enabled[] to `true`.
By default, the `MBeanRegistry` is disabled, but you can enable it by setting configprop:server.tomcat.mbeanregistry.enabled[] to `true`.
Tomcat metrics are published under the `tomcat.` meter name.
Tomcat metrics are published under the `tomcat.` meter name.
@ -827,7 +834,7 @@ Tomcat metrics are published under the `tomcat.` meter name.
[[actuator.metrics.supported.cache]]
[[actuator.metrics.supported.cache]]
==== Cache Metrics
==== Cache Metrics
Auto-configuration enables the instrumentation of all available ``Cache``s on startup with metrics prefixed with `cache`.
Auto-configuration enables the instrumentation of all available `Cache` instances on startup, with metrics prefixed with `cache`.
Cache instrumentation is standardized for a basic set of metrics.
Cache instrumentation is standardized for a basic set of metrics.
Additional, cache-specific metrics are also available.
Additional, cache-specific metrics are also available.
@ -839,10 +846,10 @@ The following cache libraries are supported:
* Any compliant JCache (JSR-107) implementation
* Any compliant JCache (JSR-107) implementation
* Redis
* Redis
Metrics are tagged by the name of the cache and by the name of the `CacheManager` that is derived from the bean name.
Metrics are tagged by the name of the cache and by the name of the `CacheManager`, which is derived from the bean name.
NOTE: Only caches that are configured on startup are bound to the registry.
NOTE: Only caches that are configured on startup are bound to the registry.
For caches not defined in the cache’s configuration, e.g. caches created on-the-fly or programmatically after the startup phase, an explicit registration is required.
For caches not defined in the cache’s configuration, such as caches created on the fly or programmatically after the startup phase, an explicit registration is required.
A `CacheMetricsRegistrar` bean is made available to make that process easier.
A `CacheMetricsRegistrar` bean is made available to make that process easier.
@ -850,15 +857,16 @@ A `CacheMetricsRegistrar` bean is made available to make that process easier.
[[actuator.metrics.supported.jdbc]]
[[actuator.metrics.supported.jdbc]]
==== DataSource Metrics
==== DataSource Metrics
Auto-configuration enables the instrumentation of all available `DataSource` objects with metrics prefixed with `jdbc.connections`.
Auto-configuration enables the instrumentation of all available `DataSource` objects with metrics prefixed with `jdbc.connections`.
Data source instrumentation results in gauges representing the currently active, idle, maximum allowed, and minimum allowed connections in the pool.
Data source instrumentation results in gauges that represent the currently active, idle, maximum allowed, and minimum allowed connections in the pool.
Metrics are also tagged by the name of the `DataSource` computed based on the bean name.
Metrics are also tagged by the name of the `DataSource` computed based on the bean name.
TIP: By default, Spring Boot provides metadata for all supported data sources; you can add additional `DataSourcePoolMetadataProvider` beans if your favorite data source isn't supported out of the box.
TIP: By default, Spring Boot provides metadata for all supported data sources.
You can add additional `DataSourcePoolMetadataProvider` beans if your favorite data source is not supported.
See `DataSourcePoolMetadataProvidersConfiguration` for examples.
See `DataSourcePoolMetadataProvidersConfiguration` for examples.
Also, Hikari-specific metrics are exposed with a `hikaricp` prefix.
Also, Hikari-specific metrics are exposed with a `hikaricp` prefix.
Each metric is tagged by the name of the Pool (can be controlled with `spring.datasource.name`).
Each metric is tagged by the name of the pool (you can control it with `spring.datasource.name`).
@ -866,10 +874,10 @@ Each metric is tagged by the name of the Pool (can be controlled with `spring.da
==== Hibernate Metrics
==== Hibernate Metrics
If `org.hibernate:hibernate-micrometer` is on the classpath, all available Hibernate `EntityManagerFactory` instances that have statistics enabled are instrumented with a metric named `hibernate`.
If `org.hibernate:hibernate-micrometer` is on the classpath, all available Hibernate `EntityManagerFactory` instances that have statistics enabled are instrumented with a metric named `hibernate`.
Metrics are also tagged by the name of the `EntityManagerFactory` that is derived from the bean name.
Metrics are also tagged by the name of the `EntityManagerFactory`, which is derived from the bean name.
To enable statistics, the standard JPA property `hibernate.generate_statistics` must be set to `true`.
To enable statistics, the standard JPA property `hibernate.generate_statistics` must be set to `true`.
You can enable that on the auto-configured `EntityManagerFactory` as shown in the following example:
You can enable that on the auto-configured `EntityManagerFactory`:
@ -885,10 +893,10 @@ You can enable that on the auto-configured `EntityManagerFactory` as shown in th
==== Spring Data Repository Metrics
==== Spring Data Repository Metrics
Auto-configuration enables the instrumentation of all Spring Data `Repository` method invocations.
Auto-configuration enables the instrumentation of all Spring Data `Repository` method invocations.
By default, metrics are generated with the name, `spring.data.repository.invocations`.
By default, metrics are generated with the name, `spring.data.repository.invocations`.
The name can be customized by setting the configprop:management.metrics.data.repository.metric-name[] property.
You can customize the name by setting the configprop:management.metrics.data.repository.metric-name[] property.
`@Timed` annotations are supported on `Repository` classes and methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
`@Timed` annotations are supported on `Repository` classes and methods (see <<actuator#actuator.metrics.supported.timed-annotation>> for details).
If you don't want to record metrics for all `Repository` invocations, you can set configprop:management.metrics.data.repository.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
If you do not want to record metrics for all `Repository` invocations, you can set configprop:management.metrics.data.repository.autotime.enabled[] to `false` and exclusively use `@Timed` annotations instead.
By default, repository invocation related metrics are tagged with the following information:
By default, repository invocation related metrics are tagged with the following information:
@ -896,16 +904,16 @@ By default, repository invocation related metrics are tagged with the following
| Tag | Description
| Tag | Description
| `repository`
| `repository`
| Simple class name of the source `Repository`.
| The simple class name of the source `Repository`.
| `method`
| `method`
| The name of the `Repository` method that was invoked.
| The name of the `Repository` method that was invoked.
| `state`
| `state`
| The result state (`SUCCESS`, `ERROR`, `CANCELED` or `RUNNING`).
| The result state (`SUCCESS`, `ERROR`, `CANCELED`, or `RUNNING`).
| `exception`
| `exception`
| Simple class name of any exception that was thrown from the invocation.
| The simple class name of any exception that was thrown from the invocation.
|===
|===
To replace the default tags, provide a `@Bean` that implements `RepositoryTagsProvider`.
To replace the default tags, provide a `@Bean` that implements `RepositoryTagsProvider`.
@ -914,53 +922,54 @@ To replace the default tags, provide a `@Bean` that implements `RepositoryTagsPr
[[actuator.metrics.supported.rabbitmq]]
[[actuator.metrics.supported.rabbitmq]]
==== RabbitMQ Metrics
==== RabbitMQ Metrics
Auto-configuration will enable the instrumentation of all available RabbitMQ connection factories with a metric named `rabbitmq`.
Auto-configuration enables the instrumentation of all available RabbitMQ connection factories with a metric named `rabbitmq`.
[[actuator.metrics.supported.spring-integration]]
[[actuator.metrics.supported.spring-integration]]
==== Spring Integration Metrics
==== Spring Integration Metrics
Spring Integration provides {spring-integration-docs}system-management.html#micrometer-integration[Micrometer support] automatically whenever a `MeterRegistry` bean is available.
Spring Integration automatically provides {spring-integration-docs}system-management.html#micrometer-integration[Micrometer support] whenever a `MeterRegistry` bean is available.
Metrics are published under the `spring.integration.` meter name.
Metrics are published under the `spring.integration.` meter name.
[[actuator.metrics.supported.kafka]]
[[actuator.metrics.supported.kafka]]
==== Kafka Metrics
==== Kafka Metrics
Auto-configuration will register a `MicrometerConsumerListener` and `MicrometerProducerListener` for the auto-configured consumer factory and producer factory respectively.
Auto-configuration registers a `MicrometerConsumerListener` and `MicrometerProducerListener` for the auto-configured consumer factory and producer factory, respectively.
It will also register a `KafkaStreamsMicrometerListener` for `StreamsBuilderFactoryBean`.
It alsos registers a `KafkaStreamsMicrometerListener` for `StreamsBuilderFactoryBean`.
For more details refer to {spring-kafka-docs}#micrometer-native[Micrometer Native Metrics] section of the Spring Kafka documentation.
For more detail, see the {spring-kafka-docs}#micrometer-native[Micrometer Native Metrics] section of the Spring Kafka documentation.
[[actuator.metrics.supported.mongodb]]
[[actuator.metrics.supported.mongodb]]
==== MongoDB Metrics
==== MongoDB Metrics
This section briefly describes the available metrics for MongoDB.
[[actuator.metrics.supported.mongodb.command]]
[[actuator.metrics.supported.mongodb.command]]
===== Command Metrics
===== MongoDB Command Metrics
Auto-configuration will register a `MongoMetricsCommandListener` with the auto-configured `MongoClient`.
Auto-configuration registers a `MongoMetricsCommandListener` with the auto-configured `MongoClient`.
A timer metric with the name `mongodb.driver.commands` is created for each command issued to the underlying MongoDB driver.
A timer metric named `mongodb.driver.commands` is created for each command issued to the underlying MongoDB driver.
Each metric is tagged with the following information by default:
Each metric is tagged with the following information by default:
|===
|===
| Tag | Description
| Tag | Description
| `command`
| `command`
| Name of the command issued
| The name of the command issued.
| `cluster.id`
| `cluster.id`
| Identifier of the cluster the command was sent to
| The identifier of the cluster to which the command was sent.
| `server.address`
| `server.address`
| Address of the server the command was sent to
| The address of the server to which the command was sent.
| `status`
| `status`
| Outcome of the command - one of (`SUCCESS`, `FAILED`)
| The outcome of the command (`SUCCESS` or `FAILED`).
|===
|===
To replace the default metric tags, define a `MongoCommandTagsProvider` bean, as shown in the following example:
To replace the default metric tags, define a `MongoCommandTagsProvider` bean, as the following example shows:
[source,java,indent=0,subs="verbatim"]
[source,java,indent=0,subs="verbatim"]
----
----
@ -981,27 +990,27 @@ To disable the auto-configured command metrics, set the following property:
Auto-configuration will register a `MongoMetricsConnectionPoolListener` with the auto-configured `MongoClient`.
Auto-configuration registers a `MongoMetricsConnectionPoolListener` with the auto-configured `MongoClient`.
The following gauge metrics are created for the connection pool:
The following gauge metrics are created for the connection pool:
* `mongodb.driver.pool.size` that reports the current size of the connection pool, including idle and and in-use members
* `mongodb.driver.pool.size` reports the current size of the connection pool, including idle and and in-use members.
* `mongodb.driver.pool.checkedout` that reports the count of connections that are currently in use
* `mongodb.driver.pool.checkedout` reports the count of connections that are currently in use.
* `mongodb.driver.pool.waitqueuesize` that reports the current size of the wait queue for a connection from the pool
* `mongodb.driver.pool.waitqueuesize` reports the current size of the wait queue for a connection from the pool.
Each metric is tagged with the following information by default:
Each metric is tagged with the following information by default:
|===
|===
| Tag | Description
| Tag | Description
| `cluster.id`
| `cluster.id`
| Identifier of the cluster the connection pool corresponds to
| The identifier of the cluster to which the connection pool corresponds.
| `server.address`
| `server.address`
| Address of the server the connection pool corresponds to
| The address of the server to which the connection pool corresponds.
|===
|===
To replace the default metric tags, define a `MongoConnectionPoolTagsProvider` bean, as shown in the following example:
To replace the default metric tags, define a `MongoConnectionPoolTagsProvider` bean:
[source,java,indent=0,subs="verbatim"]
[source,java,indent=0,subs="verbatim"]
----
----
@ -1023,52 +1032,52 @@ To disable the auto-configured connection pool metrics, set the following proper
[[actuator.metrics.supported.jetty]]
[[actuator.metrics.supported.jetty]]
==== Jetty Metrics
==== Jetty Metrics
Auto-configuration will bind metrics for Jetty's `ThreadPool` using Micrometer's `JettyServerThreadPoolMetrics`.
Auto-configuration binds metrics for Jetty's `ThreadPool` by using Micrometer's `JettyServerThreadPoolMetrics`.
Metrics for Jetty's ``Connector``s are bound using Micrometer's `JettyConnectionMetrics` and, in addition when configprop:server.ssl.enabled[] is set to `true`, Micrometer's `JettySslHandshakeMetrics`.
Metrics for Jetty's `Connector` instances are bound by using Micrometer's `JettyConnectionMetrics` and, when configprop:server.ssl.enabled[] is set to `true`, Micrometer's `JettySslHandshakeMetrics`.
[[actuator.metrics.supported.timed-annotation]]
[[actuator.metrics.supported.timed-annotation]]
==== @Timed Annotation Support
==== @Timed Annotation Support
The `@Timed` annotation from the `io.micrometer.core.annotation` package can be used with several of the supported technologies listed above.
You can use the `@Timed` annotation from the `io.micrometer.core.annotation` package with several of the supported technologies described earlier.
If supported, the annotation can be used either at the class-level or the method-level.
If supported, you can use the annotation at either the class level or the method level.
For example, the following code shows how the annotation can be used to instrument all request mappings in a `@RestController`:
For example, the following code shows how you can use the annotation to instrument all request mappings in a `@RestController`:
Using a `MeterBinder` ensures that the correct dependency relationships are set up and that the bean is available when the metric's value is retrieved.
Using a `MeterBinder` ensures that the correct dependency relationships are set up and that the bean is available when the metric's value is retrieved.
A `MeterBinder` implementation can also be useful if you find that you repeatedly instrument a suite of metrics across components or applications.
A `MeterBinder` implementation can also be useful if you find that you repeatedly instrument a suite of metrics across components or applications.
NOTE: By default, metrics from all `MeterBinder` beans will be automatically bound to the Spring-managed `MeterRegistry`.
NOTE: By default, metrics from all `MeterBinder` beans are automatically bound to the Spring-managed `MeterRegistry`.
[[actuator.metrics.customizing]]
[[actuator.metrics.customizing]]
=== Customizing Individual Metrics
=== Customizing Individual Metrics
If you need to apply customizations to specific `Meter` instances you can use the `io.micrometer.core.instrument.config.MeterFilter` interface.
If you need to apply customizations to specific `Meter` instances, you can use the `io.micrometer.core.instrument.config.MeterFilter` interface.
For example, if you want to rename the `mytag.region` tag to `mytag.area` for all meter IDs beginning with `com.example`, you can do the following:
For example, if you want to rename the `mytag.region` tag to `mytag.area` for all meter IDs beginning with `com.example`, you can do the following:
@ -1093,16 +1102,16 @@ For example, if you want to rename the `mytag.region` tag to `mytag.area` for al
| Publish a cumulative histogram with buckets defined by your service-level objectives.
| Publish a cumulative histogram with buckets defined by your service-level objectives.
|===
|===
For more details on concepts behind `percentiles-histogram`, `percentiles` and `slo` refer to the {micrometer-concepts-docs}#_histograms_and_percentiles["Histograms and percentiles" section] of the micrometer documentation.
For more details on the concepts behind `percentiles-histogram`, `percentiles`, and `slo`, see the {micrometer-concepts-docs}#_histograms_and_percentiles["`Histograms and percentiles`" section] of the Micrometer documentation.
[[actuator.metrics.endpoint]]
[[actuator.metrics.endpoint]]
=== Metrics Endpoint
=== Metrics Endpoint
Spring Boot provides a `metrics` endpoint that can be used diagnostically to examine the metrics collected by an application.
Spring Boot provides a `metrics` endpoint that you can use diagnostically to examine the metrics collected by an application.
The endpoint is not available by default and must be exposed, see <<actuator#actuator.endpoints.exposing,exposing endpoints>> for more details.
The endpoint is not available by default and must be exposed. See <<actuator#actuator.endpoints.exposing,exposing endpoints>> for more details.
Navigating to `/actuator/metrics` displays a list of available meter names.
Navigating to `/actuator/metrics` displays a list of available meter names.
You can drill down to view information about a particular meter by providing its name as a selector, e.g. `/actuator/metrics/jvm.memory.max`.
You can drill down to view information about a particular meter by providing its name as a selector -- for example, `/actuator/metrics/jvm.memory.max`.
[TIP]
[TIP]
====
====
The name you use here should match the name used in the code, not the name after it has been naming-convention normalized for a monitoring system it is shipped to.
The name you use here should match the name used in the code, not the name after it has been naming-convention normalized for a monitoring system to which it is shipped.
In other words, if `jvm.memory.max` appears as `jvm_memory_max` in Prometheus because of its snake case naming convention, you should still use `jvm.memory.max` as the selector when inspecting the meter in the `metrics` endpoint.
In other words, if `jvm.memory.max` appears as `jvm_memory_max` in Prometheus because of its snake case naming convention, you should still use `jvm.memory.max` as the selector when inspecting the meter in the `metrics` endpoint.
====
====
You can also add any number of `tag=KEY:VALUE` query parameters to the end of the URL to dimensionally drill down on a meter, e.g. `/actuator/metrics/jvm.memory.max?tag=area:nonheap`.
You can also add any number of `tag=KEY:VALUE` query parameters to the end of the URL to dimensionally drill down on a meter -- for example, `/actuator/metrics/jvm.memory.max?tag=area:nonheap`.
[TIP]
[TIP]
====
====
The reported measurements are the _sum_ of the statistics of all meters matching the meter name and any tags that have been applied.
The reported measurements are the _sum_ of the statistics of all meters that match the meter name and any tags that have been applied.
So in the example above, the returned "Value" statistic is the sum of the maximum memory footprints of "Code Cache", "Compressed Class Space", and "Metaspace" areas of the heap.
In the preceding example, the returned `Value` statistic is the sum of the maximum memory footprints of the "`Code Cache`", "`Compressed Class Space`", and "`Metaspace`" areas of the heap.
If you only wanted to see the maximum size for the "Metaspace", you could add an additional `tag=id:Metaspace`, i.e. `/actuator/metrics/jvm.memory.max?tag=area:nonheap&tag=id:Metaspace`.
If you wanted to see only the maximum size for the "`Metaspace`", you could add an additional `tag=id:Metaspace` -- that is, `/actuator/metrics/jvm.memory.max?tag=area:nonheap&tag=id:Metaspace`.
@ -5,7 +5,7 @@ The default convention is to use the `id` of the endpoint with a prefix of `/act
For example, `health` is exposed as `/actuator/health`.
For example, `health` is exposed as `/actuator/health`.
TIP: Actuator is supported natively with Spring MVC, Spring WebFlux, and Jersey.
TIP: Actuator is supported natively with Spring MVC, Spring WebFlux, and Jersey.
If both Jersey and Spring MVC are available, Spring MVC will be used.
If both Jersey and Spring MVC are available, Spring MVC is used.
NOTE: Jackson is a required dependency in order to get the correct JSON responses as documented in the API documentation ({spring-boot-actuator-restapi-docs}[HTML] or {spring-boot-actuator-restapi-pdfdocs}[PDF]).
NOTE: Jackson is a required dependency in order to get the correct JSON responses as documented in the API documentation ({spring-boot-actuator-restapi-docs}[HTML] or {spring-boot-actuator-restapi-pdfdocs}[PDF]).
@ -15,7 +15,7 @@ NOTE: Jackson is a required dependency in order to get the correct JSON response
=== 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, your application might already use `/actuator` for another purpose.
For example, your application might already use `/actuator` for another purpose.
You can use the configprop:management.endpoints.web.base-path[] property to change the prefix for your management endpoint, as shown in the following example:
You can use the configprop:management.endpoints.web.base-path[] property to change the prefix for your management endpoint, as the following example shows:
@ -27,7 +27,7 @@ You can use the configprop:management.endpoints.web.base-path[] property to chan
The preceding `application.properties` example changes the endpoint from `/actuator/\{id}` to `/manage/\{id}` (for example, `/manage/info`).
The preceding `application.properties` example changes the endpoint from `/actuator/\{id}` to `/manage/\{id}` (for example, `/manage/info`).
NOTE: Unless the management port has been configured to <<actuator#actuator.monitoring.customizing-management-server-port,expose endpoints by using a different HTTP port>>, `management.endpoints.web.base-path` is relative to `server.servlet.context-path` (Servlet web applications) or `spring.webflux.base-path` (reactive web applications).
NOTE: Unless the management port has been configured to <<actuator#actuator.monitoring.customizing-management-server-port,expose endpoints by using a different HTTP port>>, `management.endpoints.web.base-path` is relative to `server.servlet.context-path` (for servlet web applications) or `spring.webflux.base-path` (for reactive web applications).
If `management.server.port` is configured, `management.endpoints.web.base-path` is relative to `management.server.base-path`.
If `management.server.port` is configured, `management.endpoints.web.base-path` is relative to `management.server.base-path`.
If you want to map endpoints to a different path, you can use the configprop:management.endpoints.web.path-mapping[] property.
If you want to map endpoints to a different path, you can use the configprop:management.endpoints.web.path-mapping[] property.
@ -51,7 +51,7 @@ The following example remaps `/actuator/health` to `/healthcheck`:
Exposing management endpoints by using the default HTTP port is a sensible choice for cloud-based deployments.
Exposing management endpoints by using the default HTTP port is a sensible choice for cloud-based deployments.
If, however, your application runs inside your own data center, you may prefer to expose endpoints by using a different HTTP port.
If, however, your application runs inside your own data center, you may prefer to expose endpoints by using a different HTTP port.
You can set the configprop:management.server.port[] property to change the HTTP port, as shown in the following example:
You can set the configprop:management.server.port[] property to change the HTTP port, as the following example shows:
@ -60,15 +60,15 @@ You can set the configprop:management.server.port[] property to change the HTTP
port: 8081
port: 8081
----
----
NOTE: On Cloud Foundry, applications only receive requests on port 8080 for both HTTP and TCP routing, by default.
NOTE: On Cloud Foundry, by default, applications receive requests only on port 8080 for both HTTP and TCP routing.
If you want to use a custom management port on Cloud Foundry, you will need to explicitly set up the application's routes to forward traffic to the custom port.
If you want to use a custom management port on Cloud Foundry, you need to explicitly set up the application's routes to forward traffic to the custom port.
[[actuator.monitoring.management-specific-ssl]]
[[actuator.monitoring.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 its own SSL by using the various `management.server.ssl.*` properties.
When configured to use a custom port, you can also configure the management server with its own SSL by using the various `management.server.ssl.*` properties.
For example, doing so lets a management server be available over HTTP while the main application uses HTTPS, as shown in the following property settings:
For example, doing so lets a management server be available over HTTP while the main application uses HTTPS, as the following property settings show:
In the `spring-boot` module, you can find two classes to create files that are often useful for process monitoring:
In the `spring-boot` module, you can find two classes to create files that are often useful for process monitoring:
* `ApplicationPidFileWriter` creates a file containing the application PID (by default, in the application directory with a file name of `application.pid`).
* `ApplicationPidFileWriter` creates a file that contains the application PID (by default, in the application directory with a file name of `application.pid`).
* `WebServerPortFileWriter` creates a file (or files) containing the ports of the running web server (by default, in the application directory with a file name of `application.port`).
* `WebServerPortFileWriter` creates a file (or files) that contain the ports of the running web server (by default, in the application directory with a file name of `application.port`).
By default, these writers are not activated, but you can enable:
By default, these writers are not activated, but you can enable them:
You might want to read about graphing tools such as https://graphiteapp.org[Graphite].
You might want to read about graphing tools such as https://graphiteapp.org[Graphite].
Otherwise, you can continue on, to read about <<deployment#deployment, '`deployment options`'>> or jump ahead for some in-depth information about Spring Boot's _<<build-tool-plugins#build-tool-plugins, build tool plugins>>_.
Otherwise, you can continue on to read about <<deployment#deployment, "`deployment options`">> or jump ahead for some in-depth information about Spring Boot's <<build-tool-plugins#build-tool-plugins, build tool plugins>>.