Spring Boot-monitoring management

1. Monitoring and management

By introducing spring-boot-starter-actuator, we can use the application monitoring and management functions in the quasi-production environment provided by Spring Boot. We can operate through HTTP, JMX, SSH protocols, and automatically get audit, health and indicator information, etc.

1. Introduce dependencies

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2. Configuration

server:
  port: 8015
spring:
  application:
    name: springboot-actuator
management:
  endpoints:
    web:
      exposure:
        include: "*" #打开所有的监控点
      base-path: /monitor #自定义监控路径默认为http://localhost:8015/actuator
  endpoint:
    health:
      show-details:  always
    shutdown:
      enabled: true #通过指定接口关闭springboot
# 描述项目基础信息
info:
  app:
    name: boot-actuator
    port: 8015
    version: 1.0.0
    author: glp

You can also configure individual permissions individually:

# 开启beans 、 mappings 访问
management.endpoints.web.exposure.include=beans,mappings

3. Access the monitoring endpoint through http

The details are as follows:

  • /auditevents : Display audit events exposed by the application (similar to authentication entry)
  • /beans: Display a complete list of all Spring Beans in the application
  • /caches: Publicly available cache/conditions: Shows the conditions evaluated on the configuration and automatic configuration classes and the reasons why they match or do not match
  • /configprops: Display a organized list of all @ConfigurationPropertie
  • /env: Get all environment properties
  • /flyway: Provide a copy of Flyway database migration information
  • /health: Display information about the running status of the application
  • /httptrace: Display HTTP tracking information (by default, the last 100 HTTP request-response exchanges)
  • /info: Get the customized information of the application, which is provided by the attribute at the beginning of info
  • /integrationgraph: Show Spring Integration diagram, need to depend on spring-integration-
    core
  • /loggers: Display and modify the configuration of the application
  • /liquibase: Display all Liquibase database migrations that have been applied
  • /metrics/{name} : Report application metrics for the specified name
  • /mappings: Display a list of all @RequestMapping paths
  • /scheduledtasks: Show the scheduled tasks in the application
  • /sessions: Allows retrieval and deletion of user sessions from the session storage supported by Spring Session, and requires the use of Spring Session Servlet-based web applications
  • /shutdown: Make the application close normally, disabled by default
  • /threaddump: Take a snapshot of thread activity

(1) Visit the project description information
http://localhost:8015/monitor/info
to write a git.properties to describe git related information
Insert picture description here

git.branch =master
git.commit.id = 3333
git.commit.time = 2017-12-12 12:12:12

Insert picture description here

(2) Access thread information
http://localhost:8015/monitor/threaddump
Insert picture description here

(3) HeapDump interface
Automatically generate Jvm heap dump file HeapDump, you can use the monitoring tool VisualVM to open this file to view the memory snapshot.
http://localhost:8015/monitor/headdump

(4) health
health is mainly used to check the running status of the application
http://localhost:8015/monitor/health

{
    
    "status":"UP","components":
{
    
    "diskSpace":
{
    
    "status":"UP","details":
{
    
    "total":149264121856,
"free":78478319616,
"threshold":10485760,
"exists":true}},
"ping":{
    
    "status":"UP"}}}

(5) Mappings interface
Description request mapping information
http://localhost:8015/monitor/mappings

{
    
    "contexts":{
    
    
"springboot-actuator":
{
    
    "mappings":
{
    
    "dispatcherServlets":
{
    
    "dispatcherServlet":
[{
    
    "handler":"Actuator web endpoint 'health'",
"predicate":
"{
    
    GET [/monitor/health], produces 

(6) Beans interface
shows the type of bean, singleton multiple instances, aliases, full path of the class, dependency Jar, etc.
http://localhost:8015/monitor/beans

(7) Conditions interface
Check under what conditions the configuration is valid, or why the automatic configuration is invalid.
http://localhost:8015/monitor/conditions

(8) ShutDown interface
gracefully shuts down Spring Boot applications, only POST requests are supported by default

Access by POST: http://localhost:8015/monitor/shutdown
Insert picture description here

Guess you like

Origin blog.csdn.net/glpghz/article/details/112978645