SpringBoot监控
#
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
{ "_links":{ "self":{ "href":"http://localhost:8080/actuator", "templated":false }, "health":{ "href":"http://localhost:8080/actuator/health", "templated":false }, "health-component-instance":{ "href":"http://localhost:8080/actuator/health/{component}/{instance}", "templated":true }, "health-component":{ "href":"http://localhost:8080/actuator/health/{component}", "templated":true }, "info":{ "href":"http://localhost:8080/actuator/info", "templated":false } } }
info相关:#
http://localhost:8080/actuator/info
info.name=lucy
info.age=99
结果:
{"name":"zhangsan","age":"23"}
http://localhost:8080/actuator/health
开启健康检查详细信息:#
# 开启健康检查的完整信息
management.endpoint.health.show-details=always
结果:
{"status":"UP","details":{"diskSpace":{"status":"UP","details":{"total":128726331392,"free":41764163584,"threshold":10485760}},"redis":{"status":"UP","details":{"version":"3.2.100"}}}}
#
开启所有endpoint,在application.properties中配置:
# 将所有的监控endpoint暴露出来
management.endpoints.web.exposure.include=*
开启所有endpoint的返回结果:
{ "_links":{ "self":{ "href":"http://localhost:8080/actuator", "templated":false }, "auditevents":{ "href":"http://localhost:8080/actuator/auditevents", "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-component-instance":{ "href":"http://localhost:8080/actuator/health/{component}/{instance}", "templated":true }, "health":{ "href":"http://localhost:8080/actuator/health", "templated":false }, "health-component":{ "href":"http://localhost:8080/actuator/health/{component}", "templated":true }, "conditions":{ "href":"http://localhost:8080/actuator/conditions", "templated":false }, "configprops":{ "href":"http://localhost:8080/actuator/configprops", "templated":false }, "env":{ "href":"http://localhost:8080/actuator/env", "templated":false }, "env-toMatch":{ "href":"http://localhost:8080/actuator/env/{toMatch}", "templated":true }, "info":{ "href":"http://localhost:8080/actuator/info", "templated":false }, "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 }, "httptrace":{ "href":"http://localhost:8080/actuator/httptrace", "templated":false }, "mappings":{ "href":"http://localhost:8080/actuator/mappings", "templated":false } } }
#
SpringBoot Admin 有两个角色,客户端(Client)和服务端(Server)。
admin-server:#
①创建 admin-server 模块
②导入依赖坐标 admin-starter-server
<dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> </dependency>
③在引导类上启用监控功能@EnableAdminServer
@EnableAdminServer @SpringBootApplication public class SpringbootAdminServerApplication { public static void main(String[] args) { SpringApplication.run(SpringbootAdminServerApplication.class, args); } }
admin-client:#
①创建 admin-client 模块
②导入依赖坐标 admin-starter-client
<dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> </dependency>
③配置相关信息:server地址等
# 执行admin.server地址 spring.boot.admin.client.url=http://localhost:9000 management.endpoint.health.show-details=always management.endpoints.web.exposure.include=*
④启动server和client服务,访问server,有很多监控到的信息。(某个请求访问的次数,所有的beans,JVM相关的,线程执行情况)
分类:
SpringBoot专题
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
2019-07-12 递归函数 算法之二分法 三元表达式 字典生成式 匿名函数 常用的内置函数(map、zip、reduce)