This is an automated email from the ASF dual-hosted git repository.
abhishekrb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 37f88fab8c6 Update Jetty thread pool metrics (#18883)
37f88fab8c6 is described below
commit 37f88fab8c69febc592f76cf62eee78c3dabf443
Author: Abhishek Radhakrishnan <[email protected]>
AuthorDate: Mon Jan 5 14:47:58 2026 -0800
Update Jetty thread pool metrics (#18883)
Add new Jetty thread pool metrics to capture request-serving thread
statistics: jetty/threadPool/utilized, jetty/threadPool/ready and
jetty/threadPool/utilizationRate.
Unlike some of the existing metrics, these new metrics are intended to
serve as an indicator for threads that would serve requests from the thread
pool.
Also update the documentation for the new metrics and also fixes up
descriptions for some existing Jetty metrics.
---
docs/operations/metrics.md | 11 +++++++----
.../opentsdb-emitter/src/main/resources/defaultMetrics.json | 3 +++
.../prometheus-emitter/src/main/resources/defaultMetrics.json | 3 +++
.../src/main/resources/defaultMetricDimensions.json | 3 +++
.../druid/server/initialization/jetty/JettyServerModule.java | 5 +++++
.../server/initialization/jetty/JettyServerModuleTest.java | 6 ++++++
6 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/docs/operations/metrics.md b/docs/operations/metrics.md
index e2c957b9cee..5f3c0d864de 100644
--- a/docs/operations/metrics.md
+++ b/docs/operations/metrics.md
@@ -149,10 +149,13 @@ to represent the task ID are deprecated and will be
removed in a future release.
|Metric|Description|Normal value|
|------|-----------|------------|
|`jetty/numOpenConnections`|Number of open jetty connections.|Not much higher
than number of jetty threads.|
-|`jetty/threadPool/total`|Number of total workable threads allocated.|The
number should equal to `threadPoolNumIdleThreads` + `threadPoolNumBusyThreads`.|
-|`jetty/threadPool/idle`|Number of idle threads.|Less than or equal to
`threadPoolNumTotalThreads`. Non zero number means there is less work to do
than configured capacity.|
-|`jetty/threadPool/busy`|Number of busy threads that has work to do from the
worker queue.|Less than or equal to `threadPoolNumTotalThreads`.|
-|`jetty/threadPool/isLowOnThreads`|A rough indicator of whether number of
total workable threads allocated is enough to handle the works in the work
queue.|0|
+|`jetty/threadPool/total`|Number of total threads allocated. This includes
internal threads and threads that are ready to serve requests.|Equals the total
number of threads in the Jetty thread pool. i.e., `jetty/threadPool/ready` +
`jetty/threadPool/utilized` + any reserved threads for internal Jetty usage.|
+|`jetty/threadPool/ready`|Number of threads that are ready to serve
requests.|Equals the total number of usable threads in the Jetty thread pool to
serve requests. i.e., `jetty/threadPool/idle` + any reserved threads for
internal Jetty usage.|
+|`jetty/threadPool/utilized`|Number of threads currently in use by the thread
pool to serve requests.|Value < `jetty/threadPool/ready`.|
+|`jetty/threadPool/utilizationRate`|Fraction of thread pool capacity currently
in use to serve requests.|0.0 ≤ Value ≤ 1. A value of 0.0 means that the thread
pool is not utilized, while a value of 1.0 means that the thread pool is fully
utilized.|
+|`jetty/threadPool/idle`|Number of idle threads.|Value ≤
(`jetty/threadPool/ready` - any reserved threads for internal Jetty usage). A
non-zero value means there is less work to do than configured capacity.|
+|`jetty/threadPool/busy`|Number of busy threads that have work to do from the
worker queue.|Value ≤ (`jetty/threadPool/utilized` + any reserved threads for
internal Jetty usage).|
+|`jetty/threadPool/isLowOnThreads`|A rough indicator of whether the number of
total workable threads allocated is enough to handle the work in the work
queue.|0|
|`jetty/threadPool/min`|Number of minimum threads
allocatable.|`druid.server.http.numThreads` plus a small fixed number of
threads allocated for Jetty acceptors and selectors.|
|`jetty/threadPool/max`|Number of maximum threads
allocatable.|`druid.server.http.numThreads` plus a small fixed number of
threads allocated for Jetty acceptors and selectors.|
|`jetty/threadPool/queueSize`|Size of the worker queue.|Not much higher than
`druid.server.http.queueSize`.|
diff --git
a/extensions-contrib/opentsdb-emitter/src/main/resources/defaultMetrics.json
b/extensions-contrib/opentsdb-emitter/src/main/resources/defaultMetrics.json
index 69100697a62..f38f115348f 100644
--- a/extensions-contrib/opentsdb-emitter/src/main/resources/defaultMetrics.json
+++ b/extensions-contrib/opentsdb-emitter/src/main/resources/defaultMetrics.json
@@ -29,6 +29,9 @@
],
"jetty/numOpenConnections": [],
"jetty/threadPool/total": [],
+ "jetty/threadPool/ready": [],
+ "jetty/threadPool/utilized": [],
+ "jetty/threadPool/utilizationRate": [],
"jetty/threadPool/idle": [],
"jetty/threadPool/busy": [],
"jetty/threadPool/isLowOnThreads": [],
diff --git
a/extensions-contrib/prometheus-emitter/src/main/resources/defaultMetrics.json
b/extensions-contrib/prometheus-emitter/src/main/resources/defaultMetrics.json
index 3702039c283..640e7e1661e 100644
---
a/extensions-contrib/prometheus-emitter/src/main/resources/defaultMetrics.json
+++
b/extensions-contrib/prometheus-emitter/src/main/resources/defaultMetrics.json
@@ -37,6 +37,9 @@
"jetty/numOpenConnections" : { "dimensions" : [], "type" : "gauge", "help":
"Number of open jetty connections."},
"jetty/threadPool/total" : { "dimensions" : [], "type" : "gauge", "help":
"Number of total workable threads allocated."},
+ "jetty/threadPool/ready" : { "dimensions" : [], "type" : "gauge", "help":
"Number of threads that are ready to serve requests."},
+ "jetty/threadPool/utilized" : { "dimensions" : [], "type" : "gauge", "help":
"Number of threads currently in use to serve requests."},
+ "jetty/threadPool/utilizationRate" : { "dimensions" : [], "type" : "gauge",
"help": "Fraction of thread pool capacity currently in use to serve requests."},
"jetty/threadPool/idle" : { "dimensions" : [], "type" : "gauge", "help":
"Number of idle threads."},
"jetty/threadPool/busy" : { "dimensions" : [], "type" : "gauge", "help":
"Number of busy threads that has work to do from the worker queue."},
"jetty/threadPool/isLowOnThreads" : { "dimensions" : [], "type" : "gauge",
"help": "A rough indicator of whether number of total workable threads
allocated is enough to handle the works in the work queue."},
diff --git
a/extensions-contrib/statsd-emitter/src/main/resources/defaultMetricDimensions.json
b/extensions-contrib/statsd-emitter/src/main/resources/defaultMetricDimensions.json
index e6b7f9f594a..d8074cb2909 100644
---
a/extensions-contrib/statsd-emitter/src/main/resources/defaultMetricDimensions.json
+++
b/extensions-contrib/statsd-emitter/src/main/resources/defaultMetricDimensions.json
@@ -159,6 +159,9 @@
"jetty/numOpenConnections": { "dimensions" : [], "type" : "gauge" },
"jetty/threadPool/total": { "dimensions" : [], "type" : "gauge" },
+ "jetty/threadPool/ready": { "dimensions" : [], "type" : "gauge" },
+ "jetty/threadPool/utilized": { "dimensions" : [], "type" : "gauge" },
+ "jetty/threadPool/utilizationRate": { "dimensions" : [], "type" : "gauge" },
"jetty/threadPool/idle": { "dimensions" : [], "type" : "gauge" },
"jetty/threadPool/busy": { "dimensions" : [], "type" : "gauge" },
"jetty/threadPool/isLowOnThreads": { "dimensions" : [], "type" : "gauge" },
diff --git
a/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
b/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
index 41cd7bf7fbd..9baa832ca4e 100644
---
a/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
+++
b/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
@@ -528,6 +528,11 @@ public class JettyServerModule extends JerseyServletModule
if (jettyServerThreadPool != null) {
emitter.emit(builder.setMetric("jetty/threadPool/total",
jettyServerThreadPool.getThreads()));
emitter.emit(builder.setMetric("jetty/threadPool/idle",
jettyServerThreadPool.getIdleThreads()));
+
+ emitter.emit(builder.setMetric("jetty/threadPool/ready",
jettyServerThreadPool.getReadyThreads()));
+ emitter.emit(builder.setMetric("jetty/threadPool/utilized",
jettyServerThreadPool.getUtilizedThreads()));
+ emitter.emit(builder.setMetric("jetty/threadPool/utilizationRate",
jettyServerThreadPool.getUtilizationRate()));
+
emitter.emit(builder.setMetric("jetty/threadPool/isLowOnThreads",
jettyServerThreadPool.isLowOnThreads() ? 1 : 0));
emitter.emit(builder.setMetric("jetty/threadPool/min",
jettyServerThreadPool.getMinThreads()));
emitter.emit(builder.setMetric("jetty/threadPool/max",
jettyServerThreadPool.getMaxThreads()));
diff --git
a/server/src/test/java/org/apache/druid/server/initialization/jetty/JettyServerModuleTest.java
b/server/src/test/java/org/apache/druid/server/initialization/jetty/JettyServerModuleTest.java
index 317c69e17e2..c4bf0324081 100644
---
a/server/src/test/java/org/apache/druid/server/initialization/jetty/JettyServerModuleTest.java
+++
b/server/src/test/java/org/apache/druid/server/initialization/jetty/JettyServerModuleTest.java
@@ -53,6 +53,9 @@ public class JettyServerModuleTest
Mockito.when(jettyServerThreadPool.getMaxThreads()).thenReturn(100);
Mockito.when(jettyServerThreadPool.getQueueSize()).thenReturn(50);
Mockito.when(jettyServerThreadPool.getBusyThreads()).thenReturn(60);
+ Mockito.when(jettyServerThreadPool.getReadyThreads()).thenReturn(20);
+ Mockito.when(jettyServerThreadPool.getUtilizedThreads()).thenReturn(5);
+ Mockito.when(jettyServerThreadPool.getUtilizationRate()).thenReturn(0.45);
JettyServerModule.JettyMonitor jettyMonitor = new
JettyServerModule.JettyMonitor();
@@ -67,6 +70,9 @@ public class JettyServerModuleTest
serviceEmitter.verifyValue("jetty/threadPool/max", 100);
serviceEmitter.verifyValue("jetty/threadPool/queueSize", 50);
serviceEmitter.verifyValue("jetty/threadPool/busy", 60);
+ serviceEmitter.verifyValue("jetty/threadPool/ready", 20);
+ serviceEmitter.verifyValue("jetty/threadPool/utilized", 5);
+ serviceEmitter.verifyValue("jetty/threadPool/utilizationRate", 0.45);
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]