### Start application with Java agent Source: https://prometheus.github.io/jmx_exporter/getting-started/quick-start Command to run the application with the JMX exporter agent attached, binding to port 9404. ```bash java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml -jar your-application.jar ``` -------------------------------- ### Run Java Agent in Combined Mode Source: https://prometheus.github.io/jmx_exporter/deployment/java-agent Starts the application with the agent configured for both HTTP metrics exposure and OpenTelemetry export. ```bash java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml -jar your-application.jar ``` ```yaml openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### OpenTelemetry Configuration YAML Source: https://prometheus.github.io/jmx_exporter/configuration/opentelemetry Example configuration for the OpenTelemetry section within the exporter YAML file. ```yaml openTelemetry: endpoint: http://localhost:4317 protocol: grpc interval: 60 timeoutSeconds: 30 rules: - pattern: ".*" ``` -------------------------------- ### Running the Isolator Java Agent Source: https://prometheus.github.io/jmx_exporter/deployment/isolator-java-agent Example command to launch an application with two isolated JMX exporter instances using different ports and configuration files. ```bash java -javaagent:jmx_prometheus_isolator_javaagent-1.6.0.jar=jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml,jmx_prometheus_javaagent-1.6.0.jar=9405:exporter2.yaml -jar your-application.jar ``` -------------------------------- ### Verify metrics endpoint Source: https://prometheus.github.io/jmx_exporter/getting-started/quick-start URL to access the exposed metrics and an example of the expected output format. ```text http://localhost:9404/metrics ``` ```text # HELP jmx_config_reload_failure_total Number of times configuration have failed to be reloaded. # TYPE jmx_config_reload_failure_total counter jmx_config_reload_failure_total 0.0 ``` -------------------------------- ### Configure HTTP mode via Java agent Source: https://prometheus.github.io/jmx_exporter/deployment/modes Use this argument to start the JMX Exporter as a Java agent on a specific port with a configuration file. ```bash -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml ``` -------------------------------- ### Run Java Agent in HTTP Mode Source: https://prometheus.github.io/jmx_exporter/deployment/java-agent Starts the application with the agent configured to expose metrics on a specific port. ```bash java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml -jar your-application.jar ``` ```yaml rules: - pattern: ".*" ``` -------------------------------- ### Run Java Agent in OpenTelemetry-only Mode Source: https://prometheus.github.io/jmx_exporter/deployment/java-agent Starts the application with the agent configured for OpenTelemetry export without starting an HTTP server. ```bash java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=exporter.yaml -jar your-application.jar ``` ```yaml openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### Build and validate documentation Source: https://prometheus.github.io/jmx_exporter/contributing Use this script to verify website changes against the source behavior. ```bash ./scripts/build-documentation.sh ``` -------------------------------- ### Apply code formatting with Spotless Source: https://prometheus.github.io/jmx_exporter/contributing Run this command before Maven validation to ensure code style compliance. ```bash ./mvnw spotless:apply ``` -------------------------------- ### Configure HTTP Basic Authentication with PBKDF2 Hashing Source: https://prometheus.github.io/jmx_exporter/configuration/authentication Requires passwordHash and salt; iterations and keyLength are optional and use defaults if omitted. ```yaml httpServer: authentication: basic: username: Prometheus algorithm: PBKDF2WithHmacSHA256 salt: 98LeBWIjca passwordHash: 02:56:48:21:BA:EF:62:CC:92:79:90:C4:E6:45:F0:48 rules: - pattern: ".*" ``` -------------------------------- ### Build and unit test the project Source: https://prometheus.github.io/jmx_exporter/building_testing Runs code formatting and executes unit tests while excluding the integration test suite. ```bash ./mvnw spotless:apply ./mvnw test -pl '!integration_test_suite' ``` -------------------------------- ### Run all integration tests Source: https://prometheus.github.io/jmx_exporter/building_testing Executes formatting and runs the integration test suite module when Docker is available. ```bash ./mvnw spotless:apply ./mvnw test -pl integration_test_suite/integration_tests ``` -------------------------------- ### Run integration smoke tests Source: https://prometheus.github.io/jmx_exporter/building_testing Pulls necessary Docker images and executes the quick smoke test script. ```bash cd integration_test_suite && ./pull-smoke-test-docker-images.sh cd .. ./run-quick-test.sh ``` -------------------------------- ### Configure Authentication with Environment Variables Source: https://prometheus.github.io/jmx_exporter/configuration/authentication Supports variable resolution for username and plaintext password fields. ```yaml httpServer: authentication: basic: username: ${USERNAME} password: ${SECRET} rules: - pattern: ".*" ``` -------------------------------- ### Configure HTTP mode via Standalone Source: https://prometheus.github.io/jmx_exporter/deployment/modes Use this command to run the JMX Exporter as a standalone application. ```bash java -jar jmx_prometheus_standalone-1.6.0.jar 9404 exporter.yaml ``` -------------------------------- ### Perform full project validation Source: https://prometheus.github.io/jmx_exporter/building_testing Executes formatting and a full clean verify cycle, which includes integration tests requiring Docker. ```bash ./mvnw spotless:apply ./mvnw clean verify ``` -------------------------------- ### Run Standalone Exporter with OpenTelemetry Source: https://prometheus.github.io/jmx_exporter/configuration/opentelemetry Execute the standalone JMX Prometheus jar with a configuration file. ```bash java -jar jmx_prometheus_standalone-1.6.0.jar exporter.yaml ``` -------------------------------- ### Standalone Configuration with OpenTelemetry Source: https://prometheus.github.io/jmx_exporter/configuration/opentelemetry Configuration for standalone mode including hostPort and OpenTelemetry endpoint. ```yaml hostPort: application.example.com:9999 openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### Configure HTTP Basic Authentication with SHA Hashing Source: https://prometheus.github.io/jmx_exporter/configuration/authentication Requires passwordHash and salt fields for SHA-1, SHA-256, or SHA-512 algorithms. ```yaml httpServer: authentication: basic: username: Prometheus algorithm: SHA-256 salt: 98LeBWIjca passwordHash: 66:5E:DC:0B:04:E9:52:67:64:FC:8F:51:66:72:70:BB rules: - pattern: ".*" ``` -------------------------------- ### Configure custom metrics path Source: https://prometheus.github.io/jmx_exporter/configuration/http-server Sets a non-default path for exposing metrics. The path must be a non-blank string. ```yaml httpServer: metrics: path: /custom/metrics rules: - pattern: ".*" ``` -------------------------------- ### Configure HTTP Basic Authentication with Plaintext Source: https://prometheus.github.io/jmx_exporter/configuration/authentication Use TLS when transmitting credentials with plaintext passwords. ```yaml httpServer: authentication: basic: username: Prometheus password: secret rules: - pattern: ".*" ``` -------------------------------- ### Run Combined Mode Java Agent Source: https://prometheus.github.io/jmx_exporter/configuration/opentelemetry Execute the Java agent in combined mode specifying port and configuration file. ```bash java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=9404:exporter.yaml -jar your-application.jar ``` -------------------------------- ### Minimal JMX Exporter Configuration Source: https://prometheus.github.io/jmx_exporter/configuration Defines a basic configuration with a catch-all rule. If omitted, the collector defaults to a single rule with standard metric formatting. ```yaml rules: - pattern: ".*" ``` -------------------------------- ### Run Java Agent with OpenTelemetry Source: https://prometheus.github.io/jmx_exporter/configuration/opentelemetry Execute the JMX Prometheus Java agent with a configuration file containing OpenTelemetry settings. ```bash java -javaagent:jmx_prometheus_javaagent-1.6.0.jar=exporter.yaml -jar your-application.jar ``` -------------------------------- ### Collect All Metrics with Default Format Source: https://prometheus.github.io/jmx_exporter/configuration/rules A catch-all rule that collects all attributes using the default naming convention. ```yaml rules: - pattern: ".*" ``` -------------------------------- ### Configure Standalone HTTP Mode Source: https://prometheus.github.io/jmx_exporter/examples Minimal configuration for running the JMX Exporter in standalone mode to monitor a remote JMX host. ```yaml hostPort: application.example.com:9999 rules: - pattern: ".*" ``` -------------------------------- ### Combined Mode Configuration Source: https://prometheus.github.io/jmx_exporter/configuration/opentelemetry Advanced configuration including headers, resource attributes, and service metadata. ```yaml openTelemetry: endpoint: http://localhost:4317 protocol: grpc headers: Authorization: Bearer token resourceAttributes: service.name: jmx-exporter serviceInstanceId: instance-001 serviceNamespace: prometheus serviceName: jmx-exporter serviceVersion: "1.6.0" rules: - pattern: ".*" ``` -------------------------------- ### Configure Custom Authenticator Plugin Source: https://prometheus.github.io/jmx_exporter/configuration/authentication Requires a class name that implements com.sun.net.httpserver.Authenticator. ```yaml httpServer: authentication: plugin: class: io.prometheus.jmx.AuthenticatorPlugin subjectAttributeName: io.prometheus.jmx.CustomAuthenticatorSubjectAttribute rules: - pattern: ".*" ``` -------------------------------- ### Configure OpenTelemetry Export Source: https://prometheus.github.io/jmx_exporter/examples Minimal configuration for exporting metrics to an OpenTelemetry endpoint. ```yaml openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### Configure Exporter with jmxUrl Source: https://prometheus.github.io/jmx_exporter/deployment/standalone Defines the target JVM connection using an explicit JMX URL. ```yaml jmxUrl: service:jmx:rmi:///jndi/rmi://application.example.com:9999/jmxrmi rules: - pattern: ".*" ``` -------------------------------- ### Configure Exporter with hostPort Source: https://prometheus.github.io/jmx_exporter/deployment/standalone Defines the target JVM connection using hostPort in the YAML configuration. ```yaml hostPort: application.example.com:9999 rules: - pattern: ".*" ``` -------------------------------- ### Configure OpenTelemetry Export Source: https://prometheus.github.io/jmx_exporter/deployment/standalone Sets up the exporter to send metrics to an OpenTelemetry endpoint. ```yaml hostPort: application.example.com:9999 openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### Configure Attributes as Labels Source: https://prometheus.github.io/jmx_exporter/configuration/metric-customizers Use this configuration to extract specific MBean attributes and apply them as labels to existing metrics. ```yaml includeObjectNames: - io.prometheus.jmx:type=customValue metricCustomizers: - mbeanFilter: domain: io.prometheus.jmx properties: type: customValue attributesAsLabels: - Text rules: - pattern: ".*" ``` -------------------------------- ### Configure Java Agent HTTP Mode Source: https://prometheus.github.io/jmx_exporter/examples Minimal configuration for running the JMX Exporter as a Java agent in HTTP mode. ```yaml rules: - pattern: ".*" ``` -------------------------------- ### Configure Exporter HTTP TLS Source: https://prometheus.github.io/jmx_exporter/configuration/ssl Basic configuration for enabling HTTPS on the exporter HTTP server using a JKS keystore. ```yaml httpServer: ssl: keyStore: filename: keystore.jks type: JKS password: changeit certificate: alias: localhost rules: - pattern: ".*" ``` -------------------------------- ### JmxCollector Constructors Source: https://prometheus.github.io/jmx_exporter/reference/collector-api Use these constructors to initialize the JmxCollector with configuration from a file, string, or input stream. ```java public JmxCollector(File in) throws IOException, MalformedObjectNameException public JmxCollector(File in, JmxCollector.Mode mode) throws IOException, MalformedObjectNameException public JmxCollector(String yamlConfig) throws MalformedObjectNameException public JmxCollector(InputStream inputStream) throws MalformedObjectNameException ``` -------------------------------- ### Configure Extra Metrics Source: https://prometheus.github.io/jmx_exporter/configuration/metric-customizers Use this configuration to define and create new metrics associated with specific MBeans. ```yaml includeObjectNames: - io.prometheus.jmx:type=stringValue metricCustomizers: - mbeanFilter: domain: io.prometheus.jmx properties: type: stringValue extraMetrics: - name: isActive value: true description: This scenario is active. rules: - pattern: ".*" ``` -------------------------------- ### Configure OpenTelemetry exporter Source: https://prometheus.github.io/jmx_exporter/deployment/modes Define the OpenTelemetry endpoint and metric rules within the exporter YAML configuration. ```yaml openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### Enable Remote JMX/RMI SSL Source: https://prometheus.github.io/jmx_exporter/configuration/ssl Enables SSL for standalone remote JMX connections using a simple boolean flag or a detailed map configuration. ```yaml hostPort: application.example.com:9999 ssl: true rules: - pattern: ".*" ``` ```yaml hostPort: application.example.com:9999 ssl: enabled: true keyStore: filename: client.jks type: JKS password: changeit trustStore: filename: truststore.jks type: JKS password: changeit protocols: TLSv1.2,TLSv1.3 ciphers: TLS_AES_128_GCM_SHA256 rules: - pattern: ".*" ``` -------------------------------- ### Run unit tests without Docker Source: https://prometheus.github.io/jmx_exporter/contributing Executes the test suite excluding the integration test module. ```bash ./mvnw test -pl '!integration_test_suite' ``` -------------------------------- ### Advanced JMX Exporter Configuration Skeleton Source: https://prometheus.github.io/jmx_exporter/configuration Provides a comprehensive structure including HTTP server thread management, OpenTelemetry endpoint configuration, and global output formatting flags. ```yaml startDelaySeconds: 0 lowercaseOutputName: false lowercaseOutputLabelNames: false httpServer: metrics: path: /metrics threads: minimum: 1 maximum: 10 keepAliveTime: 120 openTelemetry: endpoint: http://localhost:4317 rules: - pattern: ".*" ``` -------------------------------- ### Define Default Metric Format Source: https://prometheus.github.io/jmx_exporter/configuration/rules The default output format used when a rule matches but no specific name is provided. ```text domain_beanPropertyValue1_key1_key2_...keyN_attrName{beanPropertyName2="beanPropertyValue2", ...} value ``` -------------------------------- ### Enable Remote JMX SSL Source: https://prometheus.github.io/jmx_exporter/deployment/standalone Enables SSL for the remote JMX connection. ```yaml hostPort: application.example.com:9999 ssl: true rules: - pattern: ".*" ``` -------------------------------- ### Isolator Java Agent Argument Format Source: https://prometheus.github.io/jmx_exporter/deployment/isolator-java-agent Defines the syntax for passing multiple exporter configurations to the isolator agent via the -javaagent flag. ```text -javaagent:jmx_prometheus_isolator_javaagent-1.6.0.jar=/path/to/exporter1.jar=agentArgs1,/path/to/exporter2.jar=agentArgs2 ``` -------------------------------- ### Configure Exporter HTTP Mutual TLS Source: https://prometheus.github.io/jmx_exporter/configuration/ssl Enables mutual TLS for the HTTP server by specifying both a keystore and a truststore. ```yaml httpServer: ssl: mutualTLS: true keyStore: type: PKCS12 filename: keystore.pkcs12 password: changeit trustStore: type: PKCS12 filename: truststore.pkcs12 password: changeit certificate: alias: localhost rules: - pattern: ".*" ``` -------------------------------- ### Configure MBean ObjectName Filters Source: https://prometheus.github.io/jmx_exporter/configuration/object-names Define include and exclude patterns for MBeans to control which metrics are collected. ```yaml includeObjectNames: - java.lang:type=Memory - java.lang:type=GarbageCollector,name=* excludeObjectNames: - java.lang:type=MemoryPool,name=CodeHeap* rules: - pattern: ".*" ``` -------------------------------- ### Create Named Metric with Labels Source: https://prometheus.github.io/jmx_exporter/configuration/rules Maps a specific MBean attribute to a custom metric name with static labels and a gauge type. ```yaml rules: - pattern: 'java.langused: (.*)' name: jvm_heap_memory_used_bytes value: '$1' labels: area: heap help: Used heap memory in bytes. type: GAUGE ``` -------------------------------- ### Configure Attribute Filters Source: https://prometheus.github.io/jmx_exporter/configuration/object-names Specify which attributes to include or exclude for specific ObjectNames. ```yaml includeObjectNameAttributes: "java.lang:type=Memory": - HeapMemoryUsage excludeObjectNameAttributes: "java.lang:type=Threading": - AllThreadIds autoExcludeObjectNameAttributes: true rules: - pattern: ".*" ``` -------------------------------- ### JmxCollector Constructors Source: https://prometheus.github.io/jmx_exporter/reference/collector-api The JmxCollector class provides multiple constructors to initialize the collector using different configuration sources such as files, input streams, or YAML strings. ```APIDOC ## JmxCollector Constructors ### Description Initializes a new instance of the JmxCollector to enable JMX collection in Java applications. ### Signatures - `public JmxCollector(File in) throws IOException, MalformedObjectNameException` - `public JmxCollector(File in, JmxCollector.Mode mode) throws IOException, MalformedObjectNameException` - `public JmxCollector(String yamlConfig) throws MalformedObjectNameException` - `public JmxCollector(InputStream inputStream) throws MalformedObjectNameException` ### Parameters - **in** (File) - The configuration file containing exporter YAML. - **mode** (JmxCollector.Mode) - The operational mode (AGENT or STANDALONE). - **yamlConfig** (String) - A string containing the exporter YAML configuration. - **inputStream** (InputStream) - An input stream providing the exporter YAML configuration. ``` -------------------------------- ### Configure HTTP server thread pool Source: https://prometheus.github.io/jmx_exporter/configuration/http-server Defines thread pool parameters for the HTTP server. All three fields are required when configuring threads, and values must be integers greater than zero. ```yaml httpServer: threads: minimum: 1 maximum: 10 keepAliveTime: 120 rules: - pattern: ".*" ``` -------------------------------- ### Configure Remote JMX Authentication Source: https://prometheus.github.io/jmx_exporter/deployment/standalone Provides credentials for connecting to a remote JMX instance requiring authentication. ```yaml hostPort: application.example.com:9999 username: jmx-user password: jmx-password rules: - pattern: ".*" ``` -------------------------------- ### Convert Units with valueFactor Source: https://prometheus.github.io/jmx_exporter/configuration/rules Uses valueFactor to convert milliseconds to seconds during metric collection. ```yaml rules: - pattern: '.*ProcessingTimeMillis: (.*)' name: application_processing_time_seconds value: '$1' valueFactor: 0.001 type: GAUGE ``` -------------------------------- ### Define Pattern Input Shape Source: https://prometheus.github.io/jmx_exporter/configuration/rules The structure of the input string matched against by rules. ```text domainattrName: value ``` -------------------------------- ### Define Counter Metric Source: https://prometheus.github.io/jmx_exporter/configuration/rules Maps an MBean attribute to a Prometheus counter metric. ```yaml rules: - pattern: '.*RequestCount: (.*)' name: application_requests_total value: '$1' type: COUNTER ``` -------------------------------- ### JmxCollector.Mode Source: https://prometheus.github.io/jmx_exporter/reference/collector-api Enum defining the operational modes for the JMX collector. ```APIDOC ## JmxCollector.Mode ### Description Controls the internal collection behavior for the JMX collector. ### Values - **AGENT**: Used for agent deployments. - **STANDALONE**: Used for standalone deployments. ``` -------------------------------- ### Maven Dependency for JMX Exporter Collector Source: https://prometheus.github.io/jmx_exporter/reference/artifacts Use these coordinates to include the JMX Exporter collector module as a library in your Maven project. ```xml io.prometheus.jmx collector 1.6.0 ``` -------------------------------- ### JmxCollector Mode Enum Source: https://prometheus.github.io/jmx_exporter/reference/collector-api Defines the operational mode for the collector, affecting internal collection behavior. ```java public enum JmxCollector.Mode { AGENT, STANDALONE } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.