3 回答

TA貢獻(xiàn)1942條經(jīng)驗 獲得超3個贊
起初,我使用 Spring Boot Actuator 和 Micrometer。但它不顯示 tomcat 線程利用率。所以我這樣配置了application.yml。
server:
port: 3200
address: 0.0.0.0
tomcat:
max-threads: 4000
mbeanregistry:
enabled: true
我設(shè)置server.tomcat.mbeanregistry.enabled為真。然后 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"
]
}

TA貢獻(xiàn)1826條經(jīng)驗 獲得超6個贊
一種簡單的方法是使用上面帶有測微計的彈簧執(zhí)行器。您可以獲得即時的 JMX 指標(biāo),也可以聲明您自己的自定義指標(biāo)。

TA貢獻(xiàn)2051條經(jīng)驗 獲得超10個贊
您可以使用Spring Boot Actuator(/metrics 端點)來提供有關(guān)內(nèi)存、堆、處理器、線程、加載的類、卸載的類、線程池等信息。
例如,此端點返回:
"threads.peak"?:?..., "threads.daemon"?:?..., "threads"?:?...,
此外,如果需要,您可以使用 /threaddump 端點獲取線程轉(zhuǎn)儲。
添加回答
舉報