• /
  • ログイン

JMX monitoring integration

Our JMX integration allows users to monitor any application that exposes metrics with JMX. The integration includes a default collection file that automatically collects key metrics from the JVM. You can also customize your metric collection with YAML files to collect any subset of metrics.

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.
  • On-host integrations do not automatically update. For best results, regularly update the integration package and the infrastructure agent.

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:

The JMX integration defines and collects integration data using two types of YAML files: the integration configuration options and the metrics collection options.

Configuration options are below. For examples, see Example config.

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.

重要

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.

JMX Instance Settings

The JMX integration collects both metrics (M) and inventory (I) information. Check the Applies To column below to find which settings can be used for each specific collection.

For an example, see the host connection file example.

Setting

Description

Default

Applies To

JMX_HOST

The host JMX is running on.

localhost

M/I

JMX_PORT

The port JMX is running on.

9999

M/I

JMX_URI_PATH

The path portion of the JMX Service URI. This is useful for nonstandard service uris.

N/A

M/I

JMX_USER

The username for the JMX connection.

N/A

M/I

JMX_PASS

The password for the JMX connection.

N/A

M/I

JMX_REMOTE

(JBoss specific) Whether or not to use the JMX remote URL connection format. Connection defaults to JBoss Domain-mode if true.

false

M/I

JMX_REMOTE_JBOSS_STANDLONE

(JBoss specific) Whether or not to use the JBoss standalone connection format. Only relevant if jmx_remote is set.

false

M/I

CONNECTION_URL

Full JMX endpoint URL. This replaces all connection arguments (above) by providing all parameters on one line.

Example: "service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi"

N/A

M/I

COLLECTION_FILES

A comma-separated list of full file paths to the metric collection definition files. For on-host install, the default JVM metrics collection file is at /etc/newrelic-infra/integrations.d/jvm-metrics.yml.

N/A

M/I

KEY_STORE

The filepath of the keystore containing the JMX client's SSL certificate.

N/A

M/I

KEY_STORE_PASSWORD

The password for the SSL key store.

N/A

M/I

LOCAL_ENTITY

Collect all metrics on the local entity. Only use when monitoring localhost.

false

M/I

TIMEOUT

The timeout for individual JMX queries, in milliseconds.

10000

M/I

TRUST_STORE

The filepath of the keystore containing the JMX server's SSL certificate.

N/A

M/I

TRUST_STORE_PASSWORD

The password for the trust store.

N/A

M/I

METRIC_LIMIT

Number of metrics that can be collected per entity. If this limit is exceeded the entity will not be reported. A limit of 0 implies no limit.

200

M/I

METRICS

Set to true to enable Metrics only collection.

false

INVENTORY

Set to true to enable Inventory only collection.

false

The values for these settings can be defined in several ways:

  • Adding the value directly in the config file. This is the most common way.
  • Replacing the values from environment variables using the {{}} notation. This requires infrastructure agent v1.14.0 or higher. Read more here or see the example below.
  • Using secrets management. Use this to protect sensible information (such as passwords) from being exposed in plain text on the configuration file. For more information, see secrets management.

Labels and custom attributes

You can further decorate your metrics using labels. Labels allow you to add key/value pair attributes to your metrics, which you can then use to query, filter or group your metrics on.

Our default sample config file includes examples of labels. These aren't mandatory, and you can remove, modify, or add new ones of your choice.

labels:
env: production
role: jmx

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

ヒント

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

Domains

The integration collects and organizes metrics according to domains. All metrics defined per domain will be sent to New Relic and can be found in a corresponding event type. This event type is either auto-generated or can be set by the user. Each file contains a single collect: block which contains an array of domains. For each domain, the following keys are defined:

  • domain: The JMX domain; for example, java.lang. You can use wildcards to match multiple domains; for example, java.*. If you use a wildcard, event_type is required, and must be unique. This field is required.
  • event_type: The event type name for a collection from this domain. If the domain is wildcarded, this is required, and must be unique. If the domain is not wildcarded and this is undefined by the user, this will be auto generated. For example, the domain java.lang will have event type JavaLangSample. For more information, see Naming tips.
  • beans: An array of beans to collect in this domain.

重要

There is a limit of 200 metrics per instance in the configuration file. If you exceed the limit for a particular instance, it will not be sent to New Relic. If you're not seeing your data in New Relic, review the troubleshooting procedures to identify if you have exceeded the limit.

Beans

Each domain contains an array of beans to be collected. For each bean, the following keys are defined:

  • query: The bean name to collect; for example,type=GarbageCollector,name=YoungGen. You can use wildcards; for example, type=GarbageCollector,name=*. This field is required.
  • exclude_regex: An optional list of regex patterns that match beans to exclude from collection; for example, type=GarbageCollector,name=.*.
  • attributes: A list of attributes to collect. If unspecified, collects all attributes.

重要

The HashMap and ArrayList data types are not supported.

Attributes

Each bean can contain attributes, an optional list of beans that can be excluded from collection. For each attribute, the following keys are defined:

重要

For map attributes, you must define either an attr or an attr_regex key.

  • attr: An exact match of the attribute name. Composite attributes can be collected by appending the composite member name to the attribute name with a dot; for example, HeapMemoryUsage.Max.

  • attr_regex: A regex pattern that matches the attributes to be collected.

  • metric_type: The New Relic metric type to collect this attribute as. Options are:

    • gauge: data will be collected as an instantaneous numeric measurement.
    • rate: data will be collected as the change in that metric per second.
    • delta: data will be collected as the change in that metric since the last measurement.
    • attribute: data will be collected as a string literal.

    If left unspecified, the JMX integration will attempt to infer the metric type based on the value returned. For example, if the metric is a number, it will collect it as gauge. If the metric is a string, it will collect it as attribute.

    If metrics are collected with an incorrect metric type, you can manually specify the correct metric type in the collection file.

  • metric_name: The name under which the metric will appear in New Relic. If unspecified, it will default to the attribute name.

For more information about JMX queries, see the Oracle ObjectName documentation.

Optional: Custom connector

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.

Tips for naming your data

Metrics are sent and stored in the form of samples. This is a list of key-value pairs that include metric data and metadata. Each sample is stored as an event in New Relic’s event database.

You are responsible for creating and naming the JMX data reported to New Relic. For this reason, New Relic strongly recommends following these conventions when naming your event types. To ensure you have a consistent naming scheme:

  • Use camel case.
  • Use a name that clearly identifies what data it contains.

Example: MyorgApplicationSample

Recommendation: Use the same naming scheme for similar metrics across different applications.

Find and use data

Data from this service is reported to an integration dashboard.

JMX data is attached to the user-defined event type specified in the configuration file. For example, if you are interested in monitoring Tomcat using the JMX integration, define an event_type called TomcatSample, and query that event type.

You can query this data for troubleshooting purposes or to create custom charts and dashboards.

For more on how to find and use your data, see Understand integration data.

Metric data

The metrics generated by the integration include metadata associated with the MBean they are collecting from. You can use this metadata in NRQL queries to filter and facet the data so that the query returns only the data for the desired beans. It can also be used to uniquely identify the metrics, since the metric name is not necessarily unique between all beans.

Each event contains the following metadata:

Name

Description

displayName

The JMX domain name for these metrics.

entityName

The JMX domain name for these metrics with the entity type “domain:” prepended.

host

The JMX host the metrics are being collected from.

query

The query used to collect these metrics.

bean

The bean whose attributes these metrics were collected from.

key:<mbean_key>

For each key in the bean name, an attribute is added to the metric set called “key:<mbean_key> with the value of the bean’s key.

Example NRQL query

Here's an example NRQL query taking advantage of metadata monitor all the collected JVM garbage collectors:

SELECT latest(CollectionTime)
FROM JVMSample
FACET `key:name`
WHERE `key:type` = 'GarbageCollector'

Metrics data attributes

The JMX integration collects the following metric data attributes:

Name

Description

HeapMemoryUsage.Used

The total Java heap memory used.

HeapMemoryUsage.Committed

The total Java heap memory committed to be used.

HeapMemoryUsage.Init

The initial Java heap memory allocated.

HeapMemoryUsage.Max

The maximum Java heap memory available.

NonHeapMemoryUsage.Used

The total Java non-heap memory used.

NonHeapMemoryUsage.Committed

The total Java non-heap memory committed to be used.

NonHeapMemoryUsage.Init

The initial Java non-heap memory allocated.

NonHeapMemoryUsage.Max

The maximum Java non-heap memory available.

ThreadCount

The number of live threads.

CollectionCount

The total number of garbage collections that have occurred.

CollectionTime

The approximate accumulated garbage collection time elapsed.

Inventory data

The JMX integration captures the configuration parameters of the JMX integration. The data is available on the Inventory page, under the config/jmx source. For more about inventory data, see Understand integration data.

Troubleshooting

Troubleshooting tips:

Check the source code

This integration is open source software. That means you can browse its source code and send improvements, or create your own fork and build it.

その他のヘルプ

さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:

問題を作成するこのページを編集する
Copyright © 2020 New Relic Inc.