liveBook · Manning

Spring Boot Actuator

As explained in Spring in Action, Sixth Edition

Spring Boot Actuator is a Spring Boot module that exposes operational and management information about a running application.

Spring Boot Actuator lets you look inside a running application instead of guessing how it is behaving. Its endpoints report information such as health, metrics, configuration properties, logging levels, and request counts. They are available through HTTP and, with the exception of the heap dump endpoint, as JMX MBeans. section 15.0 section 15.1

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Add this starter dependency to a Spring Boot Maven project to enable Actuator’s out-of-the-box endpoints. section 15.1

Start with two questions: What application is this, and is it healthy? An HTTP GET to /actuator/info returns application information; by default, its response may be just {}. Properties prefixed with info supply values for that response. An HTTP GET to /actuator/health returns a health status, such as {"status":"UP"}. section 15.2.1

Add support contact information

Put `info.contact.email: support@tacocloud.com` in application.yml. The /actuator/info response then includes that email under contact. To request more than the basic health status, set `management.endpoint.health.show-details: always`; the detailed response can include MongoDB and disk-space health. section 15.2.1

Most endpoints are disabled by default; use `management.endpoints.web.exposure.include` and `management.endpoints.web.exposure.exclude` to choose which web endpoints to expose. Treat that choice carefully: endpoints such as /env and /loggers can change a running application’s configuration. section 15.5

@Override
protected void configure(HttpSecurity http) throws Exception {
  http
    .requestMatcher(EndpointRequest.toAnyEndpoint())
      .authorizeRequests()
        .anyRequest().hasRole("ADMIN")
    .and()
    .httpBasic();
}

Actuator does not secure its own endpoints. This Spring Security configuration requires ROLE_ADMIN for requests matched by `EndpointRequest.toAnyEndpoint()`, avoiding a hardcoded /actuator/** path that could become wrong if the base path changes. section 15.4

How Spring in Action, Sixth Edition covers it

How deep it goes
Shows starter setup, endpoint requests, health configuration, exposure settings, and security matching; defers JMX endpoint treatment.
Examples
Uses curl requests for /actuator/info and /actuator/health, YAML contact properties, and a ROLE_ADMIN endpoint matcher.
What it assumes
Assumes a Spring Boot application and Maven build while introducing Actuator setup through its starter dependency.
What you can do after
Operate/configure it by adding the Maven starter, inspecting HTTP endpoints, selecting exposure, and restricting access with Spring Security.
How it connects
Connects application health, environment properties, logging levels, Micrometer metrics, and Spring Security.

Also explained in

Compare how 2 books explain Spring Boot Actuator →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.