spring-boot-actuator
查看默认支持的
常用API
查看可用的端点
curl http://127.0.0.1:8080/actuator
响应

{ "_links": { "self": { "href": "http://127.0.0.1:8080/actuator", "templated": false }, "archaius": { "href": "http://127.0.0.1:8080/actuator/archaius", "templated": false }, "arthas": { "href": "http://127.0.0.1:8080/actuator/arthas", "templated": false }, "nacos-discovery": { "href": "http://127.0.0.1:8080/actuator/nacos-discovery", "templated": false }, "sentinel": { "href": "http://127.0.0.1:8080/actuator/sentinel", "templated": false }, "auditevents": { "href": "http://127.0.0.1:8080/actuator/auditevents", "templated": false }, "beans": { "href": "http://127.0.0.1:8080/actuator/beans", "templated": false }, "caches": { "href": "http://127.0.0.1:8080/actuator/caches", "templated": false }, "caches-cache": { "href": "http://127.0.0.1:8080/actuator/caches/{cache}", "templated": true }, "health-component": { "href": "http://127.0.0.1:8080/actuator/health/{component}", "templated": true }, "health-component-instance": { "href": "http://127.0.0.1:8080/actuator/health/{component}/{instance}", "templated": true }, "health": { "href": "http://127.0.0.1:8080/actuator/health", "templated": false }, "conditions": { "href": "http://127.0.0.1:8080/actuator/conditions", "templated": false }, "shutdown": { "href": "http://127.0.0.1:8080/actuator/shutdown", "templated": false }, "configprops": { "href": "http://127.0.0.1:8080/actuator/configprops", "templated": false }, "env-toMatch": { "href": "http://127.0.0.1:8080/actuator/env/{toMatch}", "templated": true }, "env": { "href": "http://127.0.0.1:8080/actuator/env", "templated": false }, "info": { "href": "http://127.0.0.1:8080/actuator/info", "templated": false }, "logfile": { "href": "http://127.0.0.1:8080/actuator/logfile", "templated": false }, "loggers": { "href": "http://127.0.0.1:8080/actuator/loggers", "templated": false }, "loggers-name": { "href": "http://127.0.0.1:8080/actuator/loggers/{name}", "templated": true }, "heapdump": { "href": "http://127.0.0.1:8080/actuator/heapdump", "templated": false }, "threaddump": { "href": "http://127.0.0.1:8080/actuator/threaddump", "templated": false }, "prometheus": { "href": "http://127.0.0.1:8080/actuator/prometheus", "templated": false }, "metrics-requiredMetricName": { "href": "http://127.0.0.1:8080/actuator/metrics/{requiredMetricName}", "templated": true }, "metrics": { "href": "http://127.0.0.1:8080/actuator/metrics", "templated": false }, "scheduledtasks": { "href": "http://127.0.0.1:8080/actuator/scheduledtasks", "templated": false }, "httptrace": { "href": "http://127.0.0.1:8080/actuator/httptrace", "templated": false }, "mappings": { "href": "http://127.0.0.1:8080/actuator/mappings", "templated": false }, "refresh": { "href": "http://127.0.0.1:8080/actuator/refresh", "templated": false }, "features": { "href": "http://127.0.0.1:8080/actuator/features", "templated": false }, "service-registry": { "href": "http://127.0.0.1:8080/actuator/service-registry", "templated": false }, "mq": { "href": "http://127.0.0.1:8080/actuator/mq", "templated": false } } }
查看可用的指标
curl http://127.0.0.1:8080/actuator/metrics
响应

{ "names": [ "process.uptime", "tomcat.threads.current", "kafka.consumer.connection.close.total", "jvm.threads.states", "sentinel.blockQps", "jvm.memory.max", "tomcat.sessions.rejected", "executor.active", "kafka.consumer.records.consumed.total", "http.server.requests", "process.cpu.usage", "jvm.classes.loaded", "tomcat.threads.busy", "jvm.buffer.memory.used", "jvm.memory.committed", "sentinel.threadNum", "jvm.classes.unloaded", "sentinel.oneMinuteException", "tomcat.sessions.active.current", "sentinel.averageRt", "kafka.consumer.fetch.throttle.time.avg", "kafka.consumer.fetch.throttle.time.max", "kafka.consumer.bytes.consumed.total", "jvm.memory.used", "tomcat.sessions.alive.max", "jvm.gc.live.data.size", "sentinel.totalQps", "kafka.consumer.join.time.avg", "kafka.consumer.join.time.max", "kafka.consumer.fetch.total", "kafka.consumer.sync.time.avg", "kafka.consumer.sync.time.max", "kafka.consumer.records.per.request.avg", "process.files.open", "jvm.gc.pause", "kafka.consumer.commit.latency.avg", "kafka.consumer.commit.latency.max", "kafka.consumer.assigned.partitions", "tomcat.sessions.active.max", "jvm.minorVersion", "sentinel.oneMinuteTotal", "kafka.consumer.connection.creation.total", "kafka.consumer.connection.count", "executor.pool.size", "executor.queued", "tomcat.global.sent", "process.start.time", "executor.completed", "sentinel.exceptionQps", "kafka.consumer.records.lag", "kafka.consumer.join.rate", "kafka.consumer.commit.rate", "kafka.consumer.io-wait-time-avg", "sentinel.oneMinuteBlock", "process.files.max", "tomcat.global.request.max", "jvm.gc.memory.promoted", "logback.events", "sentinel.oneMinutePass", "kafka.consumer.fetch.size.avg", "kafka.consumer.fetch.size.max", "tomcat.global.request", "kafka.consumer.io-time-avg", "kafka.consumer.heartbeat.rate", "system.load.average.1m", "kafka.consumer.sync.rate", "sentinel.passQps", "jvm.gc.max.data.size", "kafka.consumer.select.total", "kafka.consumer.fetch.latency.avg", "kafka.consumer.fetch.latency.max", "kafka.consumer.io.ratio", "kafka.consumer.io.wait.ratio", "system.cpu.count", "tomcat.global.received", "jvm.buffer.count", "kafka.consumer.records.lead.avg", "kafka.consumer.records.lead.min", "jvm.buffer.total.capacity", "sentinel.successQps", "kafka.consumer.records.lag.avg", "kafka.consumer.records.lag.max", "kafka.consumer.last-heartbeat", "tomcat.sessions.created", "jvm.threads.daemon", "system.cpu.usage", "jvm.gc.memory.allocated", "tomcat.threads.config.max", "jvm.majorVersion", "tomcat.global.error", "tomcat.sessions.expired", "kafka.consumer.heartbeat.response.time.max", "jvm.threads.live", "jvm.threads.peak", "kafka.consumer.records.lead" ] }
查看tomcat相关
curl http://127.0.0.1:8080/actuator/metrics/tomcat.threads.busy
响应

{ "name": "tomcat.threads.busy", "description": null, "baseUnit": "threads", "measurements": [ { "statistic": "VALUE", "value": 1.0 } ], "availableTags": [ { "tag": "instance", "values": [ "10.42.4.109" ] }, { "tag": "service", "values": [ "assist-core-toolkit" ] }, { "tag": "name", "values": [ "http-nio-8080" ] } ] }
tomcat相关指标解释

Tomcat 相关指标
tomcat.threads.current
含义:当前正在运行的线程数。
用途:监控 Tomcat 服务器的线程池状态,了解当前负载情况。
tomcat.threads.busy
含义:当前正在处理请求的繁忙线程数。
用途:评估服务器的繁忙程度,帮助识别潜在的性能瓶颈。
tomcat.threads.config.max
含义:配置的最大线程数。
用途:确保服务器能够处理的最大并发请求数量,避免因线程不足导致请求失败。
tomcat.sessions.active.current
含义:当前活跃的会话数。
用途:监控当前在线用户的数量,帮助评估系统负载。
tomcat.sessions.active.max
含义:最大活跃会话数。
用途:了解系统在某个时间段内的最大并发用户数,帮助优化会话管理策略。
tomcat.sessions.created
含义:创建的会话总数。
用途:统计一段时间内创建的会话数量,帮助评估系统的使用情况。
tomcat.sessions.expired
含义:过期的会话数。
用途:监控会话的过期情况,帮助优化会话超时设置。
tomcat.sessions.rejected
含义:被拒绝的会话数。
用途:了解因会话管理限制而被拒绝的会话数量,帮助调整会话管理策略。
tomcat.sessions.alive.max
含义:最长存活时间的会话数。
用途:了解会话的最长存活时间,帮助优化会话超时设置。
tomcat.global.request
含义:总的请求数。
用途:统计服务器接收到的总请求数,帮助评估系统的使用情况。
tomcat.global.request.max
含义:最大请求处理时间。
用途:了解处理请求的最长时间,帮助识别性能瓶颈。
tomcat.global.sent
含义:发送的字节数。
用途:统计服务器发送的数据量,帮助评估网络带宽使用情况。
tomcat.global.received
含义:接收的字节数。
用途:统计服务器接收的数据量,帮助评估网络带宽使用情况。
tomcat.global.error
含义:错误请求数。
用途:统计服务器处理请求时发生的错误次数,帮助识别和解决潜在问题。
tomcat.sessions.rejected
含义:被拒绝的会话数。
用途:了解因会话管理限制而被拒绝的会话数量,帮助调整会话管理策略。
总结
这些指标可以帮助您全面了解 Tomcat 服务器的运行状态,包括线程池、会话管理和请求处理等方面。通过监控这些指标,您可以及时发现并解决潜在的性能问题,优化系统性能。
日志atuator
有些时候我们会在业务代码打大量debug,当出现问题时我们需要重放 打印debug的值
初始化类
org.springframework.boot.actuate.logging.LoggersEndpoint
获取某个类的日志级别
curl http://localhost:8080/actuator/loggers/com.yxt.assist.toolkit.anticorruption.baseinfo.adaptor.impl.OrganizationAdapterImpl
动态改变某个类的日志级别
curl -X POST http://127.0.0.1:8080/actuator/loggers/com.yxt.assist.toolkit.server.awardpunishment.service.impl.AwardPunishmentApplicationServiceImpl \ -H "Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8" \ --data '{"configuredLevel":"debug"}'
环境变量actuator
排查问题的时候判断是否加载到了我们的最新配置
查询是否有指定环境变量
curl 127.0.0.1:8080/actuator/env/server.port
响应

{ "property": { "source": "ApolloBootstrapPropertySources:application.yml", "value": "8080" }, "activeProfiles": [ "dev" ], "propertySources": [ { "name": "server.ports" }, { "name": "ApolloBootstrapPropertySources:application.yml", "property": { "value": "8080" } }, { "name": "ApolloBootstrapPropertySources:application.properties" }, { "name": "ApolloBootstrapPropertySources:bizconfig.properties" }, { "name": "ApolloBootstrapPropertySources:thirdconfig.properties" }, { "name": "ApolloBootstrapPropertySources:common.properties" }, { "name": "ApolloPropertySources:application" }, { "name": "myEncrypt" }, { "name": "servletConfigInitParams" }, { "name": "servletContextInitParams" }, { "name": "systemProperties" }, { "name": "systemEnvironment" }, { "name": "random" }, { "name": "applicationConfig: [classpath:/application.properties]" }, { "name": "springCloudClientHostInfo" }, { "name": "yxtSentinelPropertySources:yxtsentinel-dev-param.yml" }, { "name": "sentinelPropertySources:yxtsentinel-dev.yml" }, { "name": "defaultProperties" }, { "name": "Management Server" } ] }
健康检查
判断是否健康
curl localhost:8080/actuator/health
响应

{"status":"UP","details":{"application":{"status":"UP"}}}
标签:
Spring Boot
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!