Reference Link : Link

Donate : Link

Actuator endpoints let you monitor and interact with your application. Spring Boot includes a number of built-in endpoints and lets you add your own. For example, the health endpoint provides basic application health information.

By default, the health endpoint is mapped to /actuator/health.

The following table shows the default exposure for the built-in endpoints :

+-------------------+-----+-----+
| ID | JMX | WEB |
+-------------------+-----+-----+
| auditevents | Yes | No |
| beans | Yes | No |
| caches | Yes | No |
| conditions | Yes | No |
| configprops | Yes | No |
| env | Yes | No |
| flyway | Yes | No |
| health | Yes | Yes |
| heapdump | N/A | No |
| httptrace | Yes | No |
| info | Yes | Yes |
| integrationgraph | Yes | No |
| jolokia | N/A | No |
| logfile | N/A | No |
| loggers | Yes | No |
| liquibase | Yes | No |
| metrics | Yes | No |
| mappings | Yes | No |
| prometheus | N/A | No |
| scheduledtasks | Yes | No |
| sessions | Yes | No |
| shutdown | Yes | No |
| threaddump | Yes | No |
+-------------------+-----+-----+

To change which endpoints are exposed, use the following technology-specific include and exclude properties :

+-------------------------------------------+--------------+
| Property | Default |
+-------------------------------------------+--------------+
| management.endpoints.jmx.exposure.exclude | |
| management.endpoints.jmx.exposure.include | * |
| management.endpoints.web.exposure.exclude | |
| management.endpoints.web.exposure.include | info, health |
+-------------------------------------------+--------------+

To stop exposing all endpoints over JMX and only expose the health and info endpoints, use the following property :

management.endpoints.jmx.exposure.include=health,info

* can be used to select all endpoints. For example, to expose everything over HTTP except the env and beans endpoints, use the following properties :

management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans

* has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints, as shown in the following example :

management:
endpoints:
web:
exposure:
include: "*"

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.actuator</groupId>
<artifactId>Actuator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Actuator</name>
<description>Actuator Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

application.yml

management:
endpoints:
web:
exposure:
include: "*"

ActuatorApplication.java

package com.actuator;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ActuatorApplication {
public static void main(String[] args) {
SpringApplication.run(ActuatorApplication.class, args);
}
}

CustomActuator.java

package com.actuator;import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.stereotype.Component;
@Endpoint(id = "customPoint")
@Component
public class CustomActuator {
@ReadOperation
public String customPoint() {
return "Hello";
}
}

ActuatorController.java

package com.actuator.controller;import java.util.Date;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ActuatorController {
@GetMapping("/example")
public String example() {
return "Hello User !! " + new Date();
}
}

Reference Links :
1. https://start.spring.io
2. https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html