• Log inStart now

JMX monitoring configuration

The JMX integration defines and collects integration data using two types of YAML files: the integration configuration options and the metrics collection options. To change how the JMX integration collects your data, first add your login credentials to the integration's YAML-format configuration.

Read on to install the integration, and to see what data we collect.

Compatibility and requirements

Our integration is compatible with Java 8 or higher. If you need to use a different Java version than the one configured in PATH, follow New Relic's configuration documentation on GitHub.

Before installing the integration, make sure that you meet the following requirements:

Install and activate

To install the JMX integration, follow the instructions for your environment:

Additional notes:

  • Advanced: Integrations are also available in tarball format to allow for install outside of a package manager.
  • When the Infrastructure agent executes the nri-jmx binary, it sets the path to PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin. The java binary must be in one of those paths.
  • nrjmx and jmx need java binaries to be in the system PATH, which is NOT the PATH for the root user, and isn't affected if you change the PATH environment variable in /root/.bashrc. Read more on how to change the PATH system variable.
  • On-host integrations do not automatically update. For best results, regularly update the integration package and the infrastructure agent.

While you wait for your data to come in...

Did this doc help you install?

Configure the integration

An integration's YAML-format configuration is where you can place required login credentials and configure how data is collected. Which options you change depend on your setup and preference.

There are several ways to configure the integration, depending on how it was installed:

Integration configuration files

The configuration file has common settings applicable to all integrations, such as interval, timeout, or inventory_source. To read all about these common settings refer to our configuration format document.

Important

If you're still using our legacy configuration/definition files, refer to the standard configuration doc for help.

Specific settings related to JMX are defined using the env section of the configuration file. These settings control the connection to your JMX instance as well as other security settings and features. The list of valid settings is described in the next section of this document.

Config options are below. For an example configuration, see the example config file.

Metrics collection files

The metrics collection definition files are structured YAML files which tell the integration what metrics to collect. For an example configuration, see the metrics collection file example.

Default JVM metrics collection file: /etc/newrelic-infra/integrations.d/jvm-metrics.yml

Tip

You can write different collection files to ease organization and maintenance. See configuration file for an example.

Collection configuration using Kubernetes annotations

You can use Kubernetes annotations to provide collection configuration. To achieve this, you need to deploy a configMap into the Kubernetes cluster that will create the configuration file for the nri-jmx application.

In this configuration file you need to specify the command for container auto-discovery, which will allow you to use placeholders in the integration configuration, including Kubernetes annotations.

Example of a configMap to monitor JVM in a Tomcat application:

Next, use annotations to define collection configuration. For example, here's a Tomcat deployment with annotations:

apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
labels:
app: java
spec:
replicas: 1
selector:
matchLabels:
app: java
template:
metadata:
annotations:
newrelic.config: >-
{
"collect": [
{
"domain": "java.lang",
"event_type": "JVMSample",
"beans": [
{
"query": "type=GarbageCollector,name=*",
"attributes": [
"CollectionCount",
"CollectionTime"
]
},
{
"query": "type=Memory",
"attributes": [
"HeapMemoryUsage.Committed",
"HeapMemoryUsage.Init",
"HeapMemoryUsage.Max",
"HeapMemoryUsage.Used",
"NonHeapMemoryUsage.Committed",
"NonHeapMemoryUsage.Init",
"NonHeapMemoryUsage.Max",
"NonHeapMemoryUsage.Used"
]
},
{
"query": "type=Threading",
"attributes": [
"ThreadCount",
"TotalStartedThreadCount"
]
},
{
"query": "type=ClassLoading",
"attributes": [
"LoadedClassCount"
]
},
{
"query": "type=Compilation",
"attributes": [
"TotalCompilationTime"
]
}
]
}
]
}
labels:
app: java
spec:
containers:
- name: tomcat
image: tomcat:10.0.12
ports:
- containerPort: 9999
env:
- name: CATALINA_OPTS
value: '-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false'

Custom connectors

JMX allows the use of custom connectors to communicate with the application. In order to use a custom connector, you have to include the custom connectors in the nrjmx classpath.

By default, the sub-folder connectors is in the classpath. If this folder does not exist, create it under the folder where nrjmx is installed.

For example, to add support for JBoss, create a folder named connectors under the default (Linux) library path /usr/lib/nrjmx/ (/usr/lib/nrjmx/connectors/) and copy the custom connector jar ($JBOSS_HOME/bin/client/jboss-cli-client.jar) into it. You can now execute JMX queries against JBoss.

Example configurations

Example file configurations for an on-host install:

For more about the general structure of on-host integration configuration, see Configuration.

Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.