diff --git a/instrumentation/jmx-metrics/javaagent/README.md b/instrumentation/jmx-metrics/javaagent/README.md index 8680e878814e..3c6268c845c5 100644 --- a/instrumentation/jmx-metrics/javaagent/README.md +++ b/instrumentation/jmx-metrics/javaagent/README.md @@ -32,6 +32,20 @@ No targets are enabled by default. The supported target environments are listed - [wildfly](wildfly.md) - [hadoop](hadoop.md) +### Predefined metrics mapping + +The pre-defined metrics do not provide an exhaustive mapping of every available JMX attribute as doing +so would be verbose, tedious to maintain and brittle as it relies on implementation details of each +of the targets supported. The goal here is to provide a monitoring of the essential metrics, advanced +use-cases will require dedicated configuration. + +The following guidelines are recommended when modifying/extending pre-defined metrics: +- stay consistent with [semconv general guidelines](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/metrics.md#general-guidelines) for metrics. +- start with `{target}.` prefix, where `{target}` is the target system, for example `tomcat` or `hadoop`. +- align with semconv when semantics are identical, for example: + - `wildfly.network.io` is consistent with [`system.network.io`](https://opentelemetry.io/docs/specs/semconv/system/system-metrics/#metric-systemnetworkio) +- when not fitting semconv, reuse the existing mbean attribute names as metric suffix to preserve semantics of the exposed MBeans, for example `tomcat.request.errorCount` where tomcat reports as error any status >=400 and another app server might do it differently. + ## Configuration Files To provide your own metric definitions, create one or more YAML configuration files, and specify their location using the `otel.jmx.config` property. Absolute or relative pathnames can be specified. For example diff --git a/instrumentation/jmx-metrics/javaagent/jetty.md b/instrumentation/jmx-metrics/javaagent/jetty.md index d771214cfc48..a9da2d1c2f3b 100644 --- a/instrumentation/jmx-metrics/javaagent/jetty.md +++ b/instrumentation/jmx-metrics/javaagent/jetty.md @@ -3,14 +3,14 @@ Here is the list of metrics based on MBeans exposed by Jetty. | Metric Name | Type | Attributes | Description | -| ------------------------------ | ------------- | ------------ | ---------------------------------------------------- | +|--------------------------------|---------------|--------------|------------------------------------------------------| | jetty.session.sessionsCreated | Counter | resource | The number of sessions established in total | | jetty.session.sessionTimeTotal | Counter | resource | The total time sessions have been active | | jetty.session.sessionTimeMax | Gauge | resource | The maximum amount of time a session has been active | | jetty.session.sessionTimeMean | Gauge | resource | The mean time sessions remain active | -| jetty.threads.busyThreads | UpDownCounter | | The current number of busy threads | -| jetty.threads.idleThreads | UpDownCounter | | The current number of idle threads | -| jetty.threads.maxThreads | UpDownCounter | | The maximum number of threads in the pool | -| jetty.threads.queueSize | UpDownCounter | | The current number of threads in the queue | +| jetty.thread.busyThreads | UpDownCounter | | The current number of busy threads | +| jetty.thread.idleThreads | UpDownCounter | | The current number of idle threads | +| jetty.thread.maxThreads | UpDownCounter | | The maximum number of threads in the pool | +| jetty.thread.queueSize | UpDownCounter | | The current number of threads in the queue | | jetty.io.selectCount | Counter | resource, id | The number of select calls | | jetty.logging.LoggerCount | UpDownCounter | | The number of registered loggers by name | diff --git a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/jetty.yaml b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/jetty.yaml index ed5435d9cc20..9e10cd160a6d 100644 --- a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/jetty.yaml +++ b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/jetty.yaml @@ -8,7 +8,7 @@ rules: resource: param(context) mapping: sessionsCreated: - unit: "{sessions}" + unit: "{session}" type: counter desc: The number of sessions established in total sessionTimeTotal: @@ -22,8 +22,8 @@ rules: desc: The mean time sessions remain active - bean: org.eclipse.jetty.util.thread:type=queuedthreadpool,id=* - prefix: jetty.threads. - unit: "{threads}" + prefix: jetty.thread. + unit: "{thread}" type: updowncounter mapping: busyThreads: diff --git a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/tomcat.yaml b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/tomcat.yaml index 8d0f7f8835a5..a9248c7853ea 100644 --- a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/tomcat.yaml +++ b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/tomcat.yaml @@ -6,133 +6,129 @@ rules: - bean: Catalina:type=GlobalRequestProcessor,name=* unit: "1" - prefix: http.server.tomcat. + prefix: tomcat. metricAttribute: name: param(name) mapping: errorCount: - metric: errorCount + metric: request.errorCount type: gauge + unit: "{request}" desc: The number of errors per second on all request processors requestCount: - metric: requestCount + metric: request.requestCount type: gauge + unit: "{request}" desc: The number of requests per second across all request processors maxTime: - metric: maxTime + metric: request.maxTime type: gauge unit: ms desc: The longest request processing time processingTime: - metric: processingTime + metric: request.processingTime type: counter unit: ms desc: Total time for processing all requests bytesReceived: - metric: traffic + metric: network.io type: counter unit: By desc: The number of bytes transmitted metricAttribute: - direction: const(received) + network.io.direction: const(receive) bytesSent: - metric: traffic + metric: network.io type: counter unit: By desc: The number of bytes transmitted metricAttribute: - direction: const(sent) + network.io.direction: const(transmit) - bean: Tomcat:type=GlobalRequestProcessor,name=* unit: "1" - prefix: http.server.tomcat. + prefix: tomcat. metricAttribute: name: param(name) mapping: errorCount: - metric: errorCount + metric: request.errorCount type: gauge + unit: "{request}" desc: The number of errors per second on all request processors requestCount: - metric: requestCount + metric: request.requestCount type: gauge + unit: "{request}" desc: The number of requests per second across all request processors maxTime: - metric: maxTime + metric: request.maxTime type: gauge unit: ms desc: The longest request processing time processingTime: - metric: processingTime + metric: request.processingTime type: counter unit: ms desc: Total time for processing all requests bytesReceived: - metric: traffic + metric: network.io type: counter unit: By desc: The number of bytes transmitted metricAttribute: - direction: const(received) + network.io.direction: const(receive) bytesSent: - metric: traffic + metric: network.io type: counter unit: By desc: The number of bytes transmitted metricAttribute: - direction: const(sent) + network.io.direction: const(transmit) - bean: Catalina:type=Manager,host=localhost,context=* - unit: "1" - prefix: http.server.tomcat. + unit: "{session}" + prefix: tomcat.session. type: updowncounter metricAttribute: context: param(context) mapping: activeSessions: - metric: sessions.activeSessions + metric: activeSessions desc: The number of active sessions - bean: Tomcat:type=Manager,host=localhost,context=* - unit: "1" - prefix: http.server.tomcat. + unit: "{session}" + prefix: tomcat.session. type: updowncounter metricAttribute: context: param(context) mapping: activeSessions: - metric: sessions.activeSessions + metric: activeSessions desc: The number of active sessions - bean: Catalina:type=ThreadPool,name=* - unit: "{threads}" - prefix: http.server.tomcat. + unit: "{thread}" + prefix: tomcat.thread. type: updowncounter metricAttribute: name: param(name) mapping: currentThreadCount: - metric: threads - desc: Thread Count of the Thread Pool - metricAttribute: - state: const(idle) + metric: currentThreadCount + desc: Total thread count of the thread pool currentThreadsBusy: - metric: threads - desc: Thread Count of the Thread Pool - metricAttribute: - state: const(busy) + metric: currentThreadsBusy + desc: Busy thread count of the thread pool - bean: Tomcat:type=ThreadPool,name=* - unit: "{threads}" - prefix: http.server.tomcat. + unit: "{thread}" + prefix: tomcat.thread. type: updowncounter metricAttribute: name: param(name) mapping: currentThreadCount: - metric: threads - desc: Thread Count of the Thread Pool - metricAttribute: - state: const(idle) + metric: currentThreadCount + desc: Total thread count of the thread pool currentThreadsBusy: - metric: threads - desc: Thread Count of the Thread Pool - metricAttribute: - state: const(busy) + metric: currentThreadsBusy + desc: Busy thread count of the thread pool diff --git a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/wildfly.yaml b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/wildfly.yaml index b6d4c543257b..5bf455f40615 100644 --- a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/wildfly.yaml +++ b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/wildfly.yaml @@ -25,6 +25,7 @@ rules: unit: ns errorCount: - bean: jboss.as:subsystem=undertow,server=*,http-listener=* + metricPrefix: wildfly. metricAttribute: server: param(server) listener: param(http-listener) @@ -32,40 +33,42 @@ rules: unit: By mapping: bytesSent: - metric: wildfly.network.io + metric: network.io desc: Total number of bytes transferred metricAttribute: - direction: const(out) + network.io.direction: const(transmit) bytesReceived: - metric: wildfly.network.io + metric: network.io desc: Total number of bytes transferred metricAttribute: - direction: const(in) + network.io.direction: const(receive) - bean: jboss.as:subsystem=datasources,data-source=*,statistics=pool - unit: "1" + unit: "{connection}" metricAttribute: data_source: param(data-source) mapping: ActiveCount: - metric: wildfly.db.client.connections.usage + metric: wildfly.db.client.connection.count metricAttribute: - state: const(used) - desc: The number of open jdbc connections + db.client.connection.state: const(used) + desc: The number of in-use physical jdbc connections IdleCount: - metric: wildfly.db.client.connections.usage + metric: wildfly.db.client.connections.count metricAttribute: - state: const(idle) - desc: The number of open jdbc connections + db.client.connection.state: const(idle) + desc: The number of idle physical jdbc connections WaitCount: - metric: wildfly.db.client.connections.WaitCount - type: counter + metric: wildfly.db.client.connection.count + metricAttribute: + db.client.connection.state: const(idle) + desc: The number of waiting logical jdbc connections - bean: jboss.as:subsystem=transactions type: counter prefix: wildfly.db.client. - unit: "{transactions}" + unit: "{transaction}" mapping: numberOfTransactions: - metric: transaction.NumberOfTransactions + metric: transaction.numberOfTransactions numberOfApplicationRollbacks: metric: rollback.count metricAttribute: diff --git a/instrumentation/jmx-metrics/javaagent/tomcat.md b/instrumentation/jmx-metrics/javaagent/tomcat.md index 6ac2e3fea16e..4846e298ff1a 100644 --- a/instrumentation/jmx-metrics/javaagent/tomcat.md +++ b/instrumentation/jmx-metrics/javaagent/tomcat.md @@ -2,12 +2,13 @@ Here is the list of metrics based on MBeans exposed by Tomcat. -| Metric Name | Type | Attributes | Description | -| ------------------------------------------ | ------------- | --------------- | --------------------------------------------------------------- | -| http.server.tomcat.sessions.activeSessions | UpDownCounter | context | The number of active sessions | -| http.server.tomcat.errorCount | Gauge | name | The number of errors per second on all request processors | -| http.server.tomcat.requestCount | Gauge | name | The number of requests per second across all request processors | -| http.server.tomcat.maxTime | Gauge | name | The longest request processing time | -| http.server.tomcat.processingTime | Counter | name | Represents the total time for processing all requests | -| http.server.tomcat.traffic | Counter | name, direction | The number of bytes transmitted | -| http.server.tomcat.threads | UpDownCounter | name, state | Thread Count of the Thread Pool | +| Metric Name | Type | Attributes | Description | +|----------------------------------|---------------|----------------------------|-----------------------------------------------------------------| +| tomcat.session.activeSessions | UpDownCounter | context | The number of active sessions | +| tomcat.request.errorCount | Gauge | name | The number of errors per second on all request processors | +| tomcat.request.requestCount | Gauge | name | The number of requests per second across all request processors | +| tomcat.request.maxTime | Gauge | name | The longest request processing time | +| tomcat.request.processingTime | Counter | name | Represents the total time for processing all requests | +| tomcat.network.io | Counter | name, network.io.direction | The number of bytes transmitted | +| tomcat.thread.currentThreadCount | UpDownCounter | name | Total thread count of the thread pool | +| tomcat.thread.currentThreadsBusy | UpDownCounter | name | Busy thread count of the thread pool | diff --git a/instrumentation/jmx-metrics/javaagent/wildfly.md b/instrumentation/jmx-metrics/javaagent/wildfly.md index 637453a4ee33..2444b848e85a 100644 --- a/instrumentation/jmx-metrics/javaagent/wildfly.md +++ b/instrumentation/jmx-metrics/javaagent/wildfly.md @@ -2,17 +2,16 @@ Here is the list of metrics based on MBeans exposed by Wildfly. -| Metric Name | Type | Attributes | Description | -| -------------------------------------------------- | ------------- | ------------------ | ----------------------------------------------------------------------- | -| wildfly.network.io | Counter | direction, server | Total number of bytes transferred | -| wildfly.request.errorCount | Counter | server, listener | The number of 500 responses that have been sent by this listener | -| wildfly.request.requestCount | Counter | server, listener | The number of requests this listener has served | -| wildfly.request.processingTime | Counter | server, listener | The total processing time of all requests handed by this listener | -| wildfly.session.expiredSession | Counter | deployment | Number of sessions that have expired | -| wildfly.session.rejectedSessions | Counter | deployment | Number of rejected sessions | -| wildfly.session.sessionsCreated | Counter | deployment | Total sessions created | -| wildfly.session.activeSessions | UpDownCounter | deployment | Number of active sessions | -| wildfly.db.client.connections.usage | Gauge | data_source, state | The number of open jdbc connections | -| wildfly.db.client.connections.WaitCount | Counter | data_source | The number of requests that had to wait to obtain a physical connection | -| wildfly.db.client.rollback.count | Counter | cause | The total number of transactions rolled back | -| wildfly.db.client.transaction.NumberOfTransactions | Counter | | The total number of transactions (top-level and nested) created | +| Metric Name | Type | Attributes | Description | +|----------------------------------------------------|---------------|------------------------------------------|-------------------------------------------------------------------------| +| wildfly.network.io | Counter | server, network.io.direction | Total number of bytes transferred | +| wildfly.request.errorCount | Counter | server, listener | The number of 500 responses that have been sent by this listener | +| wildfly.request.requestCount | Counter | server, listener | The number of requests this listener has served | +| wildfly.request.processingTime | Counter | server, listener | The total processing time of all requests handed by this listener | +| wildfly.session.expiredSession | Counter | deployment | Number of sessions that have expired | +| wildfly.session.rejectedSessions | Counter | deployment | Number of rejected sessions | +| wildfly.session.sessionsCreated | Counter | deployment | Total sessions created | +| wildfly.session.activeSessions | UpDownCounter | deployment | Number of active sessions | +| wildfly.db.client.connection.count | Gauge | data_source, db.client.connections.state | The number of open jdbc connections | +| wildfly.db.client.rollback.count | Counter | cause | The total number of transactions rolled back | +| wildfly.db.client.transaction.NumberOfTransactions | Counter | | The total number of transactions (top-level and nested) created |