Prometheus JMX_EXPORTER for Jboss/Wildfly

2 minutes

Need:

We had a need to expose JVM parameters and other application specific metrics for monitoring.
Altering the code was not an option as we needed a systematic solution to deploy on all our servers without rewriting all projects.

Solution:

As we were already using Prometheus the logical path was to search for a tool which we would easily integrate with an existing solution.
I stumbled upon Prometheus JMX_EXPORTER, a process for exposing JMX Beans via HTTP for Prometheus consumption. Official git page of jmx_exporter can be found here.
With this solution I was able to export any JMX bean on a specific JVM (database info, bean info, JVM parameters, memory, heap, http statistics)

Problems:

The whole project had very little documentation. There is some information on the official git page but unfortunately out of the box setup and configuration didn’t work on Jboss EAP at all.
Even when searching outside the git you could find non info/guilds on how to approach this matter. Eventually after merging few solutions I found on the internet I was able to run and example on Wildfly 12.0.0 in standalone.
Unfortunately this was not enough as all our production servers are running in domain mode. After a few more hours and a little bit of luck (thanks to my college Aleksandar Brankovic) I was done.

  • First step:

All the files that we are going to be used should be located on host servers and placed in the matching folders. You can also place the files on a shared folder so you don’t need to copy/paste them on all of your servers.
Place jmx_prometheus_javaagent.jar that you can find on the official git page and copy it to the $JBOSS_HOME/bin
Place jmx_exporter_conf.yaml $JBOSS_HOME/domain/configuration/
Here is the most simple configuration file that will just be used for this test:

  • Second step:

We need to propagate the -javaagent configuration to all server registered on the domain controller and we need to add other specific configuration that needs to be added in order to fix class loader problems that are present when providing a custom javaagent. Pass these configuration to your domain.xml of domain controller located at $JBOSS_HOME/domain/configuration/domain.xml

At the time of the writing most recent version of WF had jboss-logmanager-2.0.9.Final so in your case check which version is present and change the configuration appropriately. With this configuration metrics will be available on all interfaces on port 58080 as jmx_exporter bind to all interfaces if not provided otherwise. Here is the syntax:

  • Third step:

We need to start our host server and pass the one last argument. In most plain example you start you server via domain.sh file located on your host.

 

After this you should be able to access your metrics on localhost:58080. Later you can pass this location to your Prometheus at tell it to gather the data.

14 Comments

You can post comments in this post.


  • This post helped me a lot with Wildfly 10. You are aposlutely right about jmx_exporter documentation.
    I run Wildfly in standalone configuration so i made changes on ${WF_HOME}/bin/standalone.conf and added JAVA_OPTS like:


    if [ “x$JBOSS_MODULES_SYSTEM_PKGS” = “x” ]; then
    JBOSS_MODULES_SYSTEM_PKGS=”org.jboss.byteman,org.jboss.logmanager”
    fi

    JAVA_OPTS=”$JAVA_OPTS -Xbootclasspath/p:${WF_HOME}/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.4.Final.jar”
    JAVA_OPTS=”$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager”
    JAVA_OPTS=”$JAVA_OPTS -javaagent:${WF_HOME}/prometheus/jmx_prometheus_javaagent-0.3.1.jar=9110:${WF_HOME}/prometheus/jmx_config.yml”

    Basically copied Your config.

    Thank You.
    Regards

    Veselin Perović 6 years ago Reply


    • I’ve used the solution proposed by Veselin Perović for the standalone mode in wildfly 10 and works like a charm!
      Be careful with copy/paste the text, because the quotes mark can change. I’ve working in creating a docker image for wildfly 11 with the jmx exporter included. From the version 15.0.0.Final metric are available by default at :9990/metrics.
      Thank you very much for sharing your knowledge!

      Jonatan Duttweiler 6 years ago Reply


      • After we modified according to Veselin Perović and bring up the standalone mode, what is the URL (what port and context) that we have to put in prometheus.yml in order for Prometheus to get the metrics ?

        Darway 4 years ago Reply


  • About:

    After this you should be able to access your metrics on localhost:58080. Later you can pass this location to your Prometheus at tell it to gather the data.

    Please, exemplo?

    Everson 6 years ago Reply


  • This guide really help me. it also work on EAP6, thanks a lot

    Nick 6 years ago Reply


  • Hi,

    Is it possible for you to guide on how to set up if we using standalone rather than domain? i’ve been stuck trying to set up a JBoss exporter.

    Alvin 5 years ago Reply


    • Setting it up for standalone should be fairly straight forward. Where exactly are you stuck?

      brainiac080195 5 years ago Reply


  • Hi,

    I am trying to setup JMX Exporter for jboss eap version 7.2. I just read your blog, Do we have to do that same configuration for standalone mode as you’ve explained above?

    Can you help me with some steps for standalone mode?

    Vishal Poptani 5 years ago Reply


    • It is much easier to export stat from WF now. No need to additional dependencies, all you need is to visit /metrics on management port. Example on local installation 127.0.0.1:9990/metrics

      brainiac080195 5 years ago Reply


      • I think the 127.0.0.1:9990/metrics is only available on JBoss 7.3 onward, for JBoss 7.2, will have to use that shown by Veselin Perović. Question, after starting the standalone with the revised standalone.conf, where can we see the metrics ? Can see that on browser with which port and “/metrics” or something else ?

        Darway 4 years ago Reply


  • Hi,
    do you have a solution for Java 11 by any chance? Unfortunately “-Xbootclasspath/p” is not a valid option since Java 9 and therefore not possible to use.

    Johannes I 4 years ago Reply


    • You need this to expose Wildfly metrics to for Prometheus?

      brainiac080195 4 years ago Reply


    • I have got the same problem!
      Any solution to export Wildlfy metrics to prometheus, when running wildfly with JAVA 11?

      Torsten 4 years ago Reply


  • Thanks for giving your time to help us.

    fodil 4 years ago Reply


Post A Reply