监控 Springboot 2.0 Tomcat 服务器线程利用率

Ahm*_*aya 8 java monitoring tomcat spring-boot

我已经使用以下 tomcat 参数启动了我的 springboot 应用程序

-Dserver.tomcat.max-threads=400
-Dserver.tomcat.max-connections=4000
Run Code Online (Sandbox Code Playgroud)

我想监控繁忙的线程和繁忙的连接大小?

springboot里面有内置解决方案吗?否则我需要得到 mbeans 吗?

发现了类似的 问题,但尚未给出解决方案。

谢谢。

Wac*_*ira 8

起初,我使用 Spring Boot Actuator 和 Micrometer。但是它没有显示tomcat线程利用率。所以我这样配置了application.yml。

server:
  port: 3200
  address: 0.0.0.0
  tomcat:
    max-threads: 4000
    mbeanregistry:
      enabled: true
Run Code Online (Sandbox Code Playgroud)

我设置server.tomcat.mbeanregistry.enabled为true。然后 Tomcat 线程利用率显示在 /actuator/metrics 中。

这是我的输出。

{
  "names": [
    "http.server.requests",
    "http.server.requests.histogram",
    "jvm.buffer.count",
    "jvm.buffer.memory.used",
    "jvm.buffer.total.capacity",
    "jvm.classes.loaded",
    "jvm.classes.unloaded",
    "jvm.gc.live.data.size",
    "jvm.gc.max.data.size",
    "jvm.gc.memory.allocated",
    "jvm.gc.memory.promoted",
    "jvm.gc.pause",
    "jvm.memory.committed",
    "jvm.memory.max",
    "jvm.memory.used",
    "jvm.threads.daemon",
    "jvm.threads.live",
    "jvm.threads.peak",
    "jvm.threads.states",
    "logback.events",
    "process.cpu.usage",
    "process.files.max",
    "process.files.open",
    "process.start.time",
    "process.uptime",
    "system.cpu.count",
    "system.cpu.usage",
    "system.load.average.1m",
    "thread.pool.core.size",
    "thread.pool.max.size",
    "thread.pool.pool.size",
    "thread.pool.thread.count",
    "tomcat.cache.access",
    "tomcat.cache.hit",
    "tomcat.global.error",
    "tomcat.global.received",
    "tomcat.global.request",
    "tomcat.global.request.max",
    "tomcat.global.sent",
    "tomcat.servlet.error",
    "tomcat.servlet.request",
    "tomcat.servlet.request.max",
    "tomcat.sessions.active.current",
    "tomcat.sessions.active.max",
    "tomcat.sessions.alive.max",
    "tomcat.sessions.created",
    "tomcat.sessions.expired",
    "tomcat.sessions.rejected",
    "tomcat.threads.busy",
    "tomcat.threads.config.max",
    "tomcat.threads.current"
  ]
}
Run Code Online (Sandbox Code Playgroud)


小智 0

一种简单的方法是使用弹簧致动器和其顶部的千分尺。您可以获得即时 JMX 指标,也可以声明您自己的自定义指标。