The Java integration allows you to collect metrics, traces, and logs from your Java application.
If your application exposes JMX metrics, a lightweight Java plugin named JMXFetch (only compatible with Java >= 1.7.) is called by the Datadog Agent to connect to the MBean Server and collect your application metrics. It also sends service checks that report on the status of your monitored instances. This plugin sends metrics to the Datadog Agent using the DogStatsD server running within the Agent. These integrations also use the JMX metrics:
Note: By default, JMX checks have a limit of 350 metrics per instance. If you require additional metrics, contact Datadog support.
Make sure you can open a JMX remote connection. A remote connection is required for the Datadog Agent to connect to the JVM, even when the two are on the same host. For security reasons, it is recommended not to use 0.0.0.0 for the listening address, and using com.sun.management.jmxremote.host=127.0.0.1 for a colocated JVM and Agent is recommended.
If running the Agent as a binary on a host, configure your JMX check as any other Agent integrations. If running the Agent as a DaemonSet in Kubernetes, configure your JMX check using auto-discovery.
Note: To run more than one JMX check, create configuration files with the format jmx_<INDEX>.d/conf.yaml, for example:jmx_1.d/conf.yaml, jmx_2.d/conf.yaml, etc. Each folder should be stored in the conf.d directory. with the is_jmx option set to true in the configuration file.
The standard gcr.io/datadoghq/agent:latest image for running the Datadog Agent container does not have JMX installed. Use the gcr.io/datadoghq/agent:latest-jmx image, this image is based on gcr.io/datadoghq/agent:latest, but it includes a JVM, which the Agent needs to run jmxfetch.
To run a JMX Check against one of your container:
Create a JMX check configuration file by referring to the Host, or by using a JMX check configuration file for one of Datadog officially supported JMX integration:
Mount this file inside the conf.d/ folder of your Datadog Agent: -v <HOST_FOLDER_PATH>:/conf.d. See the Setting up Check Templates documentation to learn more.
Note: Using %%port%% has proven problematic in practice. If you experience an issue, the best workaround is to replace %%port%% with a hard-coded JMX port.
Allows specifying custom jars that are added to the classpath of the Agent’s JVM.
If the Agent needs to connect to a non-default JMX URL, specify it here instead of a host and port. If you use this you need to specify a name for the instance.
Allows creating different configuration files for each application rather than using a single long JMX file. Include the option in each configuration file as explained in the note from the Configuration section.
Instructs the integration to collect the default JVM metrics (jvm.*). Default is true.
Each integration contains a metrics.yaml file that contains a list of default beans to collect. Setting this to True automatically collects those metrics without explicitly adding them to the yaml file. This is typically used for setting up the configuration with Autodiscovery to reduce the size of the configuration object. This is not applicable to collecting JMX metrics with the Java Tracing Agent.
Specify the path to your Java executable or binary if the Agent cannot find it, for example: C:/path/to/java.exe or /etc/alternatives/java
Java JVM options
Used in conjunction with jmx_url.
Set to true to use better metric names for garbage collection metrics. Default is false
Instead of specifying a host and port or jmx_url, the Agent can connect using the attach API. This requires the JDK to be installed and the path to tools.jar to be set.
Refresh period for refreshing the matching MBeans list. Default is 600 seconds. Decreasing this value may result in increased CPU usage.
Refresh period for refreshing the matching MBeans list immediately post initialization. Default is the value of refresh_beans.
The connection timeout, in milliseconds, when connecting to a JVM using host and port or a jmx_url.
Specify the duration without reply from the connected JVM, in milliseconds, after which the Agent gives up on an existing connection and retries.
Attach a service:<SERVICE> tag to every metric, event, and service check emitted by this integration.
Custom service check prefix, for example my_prefix to get a service check called my_prefix.can_connect. Integration name is used as the default if not set.
To be set when process_name_regex is set.
trust_store_path and trust_store_password
Should be set if SSL is enabled.
The conf parameter is a list of dictionaries. Only 2 keys are allowed in this dictionary:
A dictionary of filters - any attribute that matches these filters are collected unless it also matches the “exclude” filters (see below).
A dictionary of filters - attributes that match these filters are not collected.
Tags are automatically added to metrics based on the actual MBean name. You can explicitly specify supplementary tags. For instance, assuming the following MBean is exposed by your monitored application:
It would create a metric called mydomain (or some variation depending on the attribute inside the bean) with tags: attr0:val0, attr1:val1, domain:mydomain, simple:val0, raw_value:my_chosen_value, multiple:val0-val1.
If you specify an alias in an include key that is formatted as camel case, it is converted to snake case. For example, MyMetricName is shown in Datadog as my_metric_name.
Description of the filters
Each include or exclude dictionary supports the following keys:
A domain name or list of domain names, for example: java.lang.
A regex pattern or list of patterns matching the domain name, for example: java\.lang.*.
bean or bean_name
A bean name or list of full bean names, for example: java.lang:type=Compilation.
A regex pattern or list of patterns matching the full bean names, for example: java\.lang.*[,:]type=Compilation.*. You can use capture groups in your regex to supply as tag values. See example configuration above.
A class of list of class names, for example: org.datadog.jmxfetch.SimpleTestJavaApp.
A regex pattern or list of patterns matching the class names, for example: org\.datadog\.jmxfetch\.SimpleTestJavaApp.
A list of tag keys to remove from the final metrics. This can be used to improve the metric tag cardinality, for example: ["attr1", "id", "partition-id"].
A list or a dictionary of attribute names (see below for more details).
Except for regex patterns, all values are case sensitive.
On top of these parameters, the filters support “custom” keys which allows you to filter by bean parameters. For example, if you want to collect metrics regarding the Cassandra cache, you could use the type: - Caches filter: