Table of Contents
MetricsHub
MetricsHub Enterprise 2.1.00
-
Home
- Custom Monitoring
JMX Query
You can configure MetricsHub to periodically query any Java application exposing JMX (Java Management Extensions), retrieve specific MBean attributes, and push OpenTelemetry metrics with the extracted values.
In the example below, we configure MetricsHub to:
- monitor the
java-app
resource using JMX - retrieve the
LoadedClassCount
attribute from thejava.lang:type=ClassLoading
MBean - expose the value as an OpenTelemetry metric named
jvm.class.count
[1]
Procedure
To achieve this use case, we:
- Declare the resource to be monitored (
java-app
) and its attributes (host.name
,host.type
):
resources:
java-app:
attributes:
host.name: java-app
host.type: linux
- Configure the
jmx
protocol:
protocols:
jmx:
port: 1099
username: myUser
password: myPassword
timeout: 60s
- Define a monitor job (
jvm
) to collect the JVM class loading metric:
monitors:
jvm:
simple:
- Set up a JMX source (
JvmClassLoading
) to retrieve theLoadedClassCount
attribute from thejava.lang:type=ClassLoading
MBean:
sources:
JvmClassLoading:
type: jmx
objectName: java.lang:type=ClassLoading
attributes:
- LoadedClassCount
- Extract and expose the metric (
jvm.class.count
) from the JMX response:
mapping:
source: ${source::JvmClassLoading}
attributes:
id: java-app-classloading
metrics:
jvm.class.count: $1
Complete Configuration
resources:
java-app:
attributes:
host.name: java-app
host.type: linux
protocols:
jmx:
port: 1099
username: myUser
password: myPassword
timeout: 60s
monitors:
jvm:
simple:
sources:
JvmClassLoading:
type: jmx
objectName: java.lang:type=ClassLoading
attributes:
- LoadedClassCount
mapping:
source: ${source::JvmClassLoading}
attributes:
id: java-app-classloading
metrics:
jvm.class.count: $1
Supporting Resources
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
No results.