This website uses cookies to ensure you get the best experience on our website.

Skip to content
LOGO
  • Company

    About IGNEK

    Learn about our story and our mission.

    Careers

    We're hiring!

    We always looking for talented peoples. Join our team!

    Blogs

    The latest industry news, updates and info.

    Case Studies

    Take a closer look at the projects we've delivered

    Webinar

    Watch our latest organized webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Custom Enterprise Portal Development for flawless Solutions

    Dedicated Development Team

    Expand Teams, Optimize Development with Our Expertise

    Back-end Development

    Empowering your digital presence with robust backend development expertise

    Front-end Development

    Crafting engaging user experiences through expert frontend development

    Digital Transformation

    Embrace digital transformation by modernizing process

    SaaS Development

    Transform your business with SaaS Innovative Solutions

    Technologies

    Liferay Services

    Development & Customization

    Theme

    Upgradation

    Migration

    Proof of Concept

    Performance Tunning

    Architecture

    Support & Maintenance

    E-commerce

    Expert Advice

    React Services

    Enterprise Development

    Custom Application

    Single Page Application

    Architecture

    API Integration

    Migration

    Consulting

    Maintenance & Support

    Spring Boot Services

    Web Service

    MVC Web Development

    API Integration

    Security

    Migration

    Microservices

    Support & Maintenance

    AEM Services

    Consulting Service

    Site Development

    Migration & Upgradation

    Integration

    Maintenance & Support

    Custom Solutions

    Content Management

    Team Augementation

  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Transforming industries through cutting edge SaaS solutions.

    Customer Portal : Boost Business Productivity

    Streamline operations and enhance productivity with our Customer Portal solution.

    Liferay Based Intranet Portal

    Internal portal for company communication, collaboration and resources

    Integration

    Matomo Integration with Liferay

    Integrate Matomo to enable user interactions seamlessly.

    Microsoft Teams integration with Liferay

    Integrate to enable seamless collaboration, messaging within your portal.

    Jira Integration With Liferay

    Optimizes business operations by integrating with Jira.

  • Hire Us

    Liferay

    Get expert Liferay developers for seamless portal solutions.

    React JS

    Get expert ReactJS developers for dynamic web solutions.

    Web Developer

    Get custom web solutions from IGNEK's expert developers.

    Spring Boot

    Get top-notch Spring Boot developers for your project success!

    Healthcare

    Get top Healthcare Developers for cutting-edge medical software.

    MERN Stack

    Get expert MERN developers from IGNEK for custom, innovative project solutions.

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • info@ignek.com
    • Ahmedabad, Gujarat, India – 382470
SCHEDULE CALL
  • COMPANY
    • About
    • Case Studies
    • Blogs
    • Career
    • Webinar
  • SERVICES
    • Enterprise Portal Development
    • Dedicated Development Team
    • Back-end Development
    • Front-end Development
    • Digital Transformation
    • SaaS Development
  • SOLUTION
    • Customer Portal:  Boost Business Productivity
    • SaaS : Software as a Service
    • Liferay Based Employee Intranet Portal
  • TECHNOLOGY
    • Liferay Services
      • Liferay Development and Customization
      • Liferay Theme Development Service
      • Liferay DXP 7.4 Upgrade
      • Liferay Migration
      • Liferay Proof Of Concept
      • Liferay Performance Tuning
      • Liferay Architecture Design Service
      • Liferay Support And Maintenance Service
      • Liferay Ecommerce Development
      • Liferay Expert Advice
    • ReactJS Services
      • ReactJS Enterprise Application Development
      • ReactJS Custom Application Development
      • ReactJS Single Page Application Development (SPA)
      • ReactJS Applications Architecture
      • ReactJS API Integration
      • ReactJS Migration
      • ReactJS Consulting
      • ReactJS Maintenance and Support
    • Spring Boot Services
      • Spring Boot Web Development Service
      • Spring MVC Web Development
      • Spring Boot API Integration Service
      • Spring Boot Security
      • Spring Boot Migration Service
      • Spring Boot Microservices
      • Spring Boot Support & Maintenance Service
    • AEM Development Services
      • AEM Consulting Services
      • AEM Site Development
      • AEM Migration & Upgradation
      • AEM Integration Services
      • AEM Maintenance & Support
      • AEM Content Management
      • Custom AEM Solutions
      • AEM Team Augmentation
  • INTEGRATION
  • HIRE US
    • Hire Liferay Developer
    • Hire ReactJS Developer
    • Hire Spring Boot Developer
    • Hire Healthcare Developer
    • Hire Web Developer
    • Hire MERN Stack Developer
  • CONTACT US
  • Company

    About IGNEK

    Careers

    We're hiring!

    Blogs

    Case Studies

    Webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Dedicated Development Team

    Back-end Development

    Front-end Development

    Digital Transformation

    SaaS Development

    Technologies

    Liferay Liferay Services
    • Development & Customization
    • Theme
    • Upgradation
    • Migration
    • Proof of Concept
    • Performance Tuning
    • Architecture
    • Support & Maintenance
    • E-commerce
    • Expert Advice
    React React Services
    • Enterprise Development
    • Custom Application
    • Single Page Application
    • Architecture
    • API Integration
    • Migration
    • Consulting
    • Maintenance & Support
    Spring Boot Spring Boot Services
    • Web Service
    • MVC Web Development
    • API Integration
    • Security
    • Migration
    • Microservices
    • Support & Maintenance
    AEM AEM Services
    • Consulting Service
    • Site Development
    • Migration & Upgradation
    • Integration
    • Maintenance & Support
    • Custom Solutions
    • Content Management
    • Team Augmentation
  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Customer Portal : Boost Business Productivity

    Liferay Based Intranet Portal

    Integration

    Matomo Integration with Liferay

    Microsoft Teams integration with Liferay

    Jira Integration With Liferay

  • Hire Us

    Liferay

    React JS

    Web Developer

    Spring Boot

    Healthcare

    MERN Stack

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • IGNEK
    • Ahmedabad, Gujarat, India – 382470
  • SCHEDULE CALL

How to use Actuator effectively with spring boot 

  • Spring Boot
  • December 30, 2024

Share On :

Introduction

Spring boot actuators are essential tools for managing and monitoring the spring boot application program in production. Actuator provides auditing, health, CPU usage, HTTP hits, mapping, database,  etc. In this blog, we will learn how to use an actuator with a spring boot application.

Prerequisites
  • JDK 11 or Later
  • Maven or Gradle
  • Spring Boot Development Environment (Here we use IntelliJ IDEA)
What is an Actuator?

The actuator is mostly used to expose operational information about the running application. It provides production-ready features that help to manage and monitor spring boot applications using HTTP or JMX.

Actuator includes auditing, health, CPU usage, HTTP hits, metrics, etc.

Why use an Actuator?

The actuator is used to simply manage and monitor by : 

  1. Providing built-in health to check our application
  2. Exposing metrics for performing application
  3. Auditing the application
How to use an Actuator effectively with a spring boot application

Step 1 : Implementing  the spring boot application

  • First of all, we need a project setup so please go to Spring Initializer and set up the project as per our requirements.
  • Open IntelliJ IDEA and set up the project.
  • Add one helper package and in the package add on Student class and create a constructor.
				
					package com.example.acturator.helper;

import org.springframework.stereotype.Component;

@Component
public class Student {

  public Student() {
    System.out.println("Creating a object for student");
  }
}
				
			
  • Then, add one controller in the application and the controller creates one method.
				
					package com.example.acturator.controller;

import com.example.acturator.helper.Student;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class HomeController {

  private final Student student;

  public HomeController(Student student) {
    this.student = student;
  }

  @GetMapping
  public String hello(){
    return "Hello World";
  }

  @GetMapping("/data")
  @Timed(value = "controller.executeTime", description = "Time taken to process the Doc Ref API")
  public Map<String,String> getStudentData(){
    return Map.of("Name","Dhruvi");
  }
}
				
			
  • Then start to run the application and hit the following API in the browser.
    • http://localhost:8080/data
  • Showing the following output in the browser : 
				
					{
    "Name": "Dhruvi"
}
				
			

Step 2 : Adding dependency for Actuator in pom.xml

  • When we Add the following dependency for the Maven project in our application and then Re-run the application:
				
					<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
				
			
  •  Show the following O/P  after adding actuator dependency :
AfterRunActuatorDependency
  • In this o/p we will see that Exposing 1 endpoint.
  • Hit the following URL in the browser 
    • http://localhost:8080/actuator
  • O/P :
				
					// 20241224112450
// http://localhost:8080/actuator

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/actuator",
      "templated": false
    },
    "health-path": {
      "href": "http://localhost:8080/actuator/health/{*path}",
      "templated": true
    },
    "health": {
      "href": "http://localhost:8080/actuator/health",
      "templated": false
    }
  }
}
				
			
  • When click the /health then show the status is up.
				
					// 20241224121551
// http://localhost:8080/actuator/health

{
  "status": "UP
}

				
			

Step 3 : Configuring Actuator EndPoints

There are more configurations for the actuator, some are listed below : 

  1. We can also change the default endpoint /admin instead of /actuator by adding the following in the application.properties file.

				
					management.endpoints.web.base-path=/admin


				
			

2. Use Include endpoint which Actuator endpoints should be explicitly enabled.

    • To show all the exposed endpoints via HTTP.
				
					
management.endpoints.web.exposure.include=*


				
			
  • To show all the expose only the health and info endpoints via HTTP.
				
					management.endpoints.web.exposure.include: health,info
				
			

3. Use Exclude which Actuator endpoints should be explicitly disabled.

    • This will disable the shutdown endpoint, even if all other endpoints are exposed.
				
					
management.endpoints.web.exposure.exclude: shutdown


				
			

4. Other use cases of the Actuator include determining how long each API takes to execute

				
					
management.endpoints.web.exposure.include=*
management.metrics.enabled=true
management.observations.annotations.enabled=true


				
			
  • This enables the metrics feature in Spring Boot Actuator, allowing the application to collect and expose data like JVM memory usage, CPU usage, and API request counts.
  • This enables the use of the @Observed annotation for tracking custom metrics and performance observations.
  • Following steps to follow to run the application : 
    • Hit this URL in the postman:  http://localhost:8080/actuator
    • When hit the below URL then go to /metrics
    • And then hit API in the postman: http://localhost:8080/data
    • And then again hit the URL: http://localhost:8080/actuator/metrics
    • Show the our custom endpoint:
ShowCustomEndpointInMetrics
    • When hit the URL:  http://localhost:8080/actuator/metrics/controller.executeTime
    • To show the Total number of times the API was executed the total time spent executing the API across all calls, and the Maximum execution time for a single request.
ShowCustomEndpointTime

Step 4 : How to Create Custom  EndPoints

 We can also create custom endpoints in the actuator in the spring boot application, let’s see how to create it.

  • To create an actuator package and inside the package create one custom endpoint class.
				
					package com.example.acturator.actuator;

import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.stereotype.Component;

@Component
@Endpoint(id = "customEndpoint")
public class CustomEndpoints {

    @ReadOperation
    public String hello(){
      return "Hello World this is a custom endpoint!!";
    }

  @WriteOperation
  public String writeOperation(String name) {
    return "Hello, " + name;
  }

  @DeleteOperation
  public String deleteOperation() {
    return "Delete operation performed";
  }
}


				
			
  • @EndPoint: It is a marked class as a custom endpoint.
  • @ReadOperation: It handles the HTTP Get requests.
  • @WriteOperation:  It handles the HTTP Post requests.
  • @DeleteOperation: It handles the HTTP Delete requests.
  •  Then run the application hit the in the postman hit the following URLs and show the o/p.
    • http://localhost:8080/actuator
actuator
    • http://localhost:8080/actuator/customEndpoint
  1. Using get data: @ReadOperation annotation is used to read all the data from the application.
getCustomEndpoint

2. Using add data: @WriteOperation annotation is used to add data in the application.

addCustomEndpoint

3. Using delete data: @DeleteOperation annotation is used to delete data from the application.

deleteCustomEndpoint

Step 5: Other Actuator EndPoints

Endpoints

Description

Health 

To check the health of the application.

Info 

Display the arbitrary application information.

Metrics 

To check the application’s metrics, such as Memory and CPU usage.

Env 

Display the environment properties such as system properties and configuration properties.

Beans 

Display the list of all beans in the application.

Loggers 

Display and allow modification of logging levels for different packages and classes.

Mappings 

Display all HTTP request mapping in the application.

Threaddump 

Provide the thread dump of the application.

Httptrace 

Displays HTTP request and response trace information.

Scheduledtasks 

Display the list of all scheduled tasks in the application.

Heapdump 

Provides a heap dump of the application’s JVM.

Shutdown 

Allows gracefully shut down the application.

Conclusion

In this blog, we showed how to make an effective spring boot application using an actuator. To manage and monitor the application we used Actuator. and we can also check the health of the application, audit the application, and display some other actuator endpoints used in the spring boot application program. You can also add how to secure endpoints and how to create custom objects.

Explore Our Services

Discover how we can help your business thrive, whether you’re running a small startup, an SME, or a large enterprise. We’re here to understand your unique needs and goals, offering the expertise and resources to support your journey to success.

Stay informed about our Spring Boot services and updates by subscribing to our newsletter—just fill in the details below to subscribe.

Loading
Loading...

Related Blogs

June 7, 2024
Spring Boot With Swagger Integration
Spring Boot With Swagger Integration
December 23, 2024
Apache Kafka with Custom Objects in Spring Boot
Apache Kafka with Custom Objects in Spring Boot
December 23, 2024
Best Practices for Working with Spring Boot
Best Practices for Working with Spring Boot
Loading...

Featured Projects Portfolios

November 25, 2024
Liferay DXP Based Intranet Portal Migration from 7.0 to 7.4
Liferay DXP Based Intranet Portal Migration from 7.0 to 7.4
November 29, 2024
Public Enterprise Website for Laundry Services
Public Enterprise Website for Laundry Services
November 29, 2024
Employee Intranet Portal for Government Entity
Employee Intranet Portal for Government Entity

Digital Solutions for Your Business with IGNEK

4.9

5.0

5.0

5.0

LOGO

Making the world a better place through constructing elegant hierarchies

COMPANY

  • About
  • Career
  • Case Study
  • Blogs

SERVICES

  • Enterprise Portal Development
  • Dedicated Development Team
  • Back-end Development
  • Front-end Development
  • Digital Transformation
  • SaaS Development

HIRE US

  • Liferay
  • Spring Boot
  • ReactJS
  • Healthcare
  • MERN Stack
  • AEM

CONTACT

  • info@ignek.com
  • info@ignek.com
SALES
  • sales@ignek.com
  • (+91) 635 157 6580
CAREER
  • hr@ignek.com
  • (+91) 932 849 5160
  • E 910-912, Ganesh Glory 11, Jagatpur Road, SG Highway, Ahmedabad, Gujarat - 382470

© 2018-2025 IGNEK, Inc. All rights reserved

Linkedin Facebook X-twitter Instagram