Skip to main content
1.6.0

Java Agent

The Java agent runs inside the target JVM. It is the recommended deployment mode for most users.

Artifact

Download jmx_prometheus_javaagent-1.6.0.jar from the 1.6.0 release.

Argument formats

The Java agent parses one agent argument string:

FormatBehavior
<PORT>:<EXPORTER_YAML>Enable HTTP on 0.0.0.0:<PORT>.
<HOST>:<PORT>:<EXPORTER_YAML>Enable HTTP on the specified host and port.
<EXPORTER_YAML>Do not start HTTP; useful for OpenTelemetry-only configuration.

Ports must be from 1 through 65535. IPv6 hosts must be enclosed in brackets, for example [::1]:9404:exporter.yaml.

HTTP mode example

java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml -jar your-application.jar
rules:
- pattern: ".*"

Metrics are available at http://localhost:9404/metrics.

OpenTelemetry-only example

java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=exporter.yaml -jar your-application.jar
openTelemetry:
endpoint: http://localhost:4317
rules:
- pattern: ".*"

Combined mode example

java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml -jar your-application.jar
openTelemetry:
endpoint: http://localhost:4317
rules:
- pattern: ".*"

Lifecycle and errors

The agent starts through premain at JVM startup or agentmain when attached. Startup registers the JMX collector and starts the enabled exporters. Malformed arguments, invalid ports, unreadable YAML, or invalid configuration fail startup.