JMX data source
Dynatrace provides a framework to create metrics from JMX MBeans. Every process monitored by OneAgent Java code module is capable of processing JMX 2.0 extensions.
You need to enable the Java Metric Extensions 2.0 (JMX) OneAgent feature
Background
JMX organizes data and functionality in an object oriented way. Every Java process has a platform MBean server which manages a set of monitoring objects called MBeans.
Every MBean has a unique object name. Every object name consists of a domain name and a list of key properties. Every key property consists of a name and a (string) value.
JMX defines a standardized syntax to write those object names, for example, java.lang:type=GarbageCollector,name=YoungGen
. Every MBean has 0 or more attributes (see MBeanServer::getAttribute). Attributes can be of any Java type (including booleans, numbers and strings).
Numeric attributes can be directly used to produce metrics in Dynatrace. It's also possible to extract numeric values from complex attributes.
Prerequisites
We assume the following:
- You possess sufficient JMX subject matter expertise to create an extension.
- You're familiar with Extensions 2.0 basic concepts and the general structure of the extension YAML file.
Supported Dynatrace versions
- Dynatrace version 1.265+
- OneAgent version 1.265+
JMX extension YAML file
Let's start with a minimal JMX extension:
# required extension metadataname: custom:com.example.jmxversion: 1.0.0minDynatraceVersion: 1.265.0author:name: John Doe# optional metric metadatametrics:- key: com.example.jmx.thread_countmetadata:displayName: Thread Countdescription: Number of active Java threadsunit: Count# defines how to create metrics from JMX MBeansjmx:groups:- group: jvmsubgroups:- subgroup: basicquery: java.lang:type=Threadingmetrics:- key: com.example.jmx.thread_counttype: gaugevalue: attribute:ThreadCount
The first two parts should already be familiar to you, we will focus on the jmx
section of the YAML file.
Groups and subgroups can be used to share configuration between multiple metrics. In our specific sample, we only have one group and one subgroup.
Extract metrics from MBeans
Every subgroup has to select a set of MBeans that should contribute to a metric. This is done with the query
field and follows the standard JMX object name syntax
Here, the query is java.lang:type=Threading
. This breaks down into looking for a bean in domain java.lang
that has exactly one property with name type
and value Threading
.
Every subgroup also needs to define at least one metric that should be extracted from the selected MBeans. In our sample we create a Dynatrace gauge metric called com.example.jmx.thread_count
by querying the numeric JMX attribute ThreadCount
from the MBean java.lang:type=Threading
.
OneAgent will automatically add the following dimensions to your metric:
dt.entity.process_group_instance
dt.entity.process_group
dt.entity.host
dt.entity.container_group_instance
dt.metrics.source
dt.extension.config.id
For more information, see JMX data source reference.