此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Boot 3.4.3spring-doc.cadn.net.cn

端点

Actuator 终端节点允许您监控应用程序并与之交互。 Spring Boot 包含许多内置端点,并允许您添加自己的端点。 例如,healthendpoint 提供基本的应用程序运行状况信息。spring-doc.cadn.net.cn

您可以控制对每个单独终端节点的访问,并通过 HTTP 或 JMX 公开它们(使其可远程访问)。 当允许访问终端节点并公开终端节点时,该终端节点被视为可用。 仅当内置终端节点可用时,才会自动配置这些终端节点。 大多数应用程序选择通过 HTTP 进行公开,其中终端节点的 ID 和前缀/actuator映射到 URL。 例如,默认情况下,healthendpoint 映射到/actuator/health.spring-doc.cadn.net.cn

要了解有关 Actuator 的终端节点及其请求和响应格式的更多信息,请参阅 API 文档

以下与技术无关的终端节点可用:spring-doc.cadn.net.cn

身份证 描述

auditeventsspring-doc.cadn.net.cn

公开当前应用程序的审计事件信息。 需要一个AuditEventRepository豆。spring-doc.cadn.net.cn

beansspring-doc.cadn.net.cn

显示应用程序中所有 Spring bean 的完整列表。spring-doc.cadn.net.cn

cachesspring-doc.cadn.net.cn

公开可用的缓存。spring-doc.cadn.net.cn

conditionsspring-doc.cadn.net.cn

显示在 configuration 和 auto-configuration 类上评估的条件,以及它们匹配或不匹配的原因。spring-doc.cadn.net.cn

configpropsspring-doc.cadn.net.cn

显示所有@ConfigurationProperties. 需进行消毒spring-doc.cadn.net.cn

envspring-doc.cadn.net.cn

暴露 Spring 的ConfigurableEnvironment. 需进行消毒spring-doc.cadn.net.cn

flywayspring-doc.cadn.net.cn

显示已应用的任何 Flyway 数据库迁移。 需要一个或多个Flyway豆。spring-doc.cadn.net.cn

healthspring-doc.cadn.net.cn

显示应用程序运行状况信息。spring-doc.cadn.net.cn

httpexchangesspring-doc.cadn.net.cn

显示 HTTP 交换信息(默认情况下,最后 100 个 HTTP 请求-响应交换)。 需要一个HttpExchangeRepository豆。spring-doc.cadn.net.cn

infospring-doc.cadn.net.cn

显示任意应用程序信息。spring-doc.cadn.net.cn

integrationgraphspring-doc.cadn.net.cn

显示 Spring 集成图。 需要依赖spring-integration-core.spring-doc.cadn.net.cn

loggersspring-doc.cadn.net.cn

显示和修改应用程序中记录器的配置。spring-doc.cadn.net.cn

liquibasespring-doc.cadn.net.cn

显示已应用的任何 Liquibase 数据库迁移。 需要一个或多个Liquibase豆。spring-doc.cadn.net.cn

metricsspring-doc.cadn.net.cn

显示当前应用程序的 “metrics” 信息。spring-doc.cadn.net.cn

mappingsspring-doc.cadn.net.cn

显示所有@RequestMapping路径。spring-doc.cadn.net.cn

quartzspring-doc.cadn.net.cn

显示有关 Quartz Scheduler 作业的信息。 需进行消毒spring-doc.cadn.net.cn

scheduledtasksspring-doc.cadn.net.cn

显示应用程序中的计划任务。spring-doc.cadn.net.cn

sessionsspring-doc.cadn.net.cn

允许从 Spring Session 支持的会话存储中检索和删除用户会话。 需要使用 Spring Session 的基于 servlet 的 Web 应用程序。spring-doc.cadn.net.cn

shutdownspring-doc.cadn.net.cn

允许正常关闭应用程序。 仅在使用 jar 打包时有效。 默认处于禁用状态。spring-doc.cadn.net.cn

startupspring-doc.cadn.net.cn

显示由ApplicationStartup. 需要SpringApplication配置一个BufferingApplicationStartup.spring-doc.cadn.net.cn

threaddumpspring-doc.cadn.net.cn

执行线程转储。spring-doc.cadn.net.cn

如果您的应用程序是 Web 应用程序(Spring MVC、Spring WebFlux 或 Jersey),则可以使用以下附加端点:spring-doc.cadn.net.cn

身份证 描述

heapdumpspring-doc.cadn.net.cn

返回堆转储文件。 在 HotSpot JVM 上,HPROF-format 文件。 在 OpenJ9 JVM 上,PHD-format 文件。spring-doc.cadn.net.cn

logfilespring-doc.cadn.net.cn

返回日志文件的内容(如果logging.file.namelogging.file.path属性)。 支持使用 HTTPRange标头检索日志文件的部分内容。spring-doc.cadn.net.cn

prometheusspring-doc.cadn.net.cn

以 Prometheus 服务器可抓取的格式公开指标。 需要依赖micrometer-registry-prometheus.spring-doc.cadn.net.cn

控制对终端节点的访问

默认情况下,访问除shutdown不受限制。 要配置对终端节点的允许访问,请使用其management.endpoint.<id>.access财产。 以下示例允许对shutdown端点:spring-doc.cadn.net.cn

management.endpoint.shutdown.access=unrestricted
management:
  endpoint:
    shutdown:
      access: unrestricted

如果您希望访问是选择加入而不是选择退出,请将management.endpoints.access.defaultproperty 设置为none并使用单个端点access属性以选择重新加入。 以下示例允许对loggersendpoint 并拒绝对所有其他 endpoint 的访问:spring-doc.cadn.net.cn

management.endpoints.access.default=none
management.endpoint.loggers.access=read-only
management:
  endpoints:
    access:
      default: none
  endpoint:
    loggers:
      access: read-only
无法访问的端点将从应用程序上下文中完全删除。 如果您只想更改终端节点所公开的技术,请使用includeexclude性能相反。

限制访问

可以使用management.endpoints.access.max-permitted财产。 此属性优先于默认访问权限或单个终端节点的访问级别。 将其设置为none使所有端点都不可访问。 将其设置为read-only以仅允许对终端节点进行读取访问。spring-doc.cadn.net.cn

@Endpoint,@JmxEndpoint@WebEndpoint,读取访问等同于注释有@ReadOperation. 为@ControllerEndpoint@RestControllerEndpoint,读取访问权限等同于可以处理GETHEAD请求。 为@ServletEndpoint,则读取访问权限等于GETHEAD请求。spring-doc.cadn.net.cn

公开端点

默认情况下,仅通过 HTTP 和 JMX 公开运行状况终端节点。 由于 Endpoints 可能包含敏感信息,因此您应该仔细考虑何时公开它们。spring-doc.cadn.net.cn

要更改公开的终端节点,请使用以下特定于includeexclude性能:spring-doc.cadn.net.cn

财产 违约

management.endpoints.jmx.exposure.excludespring-doc.cadn.net.cn

management.endpoints.jmx.exposure.includespring-doc.cadn.net.cn

healthspring-doc.cadn.net.cn

management.endpoints.web.exposure.excludespring-doc.cadn.net.cn

management.endpoints.web.exposure.includespring-doc.cadn.net.cn

healthspring-doc.cadn.net.cn

includeproperty 列出公开的端点的 ID。 这excludeproperty 列出不应公开的端点的 ID。 这exclude属性优先于include财产。 您可以配置includeexclude属性中,其中包含终端节点 ID 列表。spring-doc.cadn.net.cn

例如,要仅公开healthinfoendpoints 的 JMX 上,请使用以下属性:spring-doc.cadn.net.cn

management.endpoints.jmx.exposure.include=health,info
management:
  endpoints:
    jmx:
      exposure:
        include: "health,info"

*可用于选择所有端点。 例如,要通过 HTTP 公开除envbeansendpoints,请使用以下属性:spring-doc.cadn.net.cn

management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
management:
  endpoints:
    web:
      exposure:
        include: "*"
        exclude: "env,beans"
*在 YAML 中具有特殊含义,因此如果要包含(或排除)所有终端节点,请务必添加引号。
如果您的应用程序公开,我们强烈建议您同时保护终端节点
如果要在端点公开时实施自己的策略,可以注册一个EndpointFilter豆。

安全

出于安全考虑,只有/healthendpoint 默认通过 HTTP 公开。 您可以使用management.endpoints.web.exposure.include属性来配置公开的端点。spring-doc.cadn.net.cn

在设置management.endpoints.web.exposure.include,确保公开的 actuator 不包含敏感信息,通过将它们放置在防火墙后面进行保护,或者由类似 Spring Security 的东西进行保护。

如果 Spring Security 在类路径上,并且没有其他SecurityFilterChainBean 存在,则除/health由 Spring Boot 自动配置保护。 如果您定义了自定义SecurityFilterChainbean,Spring Boot 自动配置会回退,并允许您完全控制 actuator 访问规则。spring-doc.cadn.net.cn

如果您希望为 HTTP 端点配置自定义安全性(例如,仅允许具有特定角色的用户访问它们),Spring Boot 提供了一些方便的RequestMatcher可以与 Spring Security 结合使用的对象。spring-doc.cadn.net.cn

典型的 Spring Security 配置可能类似于以下示例:spring-doc.cadn.net.cn

import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

import static org.springframework.security.config.Customizer.withDefaults;

@Configuration(proxyBeanMethods = false)
public class MySecurityConfiguration {

	@Bean
	public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
		http.securityMatcher(EndpointRequest.toAnyEndpoint());
		http.authorizeHttpRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN"));
		http.httpBasic(withDefaults());
		return http.build();
	}

}
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.Customizer.withDefaults
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.web.SecurityFilterChain

@Configuration(proxyBeanMethods = false)
class MySecurityConfiguration {

	@Bean
	fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
		http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests { requests ->
			requests.anyRequest().hasRole("ENDPOINT_ADMIN")
		}
		http.httpBasic(withDefaults())
		return http.build()
	}

}

The preceding example uses EndpointRequest.toAnyEndpoint() to match a request to any endpoint and then ensures that all have the ENDPOINT_ADMIN role. Several other matcher methods are also available on EndpointRequest. See the API documentation for details.spring-doc.cadn.net.cn

If you deploy applications behind a firewall, you may prefer that all your actuator endpoints can be accessed without requiring authentication. You can do so by changing the management.endpoints.web.exposure.include property, as follows:spring-doc.cadn.net.cn

management.endpoints.web.exposure.include=*
management:
  endpoints:
    web:
      exposure:
        include: "*"

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:spring-doc.cadn.net.cn

import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration(proxyBeanMethods = false)
public class MySecurityConfiguration {

	@Bean
	public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
		http.securityMatcher(EndpointRequest.toAnyEndpoint());
		http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll());
		return http.build();
	}

}
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.web.SecurityFilterChain

@Configuration(proxyBeanMethods = false)
class MySecurityConfiguration {

	@Bean
	fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
		http.securityMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests { requests ->
			requests.anyRequest().permitAll()
		}
		return http.build()
	}

}
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 need to configure an additional SecurityFilterChain bean with rules that apply to the rest of the application.

Cross Site Request Forgery Protection

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), a PUT, or a DELETE get a 403 (forbidden) error when the default security configuration is in use.spring-doc.cadn.net.cn

We recommend disabling CSRF protection completely only if you are creating a service that is used by non-browser clients.

You can find additional information about CSRF protection in the Spring Security Reference Guide.spring-doc.cadn.net.cn

Configuring Endpoints

Endpoints automatically cache responses to read operations that do not take any parameters. 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:spring-doc.cadn.net.cn

management.endpoint.beans.cache.time-to-live=10s
management:
  endpoint:
    beans:
      cache:
        time-to-live: "10s"
The management.endpoint.<name> prefix uniquely identifies the endpoint that is being configured.

Sanitize Sensitive Values

Information returned by the /env, /configprops and /quartz endpoints can be sensitive, so by default values are always fully sanitized (replaced by ).******spring-doc.cadn.net.cn

Values can only be viewed in an unsanitized form when:spring-doc.cadn.net.cn

The show-values property can be configured for sanitizable endpoints to one of the following values:spring-doc.cadn.net.cn

For HTTP endpoints, a user is considered to be authorized if they have authenticated and have the roles configured by the endpoint’s roles property. By default, any authenticated user is authorized.spring-doc.cadn.net.cn

For JMX endpoints, all users are always authorized.spring-doc.cadn.net.cn

The following example allows all users with the admin role to view values from the /env endpoint in their original form. Unauthorized users, or users without the admin role, will see only sanitized values.spring-doc.cadn.net.cn

management.endpoint.env.show-values=when-authorized
management.endpoint.env.roles=admin
management:
  endpoint:
    env:
      show-values: when-authorized
      roles: "admin"
This example assumes that no SanitizingFunction beans have been defined.

Hypermedia for Actuator Web Endpoints

A “discovery page” is added with links to all the endpoints. The “discovery page” is available on /actuator by default.spring-doc.cadn.net.cn

To disable the “discovery page”, add the following property to your application properties:spring-doc.cadn.net.cn

management.endpoints.web.discovery.enabled=false
management:
  endpoints:
    web:
      discovery:
        enabled: false

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, 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./spring-doc.cadn.net.cn

CORS Support

Cross-origin resource sharing (CORS) is a 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, you can configure Actuator’s web endpoints to support such scenarios.spring-doc.cadn.net.cn

CORS support is disabled by default and is only enabled once you have set the management.endpoints.web.cors.allowed-origins property. The following configuration permits GET and POST calls from the example.com domain:spring-doc.cadn.net.cn

management.endpoints.web.cors.allowed-origins=https://example.com
management.endpoints.web.cors.allowed-methods=GET,POST
management:
  endpoints:
    web:
      cors:
        allowed-origins: "https://example.com"
        allowed-methods: "GET,POST"
See CorsEndpointProperties for a complete list of options.

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. Endpoints can be exposed over HTTP by using Jersey, Spring MVC, or Spring WebFlux. If both Jersey and Spring MVC are available, Spring MVC is used.spring-doc.cadn.net.cn

The following example exposes a read operation that returns a custom object:spring-doc.cadn.net.cn

	@ReadOperation
	public CustomData getData() {
		return new CustomData("test", 5);
	}
	@ReadOperation
	fun getData(): CustomData {
		return CustomData("test", 5)
	}

You can also write technology-specific endpoints by using @JmxEndpoint or @WebEndpoint. These endpoints are restricted to their respective technologies. For example, @WebEndpoint is exposed only over HTTP and not over JMX.spring-doc.cadn.net.cn

You can write technology-specific extensions by using @EndpointWebExtension and @EndpointJmxExtension. These annotations let you provide technology-specific operations to augment an existing endpoint.spring-doc.cadn.net.cn

Finally, if you need access to web-framework-specific functionality, you can implement servlet or Spring @Controller and @RestController endpoints at the cost of them not being available over JMX or when using a different web framework.spring-doc.cadn.net.cn

Receiving Input

Operations on an endpoint receive input through their parameters. 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 over JMX, the parameters are mapped to the parameters of the MBean’s operations. Parameters are required by default. They can be made optional by annotating them with either @javax.annotation.Nullable or @Nullable.spring-doc.cadn.net.cn

You can map each root property in the JSON request body to a parameter of the endpoint. Consider the following JSON request body:spring-doc.cadn.net.cn

{
	"name": "test",
	"counter": 42
}

You can use this to invoke a write operation that takes String name and int counter parameters, as the following example shows:spring-doc.cadn.net.cn

	@WriteOperation
	public void updateData(String name, int counter) {
		// injects "test" and 42
	}
	@WriteOperation
	fun updateData(name: String?, counter: Int) {
		// injects "test" and 42
	}
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 that defines a name and counter properties is not supported.
To let the input be mapped to the operation method’s parameters, Java code that implements an endpoint should be compiled with -parameters. For Kotlin code, please review the recommendation of the Spring Framework reference. This will happen automatically if you use Spring Boot’s Gradle plugin or if you use Maven and spring-boot-starter-parent.

Input Type Conversion

The parameters passed to endpoint operation methods are, if necessary, automatically converted to the required type. 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.spring-doc.cadn.net.cn

Custom Web Endpoints

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 is used.spring-doc.cadn.net.cn

Web Endpoint Request Predicates

A request predicate is automatically generated for each operation on a web-exposed endpoint.spring-doc.cadn.net.cn

Path

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. For example, an endpoint with an ID of sessions uses /actuator/sessions as its path in the predicate.spring-doc.cadn.net.cn

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. 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 conversion-compatible with a String[].spring-doc.cadn.net.cn

HTTP method

The HTTP method of the predicate is determined by the operation type, as shown in the following table:spring-doc.cadn.net.cn

Operation HTTP method

@ReadOperationspring-doc.cadn.net.cn

GETspring-doc.cadn.net.cn

@WriteOperationspring-doc.cadn.net.cn

POSTspring-doc.cadn.net.cn

@DeleteOperationspring-doc.cadn.net.cn

DELETEspring-doc.cadn.net.cn

Consumes

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.spring-doc.cadn.net.cn

Produces

The produces clause of the predicate can be determined by the produces attribute of the @DeleteOperation, @ReadOperation, and @WriteOperation annotations. The attribute is optional. If it is not used, the produces clause is determined automatically.spring-doc.cadn.net.cn

If the operation method returns void or Void, the produces clause is empty. If the operation method returns a 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.spring-doc.cadn.net.cn

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.spring-doc.cadn.net.cn

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).spring-doc.cadn.net.cn

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).spring-doc.cadn.net.cn

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).spring-doc.cadn.net.cn

Web Endpoint Range Requests

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 Resource automatically support range requests.spring-doc.cadn.net.cn

Range requests are not supported when using Jersey.

Web Endpoint Security

An operation on a web endpoint or a web-specific endpoint extension can receive the current Principal or SecurityContext as a method parameter. The former is typically used in conjunction with either @javax.annotation.Nullable or @Nullable to provide different behavior for authenticated and unauthenticated users. The latter is typically used to perform authorization checks by using its isUserInRole(String) method.spring-doc.cadn.net.cn

Health Information

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. The information exposed by the health endpoint depends on the management.endpoint.health.show-details and management.endpoint.health.show-components properties, which can be configured with one of the following values:spring-doc.cadn.net.cn

Name Description

neverspring-doc.cadn.net.cn

Details are never shown.spring-doc.cadn.net.cn

when-authorizedspring-doc.cadn.net.cn

Details are shown only to authorized users. Authorized roles can be configured by using management.endpoint.health.roles.spring-doc.cadn.net.cn

alwaysspring-doc.cadn.net.cn

Details are shown to all users.spring-doc.cadn.net.cn

The default value is never. 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. You can configure the roles by using the management.endpoint.health.roles property.spring-doc.cadn.net.cn

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 HealthContributorRegistry (by default, all HealthContributor instances defined in your ApplicationContext). Spring Boot includes a number of auto-configured HealthContributor beans, and you can also write your own.spring-doc.cadn.net.cn

A HealthContributor can be either a HealthIndicator or a CompositeHealthContributor. A HealthIndicator provides actual health information, including a Status. A CompositeHealthContributor provides a composite of other HealthContributor instances. Taken together, contributors form a tree structure to represent the overall system health.spring-doc.cadn.net.cn

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. If no HealthIndicator returns a status that is known to the StatusAggregator, an UNKNOWN status is used.spring-doc.cadn.net.cn

You can use the HealthContributorRegistry to register and unregister health indicators at runtime.

Auto-configured HealthIndicators

When appropriate, Spring Boot auto-configures the HealthIndicator beans listed in the following table. You can also enable or disable selected indicators by configuring management.health.key.enabled, with the key listed in the following table:spring-doc.cadn.net.cn

Key Name Description

cassandraspring-doc.cadn.net.cn

CassandraDriverHealthIndicatorspring-doc.cadn.net.cn

Checks that a Cassandra database is up.spring-doc.cadn.net.cn

couchbasespring-doc.cadn.net.cn

CouchbaseHealthIndicatorspring-doc.cadn.net.cn

Checks that a Couchbase cluster is up.spring-doc.cadn.net.cn

dbspring-doc.cadn.net.cn

DataSourceHealthIndicatorspring-doc.cadn.net.cn

Checks that a connection to DataSource can be obtained.spring-doc.cadn.net.cn

diskspacespring-doc.cadn.net.cn

DiskSpaceHealthIndicatorspring-doc.cadn.net.cn

Checks for low disk space.spring-doc.cadn.net.cn

elasticsearchspring-doc.cadn.net.cn

ElasticsearchRestClientHealthIndicatorspring-doc.cadn.net.cn

Checks that an Elasticsearch cluster is up.spring-doc.cadn.net.cn

hazelcastspring-doc.cadn.net.cn

HazelcastHealthIndicatorspring-doc.cadn.net.cn

Checks that a Hazelcast server is up.spring-doc.cadn.net.cn

jmsspring-doc.cadn.net.cn

JmsHealthIndicatorspring-doc.cadn.net.cn

Checks that a JMS broker is up.spring-doc.cadn.net.cn

ldapspring-doc.cadn.net.cn

LdapHealthIndicatorspring-doc.cadn.net.cn

Checks that an LDAP server is up.spring-doc.cadn.net.cn

mailspring-doc.cadn.net.cn

MailHealthIndicatorspring-doc.cadn.net.cn

Checks that a mail server is up.spring-doc.cadn.net.cn

mongospring-doc.cadn.net.cn

MongoHealthIndicatorspring-doc.cadn.net.cn

Checks that a Mongo database is up.spring-doc.cadn.net.cn

neo4jspring-doc.cadn.net.cn

Neo4jHealthIndicatorspring-doc.cadn.net.cn

Checks that a Neo4j database is up.spring-doc.cadn.net.cn

pingspring-doc.cadn.net.cn

PingHealthIndicatorspring-doc.cadn.net.cn

Always responds with UP.spring-doc.cadn.net.cn

rabbitspring-doc.cadn.net.cn

RabbitHealthIndicatorspring-doc.cadn.net.cn

Checks that a Rabbit server is up.spring-doc.cadn.net.cn

redisspring-doc.cadn.net.cn

RedisHealthIndicatorspring-doc.cadn.net.cn

Checks that a Redis server is up.spring-doc.cadn.net.cn

sslspring-doc.cadn.net.cn

SslHealthIndicatorspring-doc.cadn.net.cn

Checks that SSL certificates are ok.spring-doc.cadn.net.cn

You can disable them all by setting the management.health.defaults.enabled property.
The ssl HealthIndicator has a "warning threshold" property named management.health.ssl.certificate-validity-warning-threshold. If an SSL certificate will be invalid within the time span defined by this threshold, the HealthIndicator will warn you but it will still return HTTP 200 to not disrupt the application. You can use this threshold to give yourself enough lead time to rotate the soon to be expired certificate.

Additional HealthIndicator beans are available but are not enabled by default:spring-doc.cadn.net.cn

Key Name Description

livenessstatespring-doc.cadn.net.cn

LivenessStateHealthIndicatorspring-doc.cadn.net.cn

Exposes the “Liveness” application availability state.spring-doc.cadn.net.cn

readinessstatespring-doc.cadn.net.cn

ReadinessStateHealthIndicatorspring-doc.cadn.net.cn

Exposes the “Readiness” application availability state.spring-doc.cadn.net.cn

Writing Custom HealthIndicators

To provide custom health information, you can register Spring beans that implement the HealthIndicator interface. You need to provide an implementation of the health() method and return a Health response. The Health response should include a status and can optionally include additional details to be displayed. The following code shows a sample HealthIndicator implementation:spring-doc.cadn.net.cn

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class MyHealthIndicator implements HealthIndicator {

	@Override
	public Health health() {
		int errorCode = check();
		if (errorCode != 0) {
			return Health.down().withDetail("Error Code", errorCode).build();
		}
		return Health.up().build();
	}

	private int check() {
		// perform some specific health check
		return ...
	}

}
import org.springframework.boot.actuate.health.Health
import org.springframework.boot.actuate.health.HealthIndicator
import org.springframework.stereotype.Component

@Component
class MyHealthIndicator : HealthIndicator {

	override fun health(): Health {
		val errorCode = check()
		if (errorCode != 0) {
			return Health.down().withDetail("Error Code", errorCode).build()
		}
		return Health.up().build()
	}

	private fun check(): Int {
		// perform some specific health check
		return  ...
	}

}
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.
Health indicators are usually called over HTTP and need to respond before any connection timeouts. Spring Boot will log a warning message for any health indicator that takes longer than 10 seconds to respond. If you want to configure this threshold, you can use the management.endpoint.health.logging.slow-indicator-threshold property.

In addition to Spring Boot’s predefined Status types, Health can return a custom Status that represents a new system state. In such cases, you also need to provide a custom implementation of the StatusAggregator interface, or you must configure the default implementation by using the management.endpoint.health.status.order configuration property.spring-doc.cadn.net.cn

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:spring-doc.cadn.net.cn

management.endpoint.health.status.order=fatal,down,out-of-service,unknown,up
management:
  endpoint:
    health:
      status:
        order: "fatal,down,out-of-service,unknown,up"

The HTTP status code in the response reflects the overall health status. By default, OUT_OF_SERVICE and DOWN map to 503. Any unmapped health statuses, including UP, map to 200. You might also want to register custom status mappings if you access the health endpoint over HTTP. Configuring a custom mapping disables the defaults mappings for DOWN and OUT_OF_SERVICE. If you want to retain the default mappings, you must explicitly configure them, alongside any custom mappings. For example, the following property maps FATAL to 503 (service unavailable) and retains the default mappings for DOWN and OUT_OF_SERVICE:spring-doc.cadn.net.cn

management.endpoint.health.status.http-mapping.down=503
management.endpoint.health.status.http-mapping.fatal=503
management.endpoint.health.status.http-mapping.out-of-service=503
management:
  endpoint:
    health:
      status:
        http-mapping:
          down: 503
          fatal: 503
          out-of-service: 503
If you need more control, you can define your own HttpCodeStatusMapper bean.

The following table shows the default status mappings for the built-in statuses:spring-doc.cadn.net.cn

Status Mapping

DOWNspring-doc.cadn.net.cn

SERVICE_UNAVAILABLE (503)spring-doc.cadn.net.cn

OUT_OF_SERVICEspring-doc.cadn.net.cn

SERVICE_UNAVAILABLE (503)spring-doc.cadn.net.cn

UPspring-doc.cadn.net.cn

No mapping by default, so HTTP status is 200spring-doc.cadn.net.cn

UNKNOWNspring-doc.cadn.net.cn

No mapping by default, so HTTP status is 200spring-doc.cadn.net.cn

Reactive Health Indicators

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 ReactiveHealthContributorRegistry (by default, all HealthContributor and ReactiveHealthContributor instances defined in your ApplicationContext). Regular HealthContributor instances that do not check against a reactive API are executed on the elastic scheduler.spring-doc.cadn.net.cn

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 with ReactiveHealthContributor#adapt.

To provide custom health information from a reactive API, you can register Spring beans that implement the ReactiveHealthIndicator interface. The following code shows a sample ReactiveHealthIndicator implementation:spring-doc.cadn.net.cn

import reactor.core.publisher.Mono;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class MyReactiveHealthIndicator implements ReactiveHealthIndicator {

	@Override
	public Mono<Health> health() {
		return doHealthCheck().onErrorResume((exception) ->
			Mono.just(new Health.Builder().down(exception).build()));
	}

	private Mono<Health> doHealthCheck() {
		// perform some specific health check
		return ...
	}

}
import org.springframework.boot.actuate.health.Health
import org.springframework.boot.actuate.health.ReactiveHealthIndicator
import org.springframework.stereotype.Component
import reactor.core.publisher.Mono

@Component
class MyReactiveHealthIndicator : ReactiveHealthIndicator {

	override fun health(): Mono<Health> {
		return doHealthCheck()!!.onErrorResume { exception: Throwable? ->
			Mono.just(Health.Builder().down(exception).build())
		}
	}

	private fun doHealthCheck(): Mono<Health>? {
		// perform some specific health check
		return  ...
	}

}
To handle the error automatically, consider extending from AbstractReactiveHealthIndicator.

Auto-configured ReactiveHealthIndicators

When appropriate, Spring Boot auto-configures the following ReactiveHealthIndicator beans:spring-doc.cadn.net.cn

Key Name Description

cassandraspring-doc.cadn.net.cn

CassandraDriverReactiveHealthIndicatorspring-doc.cadn.net.cn

Checks that a Cassandra database is up.spring-doc.cadn.net.cn

couchbasespring-doc.cadn.net.cn

CouchbaseReactiveHealthIndicatorspring-doc.cadn.net.cn

Checks that a Couchbase cluster is up.spring-doc.cadn.net.cn

elasticsearchspring-doc.cadn.net.cn

ElasticsearchReactiveHealthIndicatorspring-doc.cadn.net.cn

Checks that an Elasticsearch cluster is up.spring-doc.cadn.net.cn

mongospring-doc.cadn.net.cn

MongoReactiveHealthIndicatorspring-doc.cadn.net.cn

Checks that a Mongo database is up.spring-doc.cadn.net.cn

neo4jspring-doc.cadn.net.cn

Neo4jReactiveHealthIndicatorspring-doc.cadn.net.cn

Checks that a Neo4j database is up.spring-doc.cadn.net.cn

redisspring-doc.cadn.net.cn

RedisReactiveHealthIndicatorspring-doc.cadn.net.cn

Checks that a Redis server is up.spring-doc.cadn.net.cn

If necessary, reactive indicators replace the regular ones. Also, any HealthIndicator that is not handled explicitly is wrapped automatically.

Health Groups

It is sometimes useful to organize health indicators into groups that you can use for different purposes.spring-doc.cadn.net.cn

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:spring-doc.cadn.net.cn

management.endpoint.health.group.custom.include=db
management:
  endpoint:
    health:
      group:
        custom:
          include: "db"

You can then check the result by hitting localhost:8080/actuator/health/custom.spring-doc.cadn.net.cn

Similarly, to create a group that excludes the database indicators from the group and includes all the other indicators, you can define the following:spring-doc.cadn.net.cn

management.endpoint.health.group.custom.exclude=db
management:
  endpoint:
    health:
      group:
        custom:
          exclude: "db"

By default, startup will fail if a health group includes or excludes a health indicator that does not exist. To disable this behavior set management.endpoint.health.validate-group-membership to false.spring-doc.cadn.net.cn

By default, groups inherit the same StatusAggregator and HttpCodeStatusMapper settings as the system health. However, you can also define these on a per-group basis. You can also override the show-details and roles properties if required:spring-doc.cadn.net.cn

management.endpoint.health.group.custom.show-details=when-authorized
management.endpoint.health.group.custom.roles=admin
management.endpoint.health.group.custom.status.order=fatal,up
management.endpoint.health.group.custom.status.http-mapping.fatal=500
management.endpoint.health.group.custom.status.http-mapping.out-of-service=500
management:
  endpoint:
    health:
      group:
        custom:
          show-details: "when-authorized"
          roles: "admin"
          status:
            order: "fatal,up"
            http-mapping:
              fatal: 500
              out-of-service: 500
You can use @Qualifier("groupname") if you need to register custom StatusAggregator or HttpCodeStatusMapper beans for use with the group.

A health group can also include/exclude a CompositeHealthContributor. You can also include/exclude only a certain component of a CompositeHealthContributor. This can be done using the fully qualified name of the component as follows:spring-doc.cadn.net.cn

management.endpoint.health.group.custom.include="test/primary"
management.endpoint.health.group.custom.exclude="test/primary/b"

In the example above, the custom group will include the HealthContributor with the name primary which is a component of the composite test. Here, primary itself is a composite and the HealthContributor with the name b will be excluded from the custom group.spring-doc.cadn.net.cn

Health groups can be made available at an additional path on either the main or management port. This is useful in cloud environments such as Kubernetes, where it is quite common to use a separate management port for the actuator endpoints for security purposes. Having a separate port could lead to unreliable health checks because the main application might not work properly even if the health check is successful. The health group can be configured with an additional path as follows:spring-doc.cadn.net.cn

management.endpoint.health.group.live.additional-path="server:/healthz"

This would make the live health group available on the main server port at /healthz. The prefix is mandatory and must be either server: (represents the main server port) or management: (represents the management port, if configured.) The path must be a single path segment.spring-doc.cadn.net.cn

DataSource Health

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. 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 management.health.db.ignore-routing-data-sources to true.spring-doc.cadn.net.cn

Kubernetes Probes

Applications deployed on Kubernetes can provide information about their internal state with Container Probes. Depending on your Kubernetes configuration, the kubelet calls those probes and reacts to the result.spring-doc.cadn.net.cn

By default, Spring Boot manages your Application Availability state. If deployed in a Kubernetes environment, actuator gathers the “Liveness” and “Readiness” information from the ApplicationAvailability interface and uses that information in dedicated health indicators: LivenessStateHealthIndicator and ReadinessStateHealthIndicator. These indicators are shown on the global health endpoint ("/actuator/health"). They are also exposed as separate HTTP Probes by using health groups: "/actuator/health/liveness" and "/actuator/health/readiness".spring-doc.cadn.net.cn

You can then configure your Kubernetes infrastructure with the following endpoint information:spring-doc.cadn.net.cn

livenessProbe:
  httpGet:
    path: "/actuator/health/liveness"
    port: <actuator-port>
  failureThreshold: ...
  periodSeconds: ...

readinessProbe:
  httpGet:
    path: "/actuator/health/readiness"
    port: <actuator-port>
  failureThreshold: ...
  periodSeconds: ...
<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.

These health groups are automatically enabled only if the application runs in a Kubernetes environment. You can enable them in any environment by using the management.endpoint.health.probes.enabled configuration property.spring-doc.cadn.net.cn

If an application takes longer to start than the configured liveness period, Kubernetes mentions the "startupProbe" as a possible solution. Generally speaking, the "startupProbe" is not necessarily needed here, as the "readinessProbe" fails until all startup tasks are done. This means your application will not receive traffic until it is ready. However, if your application takes a long time to start, consider using a "startupProbe" to make sure that Kubernetes won’t kill your application while it is in the process of starting. See the section that describes 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. 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). For this reason, it is a good idea to make the liveness and readiness health groups available on the main server port. This can be done by setting the following property:spring-doc.cadn.net.cn

management.endpoint.health.probes.add-additional-paths=true

This would make the liveness group available at /livez and the readiness group available at /readyz on the main server port. Paths can be customized using the additional-path property on each group, see health groups for details.spring-doc.cadn.net.cn

Checking External State With Kubernetes Probes

Actuator configures the “liveness” and “readiness” probes as Health Groups. This means that all the health groups features are available for them. You can, for example, configure additional Health Indicators:spring-doc.cadn.net.cn

management.endpoint.health.group.readiness.include=readinessState,customCheck
management:
  endpoint:
    health:
      group:
        readiness:
          include: "readinessState,customCheck"

By default, Spring Boot does not add other health indicators to these groups.spring-doc.cadn.net.cn

The “liveness” probe should not depend on health checks for external systems. If the 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 (such as a database, a Web API, or an external cache) fails, Kubernetes might restart all application instances and create cascading failures.spring-doc.cadn.net.cn

As for the “readiness” probe, the choice of checking external systems must be made carefully by the application developers. For this reason, Spring Boot does not include any additional health checks in the readiness probe. If the 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. 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.spring-doc.cadn.net.cn

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 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 that has an explicit 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.

Also, if an application uses Kubernetes autoscaling, it may react differently to applications being taken out of the load-balancer, depending on its autoscaler configuration.spring-doc.cadn.net.cn

Application Lifecycle and Probe States

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) and the actual probe (which exposes that state). Depending on the phase of application lifecycle, the probe might not be available.spring-doc.cadn.net.cn

Spring Boot publishes application events during startup and shutdown, and probes can listen to such events and expose the AvailabilityState information.spring-doc.cadn.net.cn

The following tables show the AvailabilityState and the state of HTTP connectors at different stages.spring-doc.cadn.net.cn

When a Spring Boot application starts:spring-doc.cadn.net.cn

Startup phase LivenessState ReadinessState HTTP server Notes

Startingspring-doc.cadn.net.cn

BROKENspring-doc.cadn.net.cn

REFUSING_TRAFFICspring-doc.cadn.net.cn

Not startedspring-doc.cadn.net.cn

Kubernetes checks the "liveness" Probe and restarts the application if it takes too long.spring-doc.cadn.net.cn

Startedspring-doc.cadn.net.cn

CORRECTspring-doc.cadn.net.cn

REFUSING_TRAFFICspring-doc.cadn.net.cn

Refuses requestsspring-doc.cadn.net.cn

The application context is refreshed. The application performs startup tasks and does not receive traffic yet.spring-doc.cadn.net.cn

Readyspring-doc.cadn.net.cn

CORRECTspring-doc.cadn.net.cn

ACCEPTING_TRAFFICspring-doc.cadn.net.cn

Accepts requestsspring-doc.cadn.net.cn

Startup tasks are finished. The application is receiving traffic.spring-doc.cadn.net.cn

When a Spring Boot application shuts down:spring-doc.cadn.net.cn

Shutdown phase Liveness State Readiness State HTTP server Notes

Runningspring-doc.cadn.net.cn

CORRECTspring-doc.cadn.net.cn

ACCEPTING_TRAFFICspring-doc.cadn.net.cn

Accepts requestsspring-doc.cadn.net.cn

Shutdown has been requested.spring-doc.cadn.net.cn

Graceful shutdownspring-doc.cadn.net.cn

CORRECTspring-doc.cadn.net.cn

REFUSING_TRAFFICspring-doc.cadn.net.cn

New requests are rejectedspring-doc.cadn.net.cn

If enabled, graceful shutdown processes in-flight requests.spring-doc.cadn.net.cn

Shutdown completespring-doc.cadn.net.cn

N/Aspring-doc.cadn.net.cn

N/Aspring-doc.cadn.net.cn

Server is shut downspring-doc.cadn.net.cn

The application context is closed and the application is shut down.spring-doc.cadn.net.cn

See Kubernetes Container Lifecycle for more information about Kubernetes deployment.

Application Information

Application information exposes various information collected from all InfoContributor beans defined in your ApplicationContext. Spring Boot includes a number of auto-configured InfoContributor beans, and you can write your own.spring-doc.cadn.net.cn

Auto-configured InfoContributors

When appropriate, Spring auto-configures the following InfoContributor beans:spring-doc.cadn.net.cn

ID Name Description Prerequisites

buildspring-doc.cadn.net.cn

BuildInfoContributorspring-doc.cadn.net.cn

Exposes build information.spring-doc.cadn.net.cn

A META-INF/build-info.properties resource.spring-doc.cadn.net.cn

envspring-doc.cadn.net.cn

EnvironmentInfoContributorspring-doc.cadn.net.cn

Exposes any property from the Environment whose name starts with info..spring-doc.cadn.net.cn

None.spring-doc.cadn.net.cn

gitspring-doc.cadn.net.cn

GitInfoContributorspring-doc.cadn.net.cn

Exposes git information.spring-doc.cadn.net.cn

A git.properties resource.spring-doc.cadn.net.cn

javaspring-doc.cadn.net.cn

JavaInfoContributorspring-doc.cadn.net.cn

Exposes Java runtime information.spring-doc.cadn.net.cn

None.spring-doc.cadn.net.cn

osspring-doc.cadn.net.cn

OsInfoContributorspring-doc.cadn.net.cn

Exposes Operating System information.spring-doc.cadn.net.cn

None.spring-doc.cadn.net.cn

processspring-doc.cadn.net.cn

ProcessInfoContributorspring-doc.cadn.net.cn

Exposes process information.spring-doc.cadn.net.cn

None.spring-doc.cadn.net.cn

sslspring-doc.cadn.net.cn

SslInfoContributorspring-doc.cadn.net.cn

Exposes SSL certificate information.spring-doc.cadn.net.cn

An SSL Bundle configured.spring-doc.cadn.net.cn

Whether an individual contributor is enabled is controlled by its management.info.<id>.enabled property. Different contributors have different defaults for this property, depending on their prerequisites and the nature of the information that they expose.spring-doc.cadn.net.cn

With no prerequisites to indicate that they should be enabled, the env, java, os, and process contributors are disabled by default. The ssl contributor has a prerequisite of having an SSL Bundle configured but it is disabled by default. Each can be enabled by setting its management.info.<id>.enabled property to true.spring-doc.cadn.net.cn

The build and git info contributors are enabled by default. Each can be disabled by setting its management.info.<id>.enabled property to false. Alternatively, to disable every contributor that is usually enabled by default, set the management.info.defaults.enabled property to false.spring-doc.cadn.net.cn

Custom Application Information

When the env contributor is enabled, you can customize the data exposed by the info endpoint by setting info.* Spring properties. All Environment properties under the info key are automatically exposed. For example, you could add the following settings to your application.properties file:spring-doc.cadn.net.cn

info.app.encoding=UTF-8
info.app.java.source=17
info.app.java.target=17
info:
  app:
    encoding: "UTF-8"
    java:
      source: "17"
      target: "17"

Rather than hardcoding those values, you could also expand info properties at build time.spring-doc.cadn.net.cn

Assuming you use Maven, you could rewrite the preceding example as follows:spring-doc.cadn.net.cn

info:
  app:
    encoding: "@project.build.sourceEncoding@"
    java:
      source: "@java.version@"
      target: "@java.version@"

Git Commit Information

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, you can use the info endpoint to expose these properties.spring-doc.cadn.net.cn

A GitProperties bean is auto-configured if a git.properties file is available at the root of the classpath. See Generate Git Information for more detail.

By default, the endpoint exposes git.branch, git.commit.id, and git.commit.time properties, if present. 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 management.info.git.mode property, as follows:spring-doc.cadn.net.cn

management.info.git.mode=full
management:
  info:
    git:
      mode: "full"

To disable the git commit information from the info endpoint completely, set the management.info.git.enabled property to false, as follows:spring-doc.cadn.net.cn

management.info.git.enabled=false
management:
  info:
    git:
      enabled: false

Build Information

If a BuildProperties bean is available, the info endpoint can also publish information about your build. This happens if a META-INF/build-info.properties file is available in the classpath.spring-doc.cadn.net.cn

The Maven and Gradle plugins can both generate that file. See Generate Build Information for more details.

Java Information

The info endpoint publishes information about your Java runtime environment, see JavaInfo for more details.spring-doc.cadn.net.cn

OS Information

The info endpoint publishes information about your Operating System, see OsInfo for more details.spring-doc.cadn.net.cn

Process Information

The info endpoint publishes information about your process, see ProcessInfo for more details.spring-doc.cadn.net.cn

SSL Information

The info endpoint publishes information about your SSL certificates (that are configured through SSL Bundles), see SslInfo for more details. This endpoint reuses the "warning threshold" property of SslHealthIndicator: if an SSL certificate will be invalid within the time span defined by this threshold, it will trigger a warning. See the management.health.ssl.certificate-validity-warning-threshold property.spring-doc.cadn.net.cn

Writing Custom InfoContributors

To provide custom application information, you can register Spring beans that implement the InfoContributor interface.spring-doc.cadn.net.cn

The following example contributes an example entry with a single value:spring-doc.cadn.net.cn

import java.util.Collections;

import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.stereotype.Component;

@Component
public class MyInfoContributor implements InfoContributor {

	@Override
	public void contribute(Info.Builder builder) {
		builder.withDetail("example", Collections.singletonMap("key", "value"));
	}

}
import org.springframework.boot.actuate.info.Info
import org.springframework.boot.actuate.info.InfoContributor
import org.springframework.stereotype.Component
import java.util.Collections

@Component
class MyInfoContributor : InfoContributor {

	override fun contribute(builder: Info.Builder) {
		builder.withDetail("example", Collections.singletonMap("key", "value"))
	}

}

If you reach the info endpoint, you should see a response that contains the following additional entry:spring-doc.cadn.net.cn

{
	"example": {
		"key" : "value"
	}
}

Software Bill of Materials (SBOM)

The sbom endpoint exposes the Software Bill of Materials. CycloneDX SBOMs can be auto-detected, but other formats can be manually configured, too.spring-doc.cadn.net.cn

The sbom actuator endpoint will then expose an SBOM called "application", which describes the contents of your application.spring-doc.cadn.net.cn

To automatically generate a CycloneDX SBOM at project build time, please see the Generate a CycloneDX SBOM section.

Other SBOM formats

If you want to publish an SBOM in a different format, there are some configuration properties which you can use.spring-doc.cadn.net.cn

The configuration property management.endpoint.sbom.application.location sets the location for the application SBOM. For example, setting this to classpath:sbom.json will use the contents of the /sbom.json resource on the classpath.spring-doc.cadn.net.cn

The media type for SBOMs in CycloneDX, SPDX and Syft format is detected automatically. To override the auto-detected media type, use the configuration property management.endpoint.sbom.application.media-type.spring-doc.cadn.net.cn

Additional SBOMs

The actuator endpoint can handle multiple SBOMs. To add SBOMs, use the configuration property management.endpoint.sbom.additional, as shown in this example:spring-doc.cadn.net.cn

management.endpoint.sbom.additional.system.location=optional:file:/system.spdx.json
management.endpoint.sbom.additional.system.media-type=application/spdx+json
management:
  endpoint:
    sbom:
      additional:
        system:
          location: "optional:file:/system.spdx.json"
          media-type: "application/spdx+json"

This will add an SBOM called "system", which is stored in /system.spdx.json. The optional: prefix can be used to prevent a startup failure if the file doesn’t exist.spring-doc.cadn.net.cn