JMX Data Collection

Last updated on 30 September, 2022

The JMX collector is used to collect data from java applications using exposed MBeans.  For issues with configuring JMX collection, see this page.

An MBean is identified by the combination of a domain and a list of properties. For example, domain= java.lang, and properties type=Memory, identifies the MBean that reports on memory usage of a JVM.

Each MBean exposes one or more attributes that can be queried and collected by name.

An MBean attribute could be:

  • A primitive java data type such as int, long, double, or String
  • An array of data (‘data’ itself could be a primitive data type, an array of data, a hash of data, and so on)
  • A hash of data

LogicMonitor can deal with all the above data types, so long as each attribute is fully specified to result in a primitive data type. However, please note that LogicMonitor does not currently support JMX queries that include a dot/period (i.e. “.” ) when they are not part of an array, e.g. an attribute name of rep.Container.

When specifying which JMX objects to collect, you must specify:

  • name – used to identify the object
  • MBean ObjectName – used to specify the JMX Domain and path of the MBean
  • Mbean Attribute – used to specify an attribute to collect.

e.g. a simple case:

If the attribute to be collected is part of a complex object, it can be qualified by use of period separator:

And if necessary, multiple levels of selectors can be specified.  For example, to collect the value of the attribute “key1” for the map with index “move” for the MBean with type rrdfs in the LogicMonitor domain:

CompositeData and Map Support

The MBean attribute expression supports CompositeData and Map. For example, the MBeanjava.lang:type=GarbageCollector,name=Copy has an attribute LastGcInfo whose value is a CompositeData (see the figure below).1

CompositeData and Map Support

To access the value of GcThreadCount, the attribute expression could be “LastGcInfo.GcThreadCount“. Same rule could be used if the value is a Map.

TabularData Support

The MBean expression supports TabularData. For example, the MBean java.lang:type=GarbageCollector,name=Copy has an attribute LastGcInfo. One of its child values, memoryUsageAfterGc, is a TabularData. The figure below describes its schema and data.1

TabularData Support

The table has 2 columns – ‘key‘ and ‘value‘. The column ‘key‘ is used to index the table (so you can uniquely locate a row by specifying an index value. For instance, key=”Code Cache” will return the 1st row). If you want to retrieve the value of the column ‘value’ of the second row, the expression could be“LastGcInfo.memoryUsageAfterGc.Eden Space.value”, where “Eden Space” is the value of the column ‘key’ to uniquely locate the row, and “value” is the name of the column whose value you want to access.

Sometimes, a TabularData may have multiple index columns. Here is an example (note that this example is faked):

This TabularData has 4 columns. The column “process” and “heap” are index columns. The combination of their value is used to uniquely locate a row. For example, process=Tomcat,heap=Code Cache will return the first row.

To retrieve the value of the column ‘committed’ of the 3rd row, the expression could be “LastGcInfo.memoryUsageAfterGc.Tomcat,Perm Gen.committed“, where ‘Tomcat,Perm Gen” are value for index columns (separated by comma), ‘committed‘ is the name of the column you want to access the value.

Array or List Support

The Mbean expression supports array or List. For example, the MBean java.lang:type=GarbageCollector,name=Copy has an attribute MemoryPoolNames whose value is a string array (String[], see figure below).


Array or List Support


To access the first element of MemoryPoolNames, the expression could be “MemoryPoolNames.0“, where “0” is the index to the array (0-based). Same rule is used to access elements in a List.

The jmx collector gets username and password information from the device properties – jmx.user and jmx.pass.

Adding JMX Attributes to Collector

Collector does not support the first-level JMX attributes which contain dots. For example, jira-software.max.user.count. Collector treats such attributes as composite attribute and splits them based on the dots. As a result, you may get a null pointer exception in the debug window and NaN in Poll Now for the DataSource.

To instruct Collector not to split the attribute, you can add a backslash ( \ ) before a dot (.). For example, jira-software\.max\.user\.count. With this addition, Collector will not split only those dots which are separated by the escape character. If a string contains any other dots then they will be treated as composite attributes. This also applies to accessing JMX attributes from a debug window.

Additional examples:

Attribute Format Attribute Interpreted in Collector Code 
jira-software\.max.user\.countjira-software.max, user.count
jira-software.max.user.countjira-software, max, user, count
jira-software.max.user\.countjira-software, max, user.count

In This Article