Python 官方文档:入门教程 => 点击学习
目录一、Actuator简介二、与SpringBoot2.0整合 1、核心依赖jar包2、Yml配置文件三、监控接口详解 1、Info接口2、Health接口3、
监控分类
<!-- 监控依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
# 端口
server:
port: 8016
spring:
application:
# 应用名称
name: node16-boot-actuator
management:
endpoints:
WEB:
exposure:
# 打开所有的监控点
include: "*"
# 自定义监控路径 monitor
# 默认值:http://localhost:8016/actuator/*
# 配置后:http://localhost:8016/monitor/*
base-path: /monitor
endpoint:
health:
show-details: always
shutdown:
# 通过指定接口关闭 SpringBoot
enabled: true
# 可以自定义端口
# server:
# port: 8089
# 描述项目基础信息
info:
app:
name: node16-boot-actuator
port: 8016
version: 1.0.0
author: cicada
Yml文件中配置的项目基础信息
路径:http://localhost:8016/monitor/info
输出:
{
"app": {
"name": "node16-boot-actuator",
"port": 8016,
"version": "1.0.0",
"author": "cicada"
}
}
health 主要用来检查应用的运行状态
路径:http://localhost:8016/monitor/health
输出:
{
"status": "UP",
"details": {
"diskSpace": {
"status": "UP",
"details": {
"total": 185496236032,
"free": 140944084992,
"threshold": 10485760
}
}
}
}
展示了 bean 的类型、单例多例、别名、类的全路径、依赖Jar等内容。
路径:http://localhost:8016/monitor/beans
输出:
{
"contexts": {
"node16-boot-actuator": {
"beans": {
"endpointCachinGoperationInvokerAdvisor": {
"aliases": [],
"scope": "singleton",
"type": "org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor",
"resource": "class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.class]",
"dependencies": ["environment"]
}
}
}
}
查看配置在什么条件下有效,或者自动配置为什么无效。
路径:http://localhost:8016/monitor/conditions
输出:
{
"contexts": {
"node16-boot-actuator": {
"positiveMatches": {
"AuditAutoConfiguration#auditListener": [{
"condition": "OnBeanCondition",
"message": "@ConditionalOnMissingBean"
}],
}
}
自动生成JVM的堆转储文件HeapDump,可以使用监控工具 VisualVM 打开此文件查看内存快照。
路径:http://localhost:8016/monitor/heapdump
描述 URI 路径和控制器的映射关系
路径:http://localhost:8016/monitor/mappings
输出:
{
"contexts": {
"node16-boot-actuator": {
"mappings": {
"dispatcherServlets": {
"dispatcherServlet": [ {
"handler": "Actuator web endpoint 'auditevents'",
"predicate": "{GET /monitor/auditevents || application/JSON]}",
"details": {
"handlerMethod": {
"className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebmvcEndpointHandlerMapping.Operat
"name": "handle",
"descriptor": "(Ljavax/servlet/http/httpservletRequest;Ljava/util/Map;)Ljava/lang/Object;"
},
"requestMappinGConditions": {
"consumes": [],
"headers": [],
"methods": ["GET"],
"params": [],
"patterns": ["/monitor/auditevents"],
"produces": [{
"mediaType": "application/vnd.spring-boot.actuator.v2+json",
"negated": false
}, {
"mediaType": "application/json",
"negated": false
}]
}
}
}
}
}
}
展示线程名、线程ID、是否等待锁、线程的状态、线程锁等相关信息。
路径:http://localhost:8016/monitor/threaddump
输出:
{
"threads": [{
"threadName": "DestroyJavaVM",
"threadId": 34,
"blockedTime": -1,
"blockedCount": 0,
"waitedTime": -1,
"waitedCount": 0,
"lockName": null,
"lockOwnerId": -1,
"lockOwnerName": null,
"inNative": false,
"suspended": false,
"threadState": "RUNNABLE",
"stackTrace": [],
"lockedMonitors": [],
"lockedSynchronizers": [],
"lockInfo": null
}
]
}
优雅关闭 Spring Boot 应用,默认只支持POST请求。
路径:http://localhost:8016/monitor/shutdown
GitHub地址:知了一笑
https://github.com/cicadasmile/spring-boot-base
码云地址:知了一笑
https://gitee.com/cicadasmile/spring-boot-base
以上就是SpringBoot配置Actuator组件,实现系统监控的详细内容,更多关于SpringBoot配置Actuator的资料请关注编程网其它相关文章!
--结束END--
本文标题: SpringBoot配置Actuator组件,实现系统监控
本文链接: https://lsjlt.com/news/128555.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0