Şuayb's BlogŞuayb's Blog
Home
Categories
Games
MediumAboutContact
Language
Theme
    1. Blog
    2. Programming
    3. Spring Boot Actuator

Spring Boot Actuator

PublishedDecember 18, 2024
UpdatedDecember 19, 2024
Reading time3 min read
JavaKotlinSpring BootActuatorMonitoring
XLinkedInFacebook
Spring Boot Actuator

Loading likes...

Spring Boot Actuator provides production-ready features to monitor and manage your applications. This guide explores Actuator's capabilities, how to enable it, and secure its endpoints.


Last updatedDecember 19, 2024

Total viewsLoading hits...

Previous articleAspect-Oriented Programming in Spring BootNext articleSpring Boot DevTools
Şuayb Şimşek

Written by

Şuayb Şimşek

Backend-focused fullstack developer sharing practical notes on Spring Boot, security, microservices, and cloud-native architecture.

Expertise

  • Spring Boot
  • Go
  • Microservices
  • Next.js
  • Cloud Native

Connect

GitHubLinkedInMedium

Related posts

Spring Boot Configuration Properties
Programming

Spring Boot Configuration Properties

Learn how to use @ConfigurationProperties for type-safe configuration, validate settings with @Validated, and manage environment-specific values with profile-specific application-{profile}.yml files.

February 4, 20263 min read
JavaKotlinSpring BootConfiguration
Spring Boot GraphQL JWE Authentication
Programming

Spring Boot GraphQL JWE Authentication

Learn how to secure your Spring Boot GraphQL APIs with stateless encrypted JWTs (JWE) while persisting user identities and roles in a JPA-backed database.

May 17, 20256 min read
JavaKotlinSpring BootSecurityJWTJWEGraphQL
Spring Boot JWE Authentication with JPA
Programming

Spring Boot JWE Authentication with JPA

Learn how to use stateless encrypted JWTs (JWE) to secure your Spring Boot APIs while persisting user identities and roles in a JPA-backed database.

May 11, 20254 min read
JavaKotlinSpring BootSecurityJWTJWEJPA

About

Articles on Spring Boot, microservices, security, and more.

ContactStart here

Latest posts

  • Captain Tsubasa 2: World Fighters
  • Captain Tsubasa: Rise of New Champions
  • Spring Boot Configuration Properties
  • Spring Boot GraphQL JWE Authentication
  • Spring Boot JWE Authentication with JPA

Top topics

JavaKotlinSpring BootJWEJWTMicroservice

Subscribe

Get practical backend + fullstack notes when new articles are published.

Social

© 2024-2026 Şuayb's Blog. All rights reserved.

🌟 Why Use Spring Boot Actuator?

Spring Boot Actuator allows developers to:

  • Monitor application health
  • Gather metrics and information
  • Expose management endpoints for operational tasks

📋 Prerequisites

📋 Ensure you have the following:

  • ☕ Java Development Kit (JDK) 17+
  • 💼 Maven or Gradle installed
  • 🄄 A Java IDE (e.g., IntelliJ IDEA, Eclipse)

🛠️ Step 1: Add Dependencies

To enable Actuator, add the following dependency to your Spring Boot project:

  • Maven:
XMLpom.xml
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  • Gradle:
GROOVYbuild.gradle
implementation 'org.springframework.boot:spring-boot-starter-actuator'

🛠️ Step 2: Enable Actuator Endpoints

By default, Actuator exposes several endpoints to provide application insights. You can enable these endpoints in your application.properties or application.yml file.

Configuration Example:

Use this configuration as a baseline and adjust values for your local or production environment.

PROPERTIESconfig.properties
management.endpoints.web.exposure.include=health,info,metrics
management.endpoint.health.show-details=always

🛠️ Step 3: Using Actuator Endpoints

Here are some commonly used Actuator endpoints:

  • /actuator/health: Provides application health status.
  • /actuator/info: Displays application metadata.
  • /actuator/metrics: Offers application performance metrics.

You can access these endpoints via a browser or API tools like cURL.

Example:

BASH
curl -X GET http://localhost:8080/actuator/health

🛠️ Step 4: Customize Actuator Endpoints

You can customize Actuator endpoints to suit your needs. For example, you can define additional metadata in the application.properties file for the /actuator/info endpoint:

PROPERTIESconfig.properties
info.app.name=My Application
info.app.version=1.0.0
info.app.description=Spring Boot Actuator Example

🛠️ Step 5: Secure Actuator Endpoints

For production environments, it's essential to secure Actuator endpoints. Use Spring Security to restrict access.


▶️ Running the Application

Run the application using the following command:

BASH
./mvnw spring-boot:run

Access the Actuator endpoints at:

FILENAME
http://localhost:8080/actuator/health

🧪 Test the API

You can test the Actuator endpoints using cURL or browser:

  • Health Endpoint:
BASH
curl -X GET http://localhost:8080/actuator/health
  • Info Endpoint:
BASH
curl -X GET http://localhost:8080/actuator/info

🏁 Conclusion

You now have a practical Spring Boot Actuator implementation with a clear, production-friendly Spring Boot structure. As a next step, adapt configuration and tests to your own domain, then validate behavior under realistic traffic and failure scenarios.

Example Security Configuration

JAVASecurityConfig.java
package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
public class SecurityConfig {

    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests()
                .requestMatchers("/actuator/**").hasRole("ADMIN")
                .anyRequest().authenticated()
            .and()
            .httpBasic();
        return http.build();
    }
}

Example Security Configuration

KOTLINSecurityConfig.kt
package com.example.demo.config

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
class SecurityConfig {

    @Bean
    fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
        http
            .authorizeHttpRequests()
                .requestMatchers("/actuator/**").hasRole("ADMIN")
                .anyRequest().authenticated()
            .and()
            .httpBasic()
        return http.build()
    }
}