HM-SpringBoot2.9.1【SpringBoot监控-actuator】

 

 

 

 

 

 


 

 

 

 

 

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 4 
 5     <modelVersion>4.0.0</modelVersion>
 6 
 7     <parent>
 8         <groupId>org.springframework.boot</groupId>
 9         <artifactId>spring-boot-starter-parent</artifactId>
10         <version>2.5.3</version>
11         <relativePath/> <!-- lookup parent from repository -->
12     </parent>
13 
14     <groupId>com.haifei</groupId>
15     <artifactId>springboot13-actuator</artifactId>
16     <version>0.0.1-SNAPSHOT</version>
17     <name>springboot13-actuator</name>
18     <description>Demo project for Spring Boot</description>
19 
20     <properties>
21         <java.version>1.8</java.version>
22     </properties>
23 
24     <dependencies>
25         <dependency>
26             <groupId>org.springframework.boot</groupId>
27             <artifactId>spring-boot-starter-actuator</artifactId>
28         </dependency>
29 
30         <dependency>
31             <groupId>org.springframework.boot</groupId>
32             <artifactId>spring-boot-starter-web</artifactId>
33         </dependency>
34 
35         <dependency>
36             <groupId>org.springframework.boot</groupId>
37             <artifactId>spring-boot-starter-test</artifactId>
38             <scope>test</scope>
39         </dependency>
40     </dependencies>
41 
42     <build>
43         <plugins>
44             <plugin>
45                 <groupId>org.springframework.boot</groupId>
46                 <artifactId>spring-boot-maven-plugin</artifactId>
47             </plugin>
48         </plugins>
49     </build>
50 
51 </project>

1 基本使用

(1)

 

 

 

 

(2)

https://www.cnblogs.com/yaoyuan2/p/11742242.html

 

 

 

 

 

 

 

 

 

 

management.endpoints.web.exposure.include=beans,env,health,info

info.name=zhangsan
info.age=22

 

 

 

 

 

UP表示健康,DOWN表示不健康

#https://www.cnblogs.com/yaoyuan2/p/11742242.html
management.endpoints.web.exposure.include=beans,env,health,info

info.name=zhangsan
info.age=22

#开启健康检查的完整信息
management.endpoint.health.show-details=always

 

 

 


 

 

本地redis服务器端未开启情况下:

 

 

 本地redis服务器端开启后:

 

 

 

 

 

 


 

2 开启所有endpoint

#https://www.cnblogs.com/yaoyuan2/p/11742242.html
#management.endpoints.web.exposure.include=beans,env,health,info

#老师课上演示[health,info]为默认暴露,我这里实操表明显然仅有[health]是默认暴露的
#将所有的监控endpoint暴露出来
management.endpoints.web.exposure.include=*

info.name=zhangsan
info.age=22

#开启健康检查的完整信息
management.endpoint.health.show-details=always

 

 

 

 

 

 

 

localhost:8080/actuator


{
  "_links": {
    "self": {
      "href": "http://localhost:8080/actuator",
      "templated": false
    },
    "beans": {
      "href": "http://localhost:8080/actuator/beans",
      "templated": false
    },
    "caches-cache": {
      "href": "http://localhost:8080/actuator/caches/{cache}",
      "templated": true
    },
    "caches": {
      "href": "http://localhost:8080/actuator/caches",
      "templated": false
    },
    "health": {
      "href": "http://localhost:8080/actuator/health",
      "templated": false
    },
    "health-path": {
      "href": "http://localhost:8080/actuator/health/{*path}",
      "templated": true
    },
    "info": {
      "href": "http://localhost:8080/actuator/info",
      "templated": false
    },
    "conditions": {
      "href": "http://localhost:8080/actuator/conditions",
      "templated": false
    },
    "configprops": {
      "href": "http://localhost:8080/actuator/configprops",
      "templated": false
    },
    "configprops-prefix": {
      "href": "http://localhost:8080/actuator/configprops/{prefix}",
      "templated": true
    },
    "env": {
      "href": "http://localhost:8080/actuator/env",
      "templated": false
    },
    "env-toMatch": {
      "href": "http://localhost:8080/actuator/env/{toMatch}",
      "templated": true
    },
    "loggers": {
      "href": "http://localhost:8080/actuator/loggers",
      "templated": false
    },
    "loggers-name": {
      "href": "http://localhost:8080/actuator/loggers/{name}",
      "templated": true
    },
    "heapdump": {
      "href": "http://localhost:8080/actuator/heapdump",
      "templated": false
    },
    "threaddump": {
      "href": "http://localhost:8080/actuator/threaddump",
      "templated": false
    },
    "metrics-requiredMetricName": {
      "href": "http://localhost:8080/actuator/metrics/{requiredMetricName}",
      "templated": true
    },
    "metrics": {
      "href": "http://localhost:8080/actuator/metrics",
      "templated": false
    },
    "scheduledtasks": {
      "href": "http://localhost:8080/actuator/scheduledtasks",
      "templated": false
    },
    "mappings": {
      "href": "http://localhost:8080/actuator/mappings",
      "templated": false
    }
  }
}

 

 

 

 

 

 


 

 1 package com.haifei.springboot13actuator;
 2 
 3 import org.springframework.stereotype.Controller;
 4 import org.springframework.web.bind.annotation.RequestMapping;
 5 
 6 @Controller
 7 @RequestMapping("/user")
 8 public class UserController {
 9 
10     @RequestMapping("/findAll")
11     public String findAll(){
12         return "success";
13     }
14 
15 }

 

 

订正

 

 

 

posted @ 2021-08-02 22:40  yub4by  阅读(55)  评论(0)    收藏  举报