DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • WireMock: The Ridiculously Easy Way (For Spring Microservices)
  • Using OpenAI Embeddings Search With SingleStoreDB
  • Designing a New Framework for Ephemeral Resources
  • A Data-Driven Approach to Application Modernization

Trending

  • WireMock: The Ridiculously Easy Way (For Spring Microservices)
  • Using OpenAI Embeddings Search With SingleStoreDB
  • Designing a New Framework for Ephemeral Resources
  • A Data-Driven Approach to Application Modernization
  1. DZone
  2. Coding
  3. Frameworks
  4. Spring Boot Actuator

Spring Boot Actuator

An actuator is a spring boot sub-project that helps to expose production-ready support features against Spring boot application.

Nikesh Pathak user avatar by
Nikesh Pathak
·
Updated Jul. 24, 20 · Tutorial
Like (6)
Save
Tweet
Share
18.10K Views

Join the DZone community and get the full member experience.

Join For Free

Key Features Offered by an Actuator

  • Health check: You can use a health endpoint to check the status of your running application.
  • Monitoring and Management over HTTP/JMX: Actuator support HTTP endpoint as well as Java Management Extensions (JMX) to provide a standard mechanism to monitor and manage applications.
    • Logger: It provides a feature to view and update the logs level.
    • Metrics: Spring Boot Actuator provides dependency management and auto-configuration for Micrometer, an application metrics facade that supports numerous monitoring systems.
    • Auditing: 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.
    • Http Tracing: HTTP Tracing can be enabled by providing a bean of type HttpTraceRepository in your application’s configuration. For convenience, Spring Boot offers an InMemoryHttpTraceRepository that store traces for the last 100 request-response exchanges
    • Process Monitoring

Enable Actuator Into Spring Boot Project

You can enable Actuator into Spring boot project by including below dependency.

Java
 




x


 
1
//Gradle
2
org.springframework.boot:spring-boot-starter-actuator:2.3.1.RELEASE
3
//Maven
4
<dependency>
5
    <groupId>org.springframework.boot</groupId>
6
    <artifactId>spring-boot-starter-actuator</artifactId>
7
    <version>2.3.1.RELEASE</version>
8
</dependency>



Endpoint Offer by Actuator

By default ‘health’ and ‘info’ endpoint is enabled

localhost

Default exposed endpoint.

Other endpoints are sensitive and not advisable to expose to the production environment without security. As we are demonstrating, let’s expose all the APIs.

Java
 




x


 
1
management.endpoints.web.exposure.include=*



localhost

Include and Exclude Endpoint.

Even you can include or exclude endpoint by defining below properties

Plain Text
 




x


 
1
# wild card to include/exclude all
2
management.endpoints.web.exposure.include=* 
3
management.endpoints.web.exposure.exclude=* 
4
 
          
5
# you can include specific properties like below
6
management.endpoints.web.exposure.include=env,beans
7
management.endpoints.web.exposure.exclude=heapdump



Customize Management Server Address

You can customize the management server port, it will help you define the limited scope to the ports.

management.server.port=8081
management.server.address=127.0.0.1

Expose Custom Endpoint

Any methods annotated with @ReadOperation, @WriteOperation, or @DeleteOperation are automatically exposed over JMX and HTTP. Even you can expose technology-specific endpoint by using @JmxEndpoint or @WebEndpoint.

Here I’m sharing you example for exposing endpoint using Spring boot 2.x

Java
 




xxxxxxxxxx
1
14


 
1
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
2
import org.springframework.stereotype.Component;
3
 
4
@Component
5
@org.springframework.boot.actuate.endpoint.annotation.Endpoint(id = "say-hello")
6
public class Endpoint {
7
 
8
    @ReadOperation
9
    public String sayHello()
10
    {
11
        return "Hello World";
12
    }
13
 
14
}



Summary: Spring boot actuator is one of the best libraries you can add in your application to enable production-ready features in less effort. it offers key features that can be used in day to day production support.

Spring Framework Spring Boot

Opinions expressed by DZone contributors are their own.

Trending

  • WireMock: The Ridiculously Easy Way (For Spring Microservices)
  • Using OpenAI Embeddings Search With SingleStoreDB
  • Designing a New Framework for Ephemeral Resources
  • A Data-Driven Approach to Application Modernization

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: