Custom Actuator Endpoints in Spring Boot 3

Spring Boot Actuator provides several out-of-the-box endpoints like /actuator/health, /metrics, and /info. But what if you need application-specific diagnostics?

That’s where Custom Actuator Endpoints in Spring Boot come into play. You can easily create your own endpoints to expose internal state, cache info, system checks, and more.

In this tutorial, you’ll learn:

  • How to create a custom actuator endpoint
  • Different types of endpoints (read-only, write, delete)
  • How to expose and secure them
  • How to integrate with Spring Boot 3 changes
Custom Actuator Endpoints in Spring Boot 3

🧱 Step 1: Add Required Dependencies

Make sure you include the Actuator module:

Optionally, you may include Spring Security if you plan to secure it:

πŸ› οΈ Step 2: Create a Custom Actuator Endpoint

Spring Boot 3 uses @Endpoint, @ReadOperation, @WriteOperation, and @DeleteOperation.

πŸ“ Example: Cache Monitoring Endpoint

Now, you can access it via:

πŸ§‘β€πŸ”§ Step 3: Enable the Custom Endpoint

By default, only certain endpoints are exposed. You’ll need to include your custom endpoint in application.yml:

✏️ Other Operation Types

πŸ”„ Write Operation Example

❌ Delete Operation Example

These map to:

  • POST /actuator/cache-stats
  • DELETE /actuator/cache-stats

πŸ” Step 4: Securing Custom Actuator Endpoints

Spring Security allows you to lock down endpoints.

πŸ§ͺ Step 5: Testing the Endpoint

Make a GET request:

Expected output:

Or for the write operation:

πŸ“˜ Summary

  • Custom Actuator Endpoints in Spring Boot allow developers to expose app-specific data for observability.
  • Use annotations like @Endpoint, @ReadOperation, @WriteOperation, and @DeleteOperation.
  • You can secure these endpoints using Spring Security and expose only what’s necessary.
  • Great for diagnostics, monitoring, troubleshooting, or DevOps tooling.

πŸ”— Resources