Article Directory
- 1. Quick Start
- 2. Monitor and manage endpoint 3. Customizing Endpoints
- 2.1. Health usage Indicators
- 2.2. Info View app Information
- 2.3. Metrics application Basic indicators
- 2.4. Trace Basic HTTP trace Information
- 2.5. shutdown close the current app
- 4. Source Code
Spring Boot provides runtime application monitoring and management capabilities. In this paper, we monitor and manage the application through HTTP.
Quick Start
Spring Boot monitoring Core is spring-boot-starter-actuator dependency, after increasing the dependency, spring boot will default to configure some common monitoring, such as JVM monitoring, class loading, health monitoring and so on.
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
If you use HTTP calls, you also need to spring-boot-starter-web dependencies.
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
monitoring and managing endpoints
The current supported monitoring is listed in the latest Spring Boot version 1.4.3.
http Method |
Path |
Description |
GET |
/actuator |
See a list of all endpoint and need to join Spring HATEOAS support |
GET |
/autoconfig |
View the usage of automatic configuration for an app |
GET |
/beans |
View information about all the beans that are applied |
GET |
/configprops |
View all configuration properties for an app |
GET |
/dump |
To view thread state information for an app |
GET |
/env |
View all environment information for an app |
GET |
/flyway |
View migration Routes Database migrations |
GET |
/health |
View App Health Metrics |
GET |
/info |
View app Information |
GET |
/liquibase |
View an already Liquibase database migration app |
GET |
/mappings |
View all URL mappings |
GET |
/metrics |
View App Basic Metrics |
POST |
/shutdown |
Allows graceful closing of the current app (not enabled by default) |
GET |
/trace |
To view basic HTTP trace Information |
GET |
/docs |
To view documents, you need to rely on Spring-boot-actuator-docs |
GET |
/heapdump |
Returns an gzip compressed hprof heap dump file |
GET |
/jolokia |
Exposing JMX beans (when Jolokia path) |
GET |
/LogFile |
View the contents of the log file (if the Logging.file or Logging.path property is set). Supports the use of portions of the HTTP range header to log files to recover content. |
|
Health usage Indicators
We can pass the Http://localhost:8080/health, statistical system status, the default inside currently only system conditions and disk status. These detectors are implemented through the Healthindicator interface, and in the next article I will explain the custom health detection through the Healthindicator interface.
Info View app Information
By default, only an empty JSON content is returned. We can set some properties through the info prefix in the application.properties configuration file.
- Info. Author. Realname= Liang
- Info. Author. Nickname=lianggzone
We can also set some properties in the Application.yml configuration file.
- Info. Author:
- Email: [email protected]. COM
- Blog: http://blog.720ui.com
Metrics application Basic indicators
We can get all kinds of important metrics of current application through http://localhost:8080/metrics, such as: memory information, thread information, garbage collection information, etc.
We can also get more granular metrics through the/metrics/{name} interface, such as we can access the/metrics/mem.free to get the current amount of available memory.
Trace Basic HTTP trace Information
View basic HTTP trace information. By default, the storage of tracking information takes the form of memory implemented by Org.springframework.boot.actuate.trace.InMemoryTraceRepository and always retains the last 100 request records.
shutdown close the current app
The shutdown endpoint is not enabled by default and we can open it in application.properties. In addition, the shutdown endpoint does not support GET requests and we need to access them via the POST method.
- Endpoints. Shutdown. Enabled=true
Customizing Endpoints
Endpoints can be customized in the Spring Boot configuration file. For example, above, we open the shutdown endpoint.
- Endpoints. Shutdown. Enabled=true
The prefix for the endpoint is, Endpoints + "." + END name.
The default endpoint access path is the root directory, which we can customize by modifying the configuration.
- Management. Context-path=/manage
At this point, our access address becomes: Http://localhost:8080/manage/info
In addition, the default monitoring interface port is consistent with the port of the business, and we can change the access port of the endpoint for security reasons.
- Management. Port=9090
We can even close the HTTP endpoint.
- Management. Port=-1
Source Code
Related example complete code: springboot-action
Finish
If you feel that my article is helpful to you, please feel free to make a reward.
- Copyright NOTICE: This article was published by Liang in Liang Blog
- Reprint statement: Free reprint-Non-commercial-non-derivative-maintain attribution (Creative Sharing 3.0 license), non-commercial reprint please indicate the author and source, commercial reprint please contact the author himself.
- Article title: Spring Boot Secrets and Combat (ix) Application monitoring-HTTP application monitoring
- Article Link: http://blog.720ui.com/2017/springboot_09_actuator_http/
Spring Boot Uncover and Combat (ix) Application monitoring-HTTP application monitoring