Spring Boot | Endpoints
Endpoints
Adding spring-boot-starter-actuator as a dependency lets you retrieve system status through a web API.
build.gradle
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-actuator'
}
Main.java
package sample.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Main {
public static void main(String[] args) throws Exception {
SpringApplication.run(Main.class, args);
}
}
Start the application and access some URLs.
$ curl http://localhost:8080/health
{"status":"UP"}
$ curl http://localhost:8080/metrics
{"mem":253440,"mem.free":127785,"processors":8,"instance.uptime":51033,"uptime":53546,"systemload.average":-1.0,"heap.committed":253440,"heap.init":262144,"heap.used":125654,"heap":3717632,"threads.peak":16,"threads.daemon":14,"threads":16,"classes":5490,"classes.loaded":5490,"classes.unloaded":0,"gc.ps_scavenge.count":3,"gc.ps_scavenge.time":39,"gc.ps_marksweep.count":1,"gc.ps_marksweep.time":44,"httpsessions.max":-1,"httpsessions.active":0,"counter.status.200.health":1,"counter.status.200.metrics":1,"gauge.response.health":47.0,"gauge.response.metrics":23.0}
The following table lists some endpoints.
| id | Description |
|---|---|
| dump | Thread dump |
| env | System properties, environment variables, and property file settings |
| health | Application status |
| metrics | Memory usage, thread count, garbage collection count, and more |
| trace | Recent access history |
| shutdown | Stops the application when accessed with the POST method. Disabled by default. |
There are also additional endpoints.