Browse Source

JMX metrics for Tomcat with 'Tomcat' JMX domain (#10115)

SylvainJuge 1 year ago
parent
commit
015a4663b3

+ 71 - 0
instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/tomcat.yaml

@@ -1,4 +1,8 @@
 ---
+# For Tomcat, the default JMX domain is "Catalina:", however with some deployments like embedded in spring-boot
+# we can have the "Tomcat:" domain used, thus we have to duplicate metrics definitions as using a wildcard
+# would match too broadly
+
 rules:
   - bean: Catalina:type=GlobalRequestProcessor,name=*
     unit: "1"
@@ -38,6 +42,45 @@ rules:
         desc: The number of bytes transmitted
         metricAttribute:
           direction: const(sent)
+  - bean: Tomcat:type=GlobalRequestProcessor,name=*
+    unit: "1"
+    prefix: http.server.tomcat.
+    metricAttribute:
+      name: param(name)
+    mapping:
+      errorCount:
+        metric: errorCount
+        type: gauge
+        desc: The number of errors per second on all request processors
+      requestCount:
+        metric: requestCount
+        type: gauge
+        desc: The number of requests per second across all request processors
+      maxTime:
+        metric: maxTime
+        type: gauge
+        unit: ms
+        desc: The longest request processing time
+      processingTime:
+        metric: processingTime
+        type: counter
+        unit: ms
+        desc: Total time for processing all requests
+      bytesReceived:
+        metric: traffic
+        type: counter
+        unit: By
+        desc: The number of bytes transmitted
+        metricAttribute:
+          direction: const(received)
+      bytesSent:
+        metric: traffic
+        type: counter
+        unit: By
+        desc: The number of bytes transmitted
+        metricAttribute:
+          direction: const(sent)
+
   - bean: Catalina:type=Manager,host=localhost,context=*
     unit: "1"
     prefix: http.server.tomcat.
@@ -48,6 +91,17 @@ rules:
       activeSessions:
         metric: sessions.activeSessions
         desc: The number of active sessions
+  - bean: Tomcat:type=Manager,host=localhost,context=*
+    unit: "1"
+    prefix: http.server.tomcat.
+    type: updowncounter
+    metricAttribute:
+      context: param(context)
+    mapping:
+      activeSessions:
+        metric: sessions.activeSessions
+        desc: The number of active sessions
+
   - bean: Catalina:type=ThreadPool,name=*
     unit: "{threads}"
     prefix: http.server.tomcat.
@@ -65,3 +119,20 @@ rules:
         desc: Thread Count of the Thread Pool
         metricAttribute:
           state: const(busy)
+  - bean: Tomcat:type=ThreadPool,name=*
+    unit: "{threads}"
+    prefix: http.server.tomcat.
+    type: updowncounter
+    metricAttribute:
+      name: param(name)
+    mapping:
+      currentThreadCount:
+        metric: threads
+        desc: Thread Count of the Thread Pool
+        metricAttribute:
+          state: const(idle)
+      currentThreadsBusy:
+        metric: threads
+        desc: Thread Count of the Thread Pool
+        metricAttribute:
+          state: const(busy)