Prometheus JMX Exporter

repository·main·Indexed 25 days ago

https://github.com/prometheus/jmx_exporter

A 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.

Tokens
11.4K
Snippets
55
Records
89
Agent score
85%

What's inside jmx_exporter

  1. Run integration tests

    main

    Integration tests can be run in two ways:

    1. Quick Smoke Test: Pull the necessary Docker images and run the quick test script.
    2. 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_tests
  2. Run JMX Exporter in Prometheus (HTTP) mode

    main

    In Prometheus mode, the standalone server exposes a /metrics endpoint 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.yaml
  3. Find integration-test-backed configurations

    main
    For 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 at integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test.
  4. Use the Isolator Java Agent for multiple exporter instances

    main

    The 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).

  5. Run the release script

    main

    The release.sh script automates the release process, including version updates, building, deploying the collector module to Maven Central, and assembling signed artifacts.

    Prerequisites

    • gpg (for artifact signing)
    • sha256sum (for checksums)
    • ~/.m2/settings.xml configured with credentials for Maven Central
    • A clean git working directory on the main or master branch

    Usage

    Run the script with the target version. You can optionally specify a specific GPG key ID for signing.

  6. Download the JMX Exporter Java agent

    main

    To use the JMX Exporter as a Java agent, download the jmx_prometheus_javaagent-1.6.0.jar file 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.jar