### Concrete Installation Example Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/http-mode.md An example of the installation command with specific values for the agent version, port, and configuration file. ```shell java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=12345:exporter.yaml -jar ``` -------------------------------- ### Concrete Installation Example Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/opentelemetry-mode.md A specific example of the installation command, using version 1.5.0 of the agent and 'exporter.yaml' for configuration. ```shell java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=exporter.yaml -jar ``` -------------------------------- ### Concrete Installation Example Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/combined-mode.md An example of how to run the standalone JMX Exporter with a specific version, port, and configuration file. ```shell java -jar jmx_prometheus_standalone-1.5.0.jar 12345 exporter.yaml ``` -------------------------------- ### Release Examples Source: https://github.com/prometheus/jmx_exporter/blob/main/RELEASING.md Examples demonstrating how to use the release script for a specific version or with a custom GPG key. ```shell # Release version 1.6.0 ./release.sh 1.6.0 ``` ```shell # Release with specific GPG key ./release.sh 1.6.0 --gpg-key ABC123DEF ``` -------------------------------- ### Setup Hugo Site and Theme Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/README.md Commands to create a new Hugo site and download/install the Hugo Geekdocs theme. Ensure you have curl and tar installed. ```bash hugo new site docs cd docs/ mkdir -p themes/hugo-geekdoc/ curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/download/v0.41.1/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1 ``` -------------------------------- ### Example: Run Specific Docker Image Source: https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/README.md An example demonstrating how to run the integration test suite with a specific Docker image, such as 'azul/zulu-openjdk:17'. ```shell export JAVA_DOCKER_IMAGES="azul/zulu-openjdk:17" ./mvnw clean verify ``` -------------------------------- ### Install npm packages and build assets Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/themes/hugo-geekdoc/README.md Install required packages from package.json and run the build script to create necessary assets for the theme. This is required if using the theme from a cloned branch. ```shell npm install ``` ```shell npm run build ``` ```shell npm run pack ``` -------------------------------- ### Example Metrics Output Source: https://context7.com/prometheus/jmx_exporter/llms.txt Illustrates the expected Prometheus text exposition format for JVM metrics, including HELP, TYPE, and metric lines. ```shell # Expected output format # HELP jvm_gc_collection_seconds_total Total GC collection time in seconds # TYPE jvm_gc_collection_seconds_total counter # jvm_gc_collection_seconds_total{gc="G1 Young Generation"} 0.123 # HELP jvm_memory_bytes_used Used bytes of a given JVM memory area. # TYPE jvm_memory_bytes_used gauge # jvm_memory_bytes_used{area="heap"} 1.23456789E8 # jvm_memory_bytes_used{area="nonheap"} 5.6789E7 ``` -------------------------------- ### Start Application with JMX Exporter Java Agent (OpenTelemetry Mode) Source: https://context7.com/prometheus/jmx_exporter/llms.txt Start the application with the Java agent, providing only the configuration file. The agent will periodically push metrics to the configured OTLP endpoint. ```shell # Start with OpenTelemetry mode (no port on the command line) java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=exporter.yaml \ -jar your_application.jar ``` -------------------------------- ### Example Metrics Output Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/http-mode.md This is an example of the metrics output you might see when accessing the /metrics endpoint. It shows a counter metric with labels. ```text # HELP my_count_total example counter # TYPE my_count_total counter my_count_total{status="error"} 1.0 my_count_total{status="ok"} 2.0 ``` -------------------------------- ### JMX Exporter Build Output Example Source: https://context7.com/prometheus/jmx_exporter/llms.txt Expected output when building the JMX exporter from source using Maven. This shows the successful completion of various modules. ```text # Expected output # [INFO] Reactor Summary for Prometheus JMX Exporter 1.5.0: # [INFO] Prometheus JMX Exporter ........................... SUCCESS [ 1.049 s] # [INFO] Prometheus JMX Exporter - Collector .............. SUCCESS [ 12.947 s] # [INFO] Prometheus JMX Exporter - Common ................. SUCCESS [ 3.792 s] # [INFO] Prometheus JMX Exporter - Java Agent ............. SUCCESS [ 44.846 s] # [INFO] Prometheus JMX Exporter - Standalone Server ...... SUCCESS [ 7.049 s] # [INFO] BUILD SUCCESS ``` -------------------------------- ### Start Standalone Server in OpenTelemetry Mode Source: https://context7.com/prometheus/jmx_exporter/llms.txt Start the standalone JMX exporter in OpenTelemetry mode, which pushes metrics to a configured endpoint. ```shell java -jar jmx_prometheus_standalone-1.5.0.jar exporter.yaml ``` -------------------------------- ### HTTP BASIC Authentication with PBKDF2WithHmacSHA256 Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/authentication.md Set up HTTP BASIC authentication using PBKDF2WithHmacSHA256. This example includes the salt and password hash. Default iterations are 600000 and keyLength is 128 bits. ```yaml httpServer: authentication: basic: username: Prometheus algorithm: PBKDF2WithHmacSHA256 salt: U9i%=N+m]#i9yvUV:bA/3n4X9JdPXf=n passwordHash: A1:0E:4E:62:F7:1E:0B:59:0A:32:EA:CC:7C:65:37:1F:6D:A6:F1:F1:ED:3F:73:ED:C9:65:19:37:21:5B:6D:4E:9D:C6:61:DF:B5:BF:BB:16:B8:9A:50:14:57:CE:3D:14:67:73:A3:71:1B:87:3B:C4:B1:0E:DC:2D:0B:10:65:D6:F5:B6:DA:07:DD:EE:DA:AC:9C:60:CD:B4:59:0C:C9:CB:A7:3D:7E:30:3E:43:83:E9:E4:13:34:A1:F1:87:5C:24:46:8E:13:90:A6:66:E1:A6:F3:0B:5A:E7:14:8A:98:6A:81:2B:B6:F8:EF:95:D4:82:7E:FB:5E:2D:D3:24:FE:96 ``` -------------------------------- ### Example Isolator Java Agent Configuration Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/isolator-java-agent/_index.md This example demonstrates how to configure two isolated JMX Exporter agents using the Isolator Java agent. Each agent listens on a different port and uses a separate configuration file. ```bash java -javaagent:jmx_prometheus_isolator_javaagent-1.5.0.jar=jmx_prometheus_javaagent-1.5.0.jar=8080:exporter.yaml,jmx_prometheus_javaagent-1.5.0.jar=8081:exporter2.yaml -jar ``` -------------------------------- ### Install JMX Exporter Standalone Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/combined-mode.md Command to run the standalone JMX Exporter JAR. Ensure you replace `` with the actual version and provide the port and configuration file. ```shell java -jar jmx_prometheus_standalone-.jar [HOSTNAME:] ``` -------------------------------- ### Install Isolator Java Agent Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/isolator-java-agent/_index.md Use this command to install the Isolator Java agent. Specify the isolator agent jar, the JMX exporter agent jar(s), and the desired port and configuration file for each instance. ```bash java -javaagent:jmx_prometheus_isolator_javaagent-.jar==[HOSTNAME:]:[,EXPORTER_JAVA_AGENT_JAR>=[HOSTNAME:]:] -jar ``` -------------------------------- ### Start Application with JMX Exporter Java Agent (HTTP Mode) Source: https://context7.com/prometheus/jmx_exporter/llms.txt Attach the JMX Exporter Java agent to your JVM at startup. Specify the port and configuration file. The agent will expose metrics on the /metrics HTTP endpoint. ```shell # Start application with the agent on port 12345 java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=12345:exporter.yaml \ -jar your_application.jar ``` ```shell # Optionally bind to a specific interface java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=0.0.0.0:12345:exporter.yaml \ -jar your_application.jar ``` -------------------------------- ### Start Application with JMX Exporter Java Agent (Combined Mode) Source: https://context7.com/prometheus/jmx_exporter/llms.txt Launch the application with the Java agent, specifying a port for HTTP mode and configuring OpenTelemetry in the YAML. This enables both pull and push metrics collection. ```shell # Port 12345 → HTTP pull; YAML openTelemetry block → push java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=12345:exporter.yaml \ -jar your_application.jar # Prometheus scrape (pull) curl http://localhost:12345/metrics # OpenTelemetry metrics appear on the configured OTLP platform ``` -------------------------------- ### Integration Test Suite Success Output Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/building_testing/_index.md Example output from the integration test suite, showing test class, argument, and method counts, along with total execution time and a final 'TESTS PASSED' status. ```shell [INFO] ------------------------------------------------------------------------ [INFO] Verifyica 0.7.2 Summary (2024-12-02T13:53:18-05:00) [INFO] ------------------------------------------------------------------------ [INFO] Test classes : 40 Passed : 40 Failed : 0 Skipped : 0 [INFO] Test arguments : 506 Passed : 506 Failed : 0 Skipped : 0 [INFO] Test methods : 2302 Passed : 2302 Failed : 0 Skipped : 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] TESTS PASSED [INFO] ------------------------------------------------------------------------ [INFO] Compact Summary | 40 40 0 0 | 506 506 0 0 | 2302 2302 0 0 | 387351.971080 ms | P [INFO] ------------------------------------------------------------------------ [INFO] Total time : 6 m, 27 s, 351 ms (387351.97108 ms) [INFO] Finished at : 2024-12-02T13:59:47-05:00 [INFO] ------------------------------------------------------------------------ [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Prometheus JMX Exporter >: [INFO] [INFO] Prometheus JMX Exporter ............................ SUCCESS [ 0.755 s] [INFO] Prometheus JMX Exporter - Collector ................ SUCCESS [ 9.543 s] [INFO] Prometheus JMX Exporter - Common ................... SUCCESS [ 3.092 s] [INFO] Prometheus JMX Exporter - Java Agent ............... SUCCESS [ 35.511 s] [INFO] Prometheus JMX Exporter - Standalone Server ........ SUCCESS [ 5.672 s] [INFO] Prometheus JMX Exporter - Integration Test Suite ... SUCCESS [ 0.259 s] [INFO] Prometheus JMX Exporter - JMX Example Application .. SUCCESS [ 1.488 s] [INFO] Prometheus JMX Exporter - Integration Tests ........ SUCCESS [06:42 min] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 07:39 min [INFO] Finished at: 2024-12-02T13:59:47-05:00 [INFO] ------------------------------------------------------------------------ ``` -------------------------------- ### JMX Exporter metricCustomizers Configuration Source: https://context7.com/prometheus/jmx_exporter/llms.txt Example YAML configuration for JMX Exporter's metricCustomizers, used to add labels or synthesize new metrics from MBean attributes. ```yaml rules: - pattern: ".*" metricCustomizers: # Add MBean properties as labels on matched metrics - mbeanFilter: domain: kafka.server properties: type: BrokerTopicMetrics attributesAsLabels: - topic - partition # Generate a new metric from a boolean/numeric attribute - mbeanFilter: domain: java.lang properties: type: OperatingSystem extraMetrics: - name: jvm_os_cpu_load value: ProcessCpuLoad description: "JVM process CPU load from OperatingSystem MBean" ``` -------------------------------- ### JMX Exporter YAML Rules Configuration Source: https://context7.com/prometheus/jmx_exporter/llms.txt Example YAML configuration for JMX Exporter rules, demonstrating various options for including, excluding, renaming, and transforming JMX metrics. ```yaml # exporter.yaml — full rules reference startDelaySeconds: 0 # Delay before serving requests (avoids empty sets on startup) lowercaseOutputName: true # Lowercase all metric names lowercaseOutputLabelNames: true # Include only specific MBean domains includeObjectNames: - "java.lang:*" - "kafka.server:*" # Exclude noisy MBeans (takes precedence over includeObjectNames) excludeObjectNames: - "java.util.logging:*" # Auto-exclude attributes that can't be converted to numeric types autoExcludeObjectNameAttributes: true # Exclude specific attributes from specific MBeans (canonical ObjectName form) excludeObjectNameAttributes: "java.lang:type=Memory": - "ObjectPendingFinalizationCount" # Suppress JVM built-in metrics (Java agent only) excludeJvmMetrics: false rules: # Rename a specific attribute, convert ms → s, type as GAUGE - pattern: 'java.lang<>CollectionTime' name: jvm_gc_collection_seconds_total valueFactor: 0.001 type: COUNTER labels: gc: "$1" help: "Total GC collection time in seconds" # Capture multiple groups to build label-rich metric names - pattern: 'kafka.server<>Value' name: kafka_server_$1_$2 type: GAUGE labels: clientId: "$3" topic: "$4" partition: "$5" # Static value injection - pattern: 'java.lang<>SpecVersion' name: jvm_spec_version_info value: 1 labels: version: "$0" type: GAUGE # Snake-case attribute names automatically - pattern: 'java.lang<>(\w+)' name: jvm_threading_$1 attrNameSnakeCase: true type: GAUGE # Cache rule computation for high-cardinality MBeans - pattern: ".*" cache: true ``` -------------------------------- ### Launch Java Agent with Custom Authenticator Source: https://context7.com/prometheus/jmx_exporter/llms.txt Start the JMX Prometheus Java agent with a custom authenticator, specifying the classpath for your custom JARs. ```shell java -cp your_application.jar:myauth.jar \ -javaagent:jmx_prometheus_javaagent-1.5.0.jar=12345:exporter.yaml \ com.example.MainClass ``` -------------------------------- ### Configure Standalone Server with hostPort Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure the standalone JMX exporter to connect to a target JVM using its host and port. This is a common setup for JMX remote invocation. ```shell cat > exporter.yaml <<'EOF' hostPort: your-app-host:5555 rules: - pattern: ".*" EOF ``` -------------------------------- ### Install JMX Exporter Agent in HTTP Mode Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/http-mode.md Use this command to run your Java application with the JMX Exporter agent. Ensure you replace placeholders with your specific values. ```shell java -javaagent:jmx_prometheus_javaagent-.jar=[HOSTNAME:]: -jar ``` ```shell java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=12345:exporter.yaml -jar ``` -------------------------------- ### JMX Exporter Build Success Output Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/building_testing/_index.md Example output indicating a successful build of the Prometheus JMX Exporter project, including individual module statuses and total build time. ```shell ... [INFO] Reactor Summary for Prometheus JMX Exporter : [INFO] [INFO] Prometheus JMX Exporter ............................ SUCCESS [ 1.049 s] [INFO] Prometheus JMX Exporter - Collector ................ SUCCESS [ 12.947 s] [INFO] Prometheus JMX Exporter - Common ................... SUCCESS [ 3.792 s] [INFO] Prometheus JMX Exporter - Java Agent ............... SUCCESS [ 44.846 s] [INFO] Prometheus JMX Exporter - Standalone Server ........ SUCCESS [ 7.049 s] [INFO] Prometheus JMX Exporter - Integration Test Suite ... SUCCESS [ 0.278 s] [INFO] Prometheus JMX Exporter - JMX Example Application .. SUCCESS [ 1.925 s] [INFO] Prometheus JMX Exporter - Integration Tests ........ SUCCESS [ 4.505 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:17 min [INFO] Finished at: 2024-12-02T13:39:20-05:00 [INFO] ------------------------------------------------------------------------ ``` -------------------------------- ### Install JMX Exporter with OpenTelemetry Mode Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/opentelemetry-mode.md Use this command to attach the JMX Prometheus Java agent to your application and enable OpenTelemetry mode. Replace `` with the agent version and `` with your application's JAR file. ```shell java -javaagent:jmx_prometheus_javaagent-.jar= -jar ``` -------------------------------- ### Install JMX Exporter Agent Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/http-mode.md Use this command to attach the JMX Exporter Java agent to your application. Ensure you replace placeholders with your specific version, hostname, port, and configuration file. ```shell java -javaagent:jmx_prometheus_javaagent-.jar=[HOSTNAME:]: -jar ``` -------------------------------- ### Scrape Metrics from JMX Exporter (HTTP Mode) Source: https://context7.com/prometheus/jmx_exporter/llms.txt Fetch the exposed metrics from the /metrics endpoint using curl. The output shows example metric names and values. ```shell # Scrape metrics curl http://localhost:12345/metrics # HELP my_count_total example counter # TYPE my_count_total counter # my_count_total{status="error"} 1.0 # my_count_total{status="ok"} 2.0 ``` -------------------------------- ### JMX Exporter Configuration Patterns Source: https://context7.com/prometheus/jmx_exporter/llms.txt Example YAML patterns for configuring the JMX exporter to collect Kafka metrics. These rules define how to map JMX MBean attributes to Prometheus metrics with specific names and labels. ```yaml - pattern: kafka.(\w+)<>(\d+)thPercentile name: kafka_$1_$2_$3 type: GAUGE labels: "$4": "$5" quantile: "0.$6" # MeanRate percent metrics - pattern: kafka.(\w+)<>MeanRate name: kafka_$1_$2_$3_percent type: GAUGE ``` -------------------------------- ### Start Application with Isolator Java Agent Source: https://context7.com/prometheus/jmx_exporter/llms.txt Attach the isolator agent to the JVM, specifying the path to the main agent JAR, port, and configuration file for each isolated instance. This allows multiple JMX Exporter instances to run concurrently within the same JVM. ```shell # Two isolated exporters: port 8080 and port 8081 java -javaagent:jmx_prometheus_isolator_javaagent-1.5.0.jar= jmx_prometheus_javaagent-1.5.0.jar=8080:exporter1.yaml, jmx_prometheus_javaagent-1.5.0.jar=8081:exporter2.yaml \ -jar your_application.jar ``` -------------------------------- ### Prepare and Run Integration Tests Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/building_testing/_index.md Clone the repository, pull necessary Docker images for smoke tests, and then use Maven Wrapper to clean and verify the project, running integration tests. Docker is required. ```shell git clone https://github.com/prometheus/jmx_exporter cd jmx_exporter ./integration_test_suite/pull-smoke-test-docker-images.sh ./mvnw clean verify ``` -------------------------------- ### Serve Hugo Docs Locally Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/README.md Run this command to serve the documentation locally for development. It will be available at http://localhost:1313. ```bash hugo server -D ``` -------------------------------- ### Basic SSL Configuration in Exporter YAML Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/ssl.md Use this configuration to enable SSL with a specified keystore file and password. The certificate alias must also be provided. ```yaml httpServer: ssl: keyStore: filename: localhost.jks password: changeit certificate: alias: localhost ``` -------------------------------- ### SSL Configuration using System Properties Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/ssl.md Configure SSL by specifying system properties for the Java keystore location and password. The exporter YAML file should still define the certificate alias. ```shell -Djavax.net.ssl.keyStore= -Djavax.net.ssl.keyStorePassword= ``` -------------------------------- ### HTTPS Configuration with System Properties Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure HTTPS using system properties for keystore location and password, rather than embedding them in the YAML. ```yaml # Use system properties for the keystore instead httpServer: ssl: certificate: alias: localhost ``` -------------------------------- ### Launch Agent with System Property Keystore and HTTPS Source: https://context7.com/prometheus/jmx_exporter/llms.txt Launch the JMX Prometheus Java agent using system properties for SSL configuration and scrape metrics over HTTPS. ```shell # System-property keystore approach java -Djavax.net.ssl.keyStore=localhost.jks \ -Djavax.net.ssl.keyStorePassword=changeit \ -javaagent:jmx_prometheus_javaagent-1.5.0.jar=12345:exporter.yaml \ -jar your_application.jar curl --cacert ca.crt https://localhost:12345/metrics # With mutual TLS curl --cacert ca.crt --cert client.crt --key client.key https://localhost:12345/metrics ``` -------------------------------- ### Configure Standalone Server with SSL and Authentication Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure the standalone JMX exporter for secure connections using SSL and basic authentication credentials. ```shell cat > exporter.yaml <<'EOF' hostPort: your-app-host:5555 ssl: true username: monitorRole password: monitorPassword rules: - pattern: ".*" EOF ``` -------------------------------- ### Run All Java Docker Images Source: https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/README.md Execute the integration test suite against all available Java Docker images. This provides comprehensive testing but may take longer. ```shell export JAVA_DOCKER_IMAGES=ALL ./mvnw clean verify ``` -------------------------------- ### Build JMX Exporter with Unit Tests Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/building_testing/_index.md Clone the repository and use Maven Wrapper to clean and package the project, executing unit tests during the build process. Java 11+ is required. ```shell git clone https://github.com/prometheus/jmx_exporter cd jmx_exporter ./mvnw clean package ``` -------------------------------- ### Running JMX Exporter Integration Tests Source: https://context7.com/prometheus/jmx_exporter/llms.txt Commands to pull Docker images for smoke tests and then run the full Maven verification, which includes integration tests. This requires Docker to be configured as shown previously. ```shell ./integration_test_suite/pull-smoke-test-docker-images.sh ./mvnw clean verify ``` -------------------------------- ### Configure Standalone Server with JMX URL Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure the standalone JMX exporter using a full JMX service URL, which provides more detailed connection information for RMI. ```shell cat > exporter.yaml <<'EOF' jmxUrl: service:jmx:rmi:///jndi/rmi://your-app-host:5555/jmxrmi rules: - pattern: ".*" EOF ``` -------------------------------- ### Configure JMX Exporter for Combined Mode Source: https://context7.com/prometheus/jmx_exporter/llms.txt Enable both HTTP and OpenTelemetry modes by providing a port on the command line and an 'openTelemetry' block in the YAML configuration. ```shell cat > exporter.yaml <<'EOF' openTelemetry: endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 60 rules: - pattern: ".*" EOF ``` -------------------------------- ### Configuring Docker for Integration Tests Source: https://context7.com/prometheus/jmx_exporter/llms.txt Steps to configure the Docker daemon's JSON file to set the required address pool size for integration tests. This is a prerequisite for running the smoke tests. ```shell # First configure Docker daemon.json for the required address pool size: cat > /etc/docker/daemon.json <<'EOF' { "default-address-pools": [ {"base": "172.16.0.0/16", "size": 24}, {"base": "192.168.0.0/16", "size": 24} ] } EOF systemctl restart docker ``` -------------------------------- ### Configure OpenTelemetry Settings via Environment Variables Source: https://context7.com/prometheus/jmx_exporter/llms.txt Alternatively, configure OpenTelemetry settings using environment variables. This provides flexibility in managing exporter behavior. ```shell # Alternatively, drive all OTEL settings via environment variables cat > exporter.yaml <<'EOF' openTelemetry: {} rules: - pattern: ".*" EOF export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318 export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf export OTEL_METRIC_EXPORT_INTERVAL=30000 # milliseconds java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=exporter.yaml \ -jar your_application.jar ``` -------------------------------- ### Advanced OpenTelemetry YAML Configuration using Environment Variables Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/opentelemetry-mode.md This configuration relies on environment variables for endpoint, protocol, and interval settings. Ensure 'OTEL_EXPORTER_OTLP_ENDPOINT', 'OTEL_EXPORTER_OTLP_PROTOCOL', and 'OTEL_METRIC_EXPORT_INTERVAL' are set. ```yaml openTelemetry: # endpoint defined via environment variable "OTEL_EXPORTER_OTLP_ENDPOINT" # protocol defined via environment variable "OTEL_EXPORTER_OTLP_PROTOCOL" # interval defined via environment variable "OTEL_METRIC_EXPORT_INTERVAL" rules: - pattern: ".*" ``` -------------------------------- ### Configure JMX Exporter for HTTP Mode Source: https://context7.com/prometheus/jmx_exporter/llms.txt Create a YAML configuration file to define which MBeans to collect. The pattern '.*' collects all MBeans. ```shell # exporter.yaml — collect every MBean cat > exporter.yaml <<'EOF' rules: - pattern: ".*" EOF ``` -------------------------------- ### Run Integration Tests with Smoke Test Containers Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/building_testing/_index.md Execute the smoke-test.sh script to build and run the integration test suite using smoke test containers. Output is logged to smoke-test.log. ```shell ./smoke-test.sh ``` -------------------------------- ### Running JMX Exporter and Fetching Metrics Source: https://context7.com/prometheus/jmx_exporter/llms.txt Demonstrates how to run the JMX exporter as a Java agent and then fetch the exposed metrics using curl. This is a common pattern for integrating applications with Prometheus. ```shell java -javaagent:jmx_prometheus_javaagent-1.5.0.jar=7071:kafka-2_0_0.yml \ -jar kafka/libs/kafka_2.13-2.8.0.jar \ kafka.Kafka config/server.properties curl http://localhost:7071/metrics | grep kafka_server_broker #kafka_server_brokertopicmetrics_messagesin_total{topic="my-topic"} 42.0 ``` -------------------------------- ### Run Smoke Test Docker Images Source: https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/README.md Execute the integration test suite using the default smoke test Docker images. This is a quick way to verify basic functionality. ```shell ./mvnw clean verify ``` -------------------------------- ### Basic YAML Configuration (jmxUrl) Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/http-mode.md Alternatively, configure the exporter using a JMX URL for connecting to your application's RMI endpoint. This also requires your application to expose RMI. ```yaml jmxUrl: service:jmx:rmi:///jndi/rmi://:/jmxrmi rules: - pattern: ".*" ``` -------------------------------- ### Run Specific Docker Image Source: https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/README.md Execute the integration test suite against a custom Docker image. Replace "" with the desired image name. ```shell export JAVA_DOCKER_IMAGES="" ./mvnw clean verify ``` -------------------------------- ### Docker Daemon Configuration for Integration Tests Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/building_testing/_index.md Configure Docker's daemon.json to define default address pools, which may be necessary for running integration tests that utilize multiple Docker networks. ```json { "default-address-pools" : [ { "base" : "172.16.0.0/16", "size" : 24 }, { "base" : "192.168.0.0/16", "size" : 24 } ] } ``` -------------------------------- ### Configure Standalone Server for OpenTelemetry Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure the standalone JMX exporter to push metrics to an OpenTelemetry collector endpoint. Specify the endpoint, protocol, and interval. ```shell cat > exporter.yaml <<'EOF' openTelemetry: endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 60 hostPort: your-app-host:5555 rules: - pattern: ".*" EOF ``` -------------------------------- ### Basic YAML Configuration (hostPort) Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/http-mode.md Configure the exporter to connect to your application's JMX endpoint using host and port. This requires your application to expose RMI. ```yaml hostPort: : rules: - pattern: ".*" ``` -------------------------------- ### HTTP BASIC Authentication with Environment Variable Password Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/authentication.md Securely provide the password for HTTP BASIC authentication using an environment variable. ```yaml httpServer: authentication: basic: username: Prometheus password: ${SECRET} ``` -------------------------------- ### Basic OpenTelemetry YAML Configuration Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/opentelemetry-mode.md Configure the OpenTelemetry exporter endpoint, protocol, and collection interval. The 'pattern' rule ensures all metrics are collected. ```yaml openTelemetry: endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 60 rules: - pattern: ".*" ``` -------------------------------- ### Basic YAML Configuration with OpenTelemetry and RMI URL Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/combined-mode.md An alternative basic YAML configuration for OpenTelemetry mode, specifying the JMX URL directly for RMI connections. ```yaml openTelemetry: endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 60 jmxUrl: service:jmx:rmi:///jndi/rmi://:/jmxrmi rules: - pattern: ".*" ``` -------------------------------- ### Basic YAML Configuration for HTTP Mode Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/http-mode.md This is a minimal configuration file for the JMX Exporter when running in HTTP mode. It uses a simple pattern to include all metrics. ```yaml rules: - pattern: ".*" ``` -------------------------------- ### Run JMX Exporter Java Agent with Multiple JARs Source: https://context7.com/prometheus/jmx_exporter/llms.txt Use this command to run the JMX exporter as a Java agent, supporting multiple versions of the agent JAR and different configuration files for distinct ports. ```shell java -javaagent:jmx_prometheus_isolator_javaagent-1.5.0.jar=jmx_prometheus_javaagent-1.4.0.jar=8080:exporter1.yaml, jmx_prometheus_javaagent-1.5.0.jar=8081:exporter2.yaml \ -jar your_application.jar ``` -------------------------------- ### Configure Multiple Isolated Exporters Source: https://context7.com/prometheus/jmx_exporter/llms.txt Create separate YAML configuration files for each isolated exporter instance. Each file defines specific MBean collection rules. ```shell cat > exporter1.yaml <<'EOF' rules: - pattern: "java.lang.*" EOF cat > exporter2.yaml <<'EOF' rules: - pattern: "kafka.*" EOF ``` -------------------------------- ### HTTP BASIC Authentication with SHA-256 Hashed Password Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/authentication.md Configure HTTP BASIC authentication using a SHA-256 hashed password with a specified salt. The passwordHash is generated from `:`. ```yaml httpServer: authentication: basic: username: Prometheus algorithm: SHA-256 salt: U9i%=N+m]#i9yvUV:bA/3n4X9JdPXf=n passwordHash: 2bf7ed4906ac065bde39f7508d6102a6cdd7153a929ea883ff6cd04442772c99 ``` -------------------------------- ### Run Standalone JMX Exporter Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/opentelemetry-mode.md Command to run the standalone JMX Exporter JAR. Replace with the actual version number. ```shell java -jar jmx_prometheus_standalone-.jar exporter.yaml ``` -------------------------------- ### Download Isolator Java Agent Source: https://context7.com/prometheus/jmx_exporter/llms.txt Download the isolator Java agent and the main Java agent JARs. The isolator agent requires the main agent JAR to function. ```shell # Download the isolator agent curl -LO https://github.com/prometheus/jmx_exporter/releases/download/1.5.0/jmx_prometheus_isolator_javaagent-1.5.0.jar curl -LO https://github.com/prometheus/jmx_exporter/releases/download/1.5.0/jmx_prometheus_javaagent-1.5.0.jar ``` -------------------------------- ### Scrape Metrics with Basic Auth Source: https://context7.com/prometheus/jmx_exporter/llms.txt Use `curl` to scrape metrics from the exporter endpoint, providing basic authentication credentials. ```shell # Scrape with BASIC auth curl -u Prometheus:secret http://localhost:12345/metrics ``` -------------------------------- ### Basic YAML Configuration with OpenTelemetry Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/combined-mode.md A basic YAML configuration for the JMX Exporter enabling OpenTelemetry mode. Metrics are pushed to the specified endpoint at a defined interval. ```yaml openTelemetry: endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 60 hostPort: : rules: - pattern: ".*" ``` -------------------------------- ### Convenience Test Scripts for JMX Exporter Source: https://context7.com/prometheus/jmx_exporter/llms.txt A list of convenience scripts provided by the JMX exporter project for running different types of tests, from a fast subset to full regression and stress testing. ```shell ./run-quick-test.sh # fast subset ./run-smoke-test.sh # smoke containers ./run-regression-test.sh # full regression ./run-stress-test.sh # stress testing ``` -------------------------------- ### PBKDF2WithHmacSHA256 Authentication Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure basic HTTP authentication using PBKDF2WithHmacSHA256. Use `openssl kdf` to generate the password hash and salt. ```yaml httpServer: authentication: basic: username: Prometheus algorithm: PBKDF2WithHmacSHA256 salt: "U9i%=N+m]#i9yvUV:bA/3n4X9JdPXf=n" passwordHash: "A1:0E:4E:62:..." ``` -------------------------------- ### HTTPS Configuration with Embedded Keystore Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure the HTTP server to use HTTPS with a JKS keystore embedded directly in the exporter configuration. ```yaml # exporter.yaml — HTTPS with keystore embedded in config httpServer: ssl: keyStore: filename: localhost.jks password: changeit certificate: alias: localhost ``` -------------------------------- ### Environment Variable Authentication Source: https://context7.com/prometheus/jmx_exporter/llms.txt Inject username and password for basic HTTP authentication from environment variables. Ensure PROM_USER and PROM_PASS are set. ```yaml httpServer: authentication: basic: username: ${PROM_USER} password: ${PROM_PASS} ``` -------------------------------- ### YAML Configuration with RMI Authentication Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/combined-mode.md YAML configuration for providing username and password credentials for RMI server authentication. ```yaml hostPort: : username: password: rules: - pattern: ".*" ``` -------------------------------- ### Basic Metrics Scrape Source: https://context7.com/prometheus/jmx_exporter/llms.txt Scrape metrics from the default `/metrics` endpoint using `curl`. ```shell # Basic scrape curl http://localhost:12345/metrics ``` -------------------------------- ### Configure JMX Exporter for OpenTelemetry Mode Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure the exporter to push metrics to an OpenTelemetry OTLP endpoint. Specify the endpoint, protocol, and collection interval in the YAML file. ```shell # exporter.yaml — push to a Prometheus OTLP endpoint every 60 s cat > exporter.yaml <<'EOF' openTelemetry: endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 60 rules: - pattern: ".*" EOF ``` -------------------------------- ### Scrape Metrics with Authentication Source: https://context7.com/prometheus/jmx_exporter/llms.txt Scrape metrics from the `/metrics` endpoint, providing basic authentication credentials. ```shell # Scrape with authentication curl -u Prometheus:secret http://localhost:12345/metrics ``` -------------------------------- ### Accessing Metrics Endpoint Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/java-agent/http-mode.md Once the application is running with the agent, you can access the metrics by navigating to this URL in your browser. Replace placeholders with your application's hostname or IP and the configured port. ```text http://:/metrics ``` -------------------------------- ### Download JMX Exporter Standalone JAR Source: https://context7.com/prometheus/jmx_exporter/llms.txt Download the standalone JMX exporter JAR file from the GitHub releases page. This is used when attaching a Java agent is not possible. ```shell curl -LO https://github.com/prometheus/jmx_exporter/releases/download/1.5.0/jmx_prometheus_standalone-1.5.0.jar ``` -------------------------------- ### Release Prometheus JMX Exporter Source: https://github.com/prometheus/jmx_exporter/blob/main/RELEASING.md Execute the release script with the desired version. Ensure you have the necessary prerequisites and a clean git working directory on the main branch. ```shell ./release.sh ``` ```shell ./release.sh --gpg-key ``` ```shell ./release.sh --help ``` -------------------------------- ### HTTP BASIC Authentication with Plaintext Password Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/authentication.md Use this configuration for simple HTTP BASIC authentication when the password can be stored in plaintext. ```yaml httpServer: authentication: basic: username: Prometheus password: secret ``` -------------------------------- ### Kafka 2.x Metrics Configuration Source: https://context7.com/prometheus/jmx_exporter/llms.txt A comprehensive YAML configuration for Kafka 2.x, mapping JMX counters and gauges to Prometheus metric names with labels. ```yaml # examples/kafka-2_0_0.yml lowercaseOutputName: true rules: # Per-second counters with two key/value pairs - pattern: kafka.(\w+)<>Count name: kafka_$1_$2_$3_total type: COUNTER labels: "$4": "$5" "$6": "$7" # Per-second counters with one key/value pair - pattern: kafka.(\w+)<>Count name: kafka_$1_$2_$3_total type: COUNTER labels: "$4": "$5" # Gauges with two key/value pairs - pattern: kafka.(\w+)<>Value name: kafka_$1_$2_$3 type: GAUGE labels: "$4": "$5" "$6": "$7" ``` -------------------------------- ### YAML Configuration with RMI SSL Enabled Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/combined-mode.md YAML configuration for enabling SSL on the RMI connection when the application's RMI server requires it. ```yaml hostPort: : ssl: true rules: - pattern: ".*" ``` -------------------------------- ### Scrape Metrics from Standalone Server Source: https://context7.com/prometheus/jmx_exporter/llms.txt Use curl to scrape the metrics endpoint exposed by the running standalone JMX exporter server. ```shell curl http://localhost:12345/metrics ``` -------------------------------- ### Pull All Docker Images Source: https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/README.md Manually pull all Docker images used in the test suite. This is optional but can prevent timeouts during testing. ```shell ./integration_test_suite/pull-docker-images.sh ``` -------------------------------- ### Download JMX Exporter Java Agent Source: https://context7.com/prometheus/jmx_exporter/llms.txt Download the JMX Exporter Java agent JAR file from the releases page. ```shell # Download the agent jar curl -LO https://github.com/prometheus/jmx_exporter/releases/download/1.5.0/jmx_prometheus_javaagent-1.5.0.jar ``` -------------------------------- ### Custom Pluggable Authenticator Source: https://context7.com/prometheus/jmx_exporter/llms.txt Replace basic authentication with a custom Java Authenticator class. The class must be on the JVM classpath. ```yaml # exporter.yaml — custom authenticator, no Subject propagation httpServer: authentication: plugin: class: com.example.MyAuthenticator ``` -------------------------------- ### Custom Pluggable Authenticator Configuration Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/authentication.md Configure a custom Java authenticator plugin by specifying its class name. The class must have a no-argument constructor and be present in the JVM classpath. ```yaml httpServer: authentication: plugin: class: my.custom.AuthenticatorWithNoArgConstructor ``` -------------------------------- ### Configure HTTP Server Threads Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/miscellaneous.md Set the minimum and maximum number of threads for the HTTP server, along with the thread keep-alive time in seconds. By default, a maximum of 10 threads are used. ```yaml httpServer: threads: minimum: 1 maximum: 10 keepAliveTime: 120 # seconds ``` -------------------------------- ### SHA-256 Salted Hash Authentication Source: https://context7.com/prometheus/jmx_exporter/llms.txt Configure basic HTTP authentication using a SHA-256 salted hash for the password. Generate the hash using `sha256sum`. ```yaml httpServer: authentication: basic: username: Prometheus algorithm: SHA-256 salt: "U9i%=N+m]#i9yvUV:bA/3n4X9JdPXf=n" passwordHash: "2bf7ed4906ac065bde39f7508d6102a6cdd7153a929ea883ff6cd04442772c99" ``` -------------------------------- ### Mutual TLS Configuration Source: https://context7.com/prometheus/jmx_exporter/llms.txt Enable Mutual TLS for HTTPS, requiring clients to present valid certificates verified against a truststore. ```yaml # Mutual TLS: verify client certificates against a truststore httpServer: ssl: mutualTLS: true trustStore: filename: ca.jks type: JKS password: changeit keyStore: filename: localhost.jks password: changeit certificate: alias: localhost ``` -------------------------------- ### Mutual TLS Configuration in Exporter YAML Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/http-mode/ssl.md Enable mutual TLS for client certificate verification by setting `mutualTLS` to true and configuring the `trustStore` parameters alongside the `keyStore`. ```yaml httpServer: ssl: mutualTLS: true trustStore: filename: ca.jks type: JKS password: changeit keyStore: filename: localhost.jks password: changeit certificate: alias: localhost ``` -------------------------------- ### Run JMX Exporter Java Agent Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/opentelemetry-mode.md Command to run the JMX Exporter as a Java agent. This method attaches the exporter to a running Java application. ```shell java -javaagent:jmx_prometheus_javaagent-1.5.0.jar exporter.yaml ``` -------------------------------- ### Pull Smoke Test Docker Images Source: https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/README.md Manually pull the Docker images required for the smoke tests. This is optional but can prevent timeouts during testing. ```shell ./integration_test_suite/pull-smoke-test-docker-images.sh ``` -------------------------------- ### Access Metrics Endpoint Source: https://github.com/prometheus/jmx_exporter/blob/main/docs/content/1.5.0/standalone/http-mode.md Once the JMX Exporter is running, you can access the collected metrics by navigating to the `/metrics` endpoint on the specified hostname and port. ```text http://:/metrics ``` -------------------------------- ### Scrape Metrics over HTTPS Source: https://context7.com/prometheus/jmx_exporter/llms.txt Scrape metrics from the `/metrics` endpoint using HTTPS, providing the CA certificate for verification. ```shell # Scrape over HTTPS curl --cacert ca.crt https://localhost:12345/metrics ```