To set up the JMX Exporter for monitoring WildFly with Prometheus, you can use the example configuration provided for WildFly. Below is a concise guide and an example configuration:
Steps to Configure JMX Exporter for WildFly
-
Download JMX Exporter: Obtain the
jmx_prometheus_javaagent.jarfrom the official Prometheus JMX Exporter GitHub repository.
-
Place the Agent: Copy the
jmx_prometheus_javaagent.jarto a directory accessible by your WildFly server.
-
Create a Configuration File: Use the example
wildfly-10.yamlconfiguration file or customize it as needed.
-
Modify WildFly Startup Script:
-
Add the following JVM argument to the
standalone.confordomain.conffile:Bash-javaagent:/path/to/jmx_prometheus_javaagent.jar=12345:/path/to/wildfly-10.yamlReplace
/path/to/with the actual paths and12345with the desired port for metrics exposure.
-
-
Restart WildFly: Restart the server to apply the changes.
-
Verify Metrics: Access the metrics at
http://127.0.0.1:12345/metrics.
Example Configuration (wildfly-10.yaml)
startDelaySeconds: 0
rules:
- pattern: ".*"
name: "wildfly_jmx_$1"
type: GAUGE
help: "WildFly JMX metric $1"
labels:
instance: "wildfly"
This configuration collects all JMX metrics and exposes them with a generic naming convention. You can customize the rules section to filter or rename metrics as needed.
Additional Notes
-
Ensure the port you specify is closed and not accessible from outside
-
For production, refine the
rulesto avoid collecting unnecessary metrics, which can lead to performance overhead.
For access with basic auth and encryption from outside the wildfly server need to deploy nginx reverse proxy with basic auth and tls encryption. For do this read Install NGINX as reverse proxy to add basic auth and tls encription for exporters not support this out of box .
After install nginx reverse proxy, metrics of your wildfly application will exposed on url:https://<wildfly-host-or-ip>:12345/metrics
after login to this URL you will see some like this:
Enjoy!)