JMX (Java Management Extensions) is handy for monitoring applications built using Java. With the OneAgent z/OS Java code module, you can monitor any metric in your JVM that is exposed via an MBean.
The customJmxMetrics
attribute defines a list of metrics to be monitored. To get started, add the customJmxMetrics
attribute to your dtconfig.json
file as shown in the following example.
Typically, you've created the dtconfig.json
file during the z/OS Java code module installation and have set the attributes Tenant
, ClusterID
, and zdcName
to your environment.
{"Tenant": "myTenant","ClusterID": myCluster,"ZdcName": "DEFAULT","customJmxMetrics": [{"name": "java.lang.CurrentThreadCount","source":{"domain": "java.lang","keyProperties": {"type": "Threading",},"attribute": "ThreadCount"}}]}
Each metric has the following mandatory attributes:
name
.
are allowed.The source specifies how a metric is collected using JMX. Each source has the following mandatory attributes:
domain
*
).keyProperties
*
).attribute
Optional source attributes are:
attributePath
allowAdditionalKeys
keyProperties
are allowed but ignored. If false, the keyProperties
need to match exactly; additional keys in the name will lead to a mismatch.calculateDelta
calculateRate
calculateDelta
to convert an absolute attribute (for example, Request Count) to a rate (for example, Requests per Second). Value = attribute / query interval.aggregation
SUM
. Available aggregations are: SUM
, AVG
, MIN
, MAX
. For example, you can use this attribute to aggregate all MemoryPools
and calculate their SUM
or MAX
value.To extract values of individual keys returned as CompositeData
type by an attribute, you need to use the attributePath
mechanism and point to the key you're interested in.
For example, HeapMemoryUsage
is a CompositeData
type that returns the following list of value-key pairs:
{committed: integer,init: integer,max: integer,used: integer}
If you want to extract the value of used
from the HeapMemoryUsage
attribute, point the attributePath
to the used
key.
{"customJmxMetrics": [{"name": "java.lang.HeapMemoryUsage","source":{"domain": "java.lang","keyProperties": {"type": "Memory"},"attribute": "HeapMemoryUsage","attributePath": "get(\"used\")"}}]}
Splittings can be used to define additional dimensions for a metric.
"splittings": [{"name": "dimension","keyProperty": "name"}]
Each splitting has the following mandatory attributes:
name
keyProperty
ObjectName
of an MBean is used for splitting. See the keyProperties
attribute of the source.The following example shows how to define a metric providing multiple dimensions within a single metric definition:
{"customJmxMetrics": [{"name": "java.lang.MemoryPoolUsage","source":{"domain": "java.lang","keyProperties": {"type": "MemoryPool","name": "*"},"attribute": "Usage","attributePath": "get(\"used\")","splittings": [{"name": "memory_type","keyProperty": "name"}]}}]}
Based on this metric definition, the following MBeans:
java.lang:type=MemoryPool,name=G1 Eden Space
java.lang:type=MemoryPool,name=G1 Survivor Space
will result in a single metric in Dynatrace with two dimensions:
java.lang.MemoryPoolUsage
with the dimension memory_type=G1 Eden Space
java.lang.MemoryPoolUsage
with the dimension memory_type=G1 Survivor Space
Go to Data Explorer to analyze and chart your custom JMX metrics. If needed, you can pin your charts to a dashboard. In the following example, you can see the java.lang.MemoryPoolUsage
metric split by the dimension memory_type
:
To get a list of metrics available in your monitoring environment, Go to Metrics to open the Metrics browser. In the following example, you can see the three metrics that we have created above: