1. The background
One of the most common complaints about Spring component scanning and auto-weaving is that it’s hard to see how the components in your application are assembled. Is there a way to look inside your application, understand its behavior, and check its health? We’ll learn about Spring Boot’s Actuator. It provides many production-level features, such as monitoring and scaling Spring Boot applications
2. Enable the physical
To enable this, you need to add a dependency
compile 'org.springframework.boot:spring-boot-starter-actuator'
Copy the code
Only a small number of health nodes are enabled by default. To see more, we can turn more on during debugging by modifying the configuration file:
management:
endpoints:
web:
exposure:
include: "*"
Copy the code
Note: The formal environment must be closed.
At this time, open the web site: http://localhost:8080/actuator, you can see the following:
image.png
2. Common use actuator endpoint
Let’s start with a bit of analysis of the popular actuator endpoint
1) Get Bean assembly report /beans
To understand the Spring context in your application, the most important endpoint is/Beans. It returns a JSON document describing each Bean in context, including its Java type and any other beans injected.
Path: http://localhost:8080/actuator/beans
You can see something like the following:
image.png
2) Indicate health status /health
image.png
3) Environment variable /env
The /env endpoint generates a list of all environment attributes available to the application
image.png
4) Environment variables /mappings
The/Mappings endpoint provides such a list of all endpoints published by an application.
image.png
5) Measure the situation
Taking a snapshot of the runtime metrics can be helpful in assessing the health of your application. Actuator provides a series of endpoints that allow you to quickly inspect your app while it’s running.
image.png
Taking a snapshot of the runtime metrics can be helpful in assessing the health of your application. Actuator 7 provides a series of endpoints that allow you to quickly inspect your app while it’s running
3. Learn more
The Actuator contains many descriptive nodes, listed as follows:
image.png
Endpoint ID | Description | |
---|---|---|
auditevents | Display audit events exposed by the application (such as authentication entry, order failure) | |
info | Basic application information is displayed | |
health | Displays the application health status | |
metrics | Displays measurement information for a variety of applications | |
loggers | Displays and modifies configured loggers | |
logfile | Return the contents of the log file (if logging.file or logging.path is set) | |
httptrace | Displays HTTP footprints, the last 100 HTTP Requests /repsponse | |
env | Displays current environment features | |
flyway | Displays detailed information about the database migration path | |
liquidbase | Displays slim information about the Liquibase database migration | |
shutdown | Let you gradually shut down the application | |
mappings | Display all @requestMapping paths | |
scheduledtasks | Displays scheduling tasks in the application | |
threaddump | Perform a thread dump | |
heapdump | Returns a Gzip-compressed JVM heap dump |
Reference 3.
Docs. Spring. IO/spring – the boot…
www.jianshu.com/p/d5943e303…