1 应用实例
在Spring boot项目中的pom.xml添加如下:
1 2 3 4 5 6 |
<!-- 监控 beg--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- 监控 end--> |
2、配置文件
必须添加如下设置,否则,查看“http://localhost:8090/metrics” 会出现401错误
1 |
management.security.enabled=false |
3、直接输入:http://localhost:8090/metrics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
{ "mem": 702229, "mem.free": 262464, "processors": 4, "instance.uptime": 16893, "uptime": 70894, "systemload.average": 31.12158203125, "heap.committed": 641536, "heap.init": 131072, "heap.used": 379071, "heap": 1864192, "nonheap.committed": 61312, "nonheap.init": 24000, "nonheap.used": 60693, ... } |
4、/health查看服务健康状态
参考文献
介绍:https://www.baeldung.com/spring-boot-actuators