Prometheus JMX Exporter
repository·main·Indexed 25 days ago
https://github.com/prometheus/jmx_exporterA tool to capture and expose JMX MBean values as Prometheus metrics. It supports running as a standalone Java executable in Prometheus (HTTP) mode or OpenTelemetry mode, and provides a JmxScraper CLI for standalone scraping. The exporter is configured via YAML to define collection rules, HTTP server settings, authentication (Basic or custom plugins), and SSL/TLS configurations.
What's inside jmx_exporter
- The JMX Exporter is a collector designed to capture JMX MBean values and expose them in a format compatible with Prometheus.
Overview of JMX Exporter functionality
mainThe Prometheus JMX Exporter collects Java Management Extensions (JMX) MBean values and converts them into Prometheus metrics. It can also be configured to send metrics through OpenTelemetry.Run integration tests
mainIntegration tests can be run in two ways:
- Quick Smoke Test: Pull the necessary Docker images and run the quick test script.
- Full Integration Test Suite: Run the specific integration test module via Maven.
Note: Both methods require Docker.
# Quick smoke test cd integration_test_suite && ./pull-smoke-test-docker-images.sh cd .. ./run-quick-test.sh # Full integration test suite via Maven ./mvnw spotless:apply ./mvnw test -pl integration_test_suite/integration_testsRun the documentation site locally
mainTo run the Docusaurus documentation site on your local machine, install the dependencies usingnpm ciand then start the development server withnpm run start.npm ci npm run startRun JMX Exporter in Prometheus (HTTP) mode
mainIn Prometheus mode, the standalone server exposes a
/metricsendpoint that allows Prometheus to scrape metrics via HTTP. You must specify a host and port (or just a port) followed by the path to your YAML configuration file.Usage pattern:
java -jar jmx_prometheus_standalone-<VERSION>.jar [HOST:]<PORT> <YAML configuration file>java -jar jmx_prometheus_standalone-1.0.1.jar 12345 config.yamlFind integration-test-backed configurations
mainFor advanced scenarios including Java agent, standalone mode, authentication, TLS, custom metrics paths, thread pools, and HTTP server configurations, refer to the concrete configurations used in the integration test suite located atintegration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test.Perform full validation with integration tests
mainTo perform a full validation of the project, including integration tests, you must have Docker installed and running. This process runs
spotless:applyfollowed by a clean verify cycle../mvnw spotless:apply ./mvnw clean verifyUse the Isolator Java Agent for multiple exporter instances
mainThe Isolator Java Agent allows you to run one or more JMX Exporter Java agent instances within a single JVM by using isolated classloaders. This is necessary when you need multiple independent exporter instances in the same process.
To use it, you must download both the isolator agent jar and the standard JMX exporter jar from the same release version (e.g., 1.6.0).
Format code with Spotless
mainBefore running Maven validation commands, use Spotless to ensure the code follows the project's formatting rules.
./mvnw spotless:applyRun the release script
mainThe
release.shscript automates the release process, including version updates, building, deploying thecollectormodule to Maven Central, and assembling signed artifacts.Prerequisites
gpg(for artifact signing)sha256sum(for checksums)~/.m2/settings.xmlconfigured with credentials for Maven Central- A clean git working directory on the
mainormasterbranch
Usage
Run the script with the target version. You can optionally specify a specific GPG key ID for signing.
Download the JMX Exporter Java agent
mainTo use the JMX Exporter as a Java agent, download the
jmx_prometheus_javaagent-1.6.0.jarfile from the official release page. Using the Java agent is recommended as it runs inside the target JVM and avoids the need for remote JMX/RMI configuration.https://github.com/prometheus/jmx_exporter/releases/download/1.6.0/jmx_prometheus_javaagent-1.6.0.jarBuild the documentation site
mainTo generate a production build of the documentation site, use thenpm run buildcommand.npm run build