How to configure Javamelody in Artifactory for monitoring

Andrey Granovsky
2021-03-31 08:53

The goal of JavaMelody is to monitor Java or Java EE applications in your environment.
It is a tool to measure and calculate statistics on real operation of an application depending on the usage of the application by users.
 

IMPORTANT NOTE: Artifactory Version 7.x is currently do not support Javamelody monitoring

​​​​​

Please follow the steps below to add JavaMelody to your Artifactory instance:

  1. Install jar files found in this link to $ARTIFACTORY_NODE_HOME/tomcat/lib . For example:

    curl -L -o javamelody-1.59.0.jar -XGET https://github.com/javamelody/javamelody/releases/download/javamelody-core-1.49.0/jrobin-1.5.9.jar

    curl -L -o javamelody-1.59.0.jar https://github.com/javamelody/javamelody/releases/download/javamelody-core-1.59.0/javamelody-1.59.0.jar

    2. Modify web.xml at $ARTIFACTORY_NODE_HOME/tomcat/webapps/artifactory/WEB-INF/web.xml according to this instruction. For example,

    <filter>

       <filter-name>javamelody</filter-name>

       <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>

       <async-supported>true</async-supported>

    </filter>

    <filter-mapping>

       <filter-name>javamelody</filter-name>

       <url-pattern>/*</url-pattern>

       <dispatcher>REQUEST</dispatcher>

       <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <listener>

       <listener-class>net.bull.javamelody.SessionListener</listener-class>

    </listener>

    3. Restart Artifactory node

    4. Check the result by accessing http(s)://YOUR_ARTIFACTORY_NODE:PORT/CONTEXT/monitoring (e.g. http://localhost:8081/artifactory/monitoring)

    For more information, please visit Javamelody User Guide page.

    In addition, if you want to add an authentication to Javamelody page, you can add a basic authentication with username and password, you may want to add the following (example) :
     

    <filter>

       <filter-name>javamelody</filter-name>

       <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>

       <async-supported>true</async-supported>

     

    <init-param> <param-name>authorized-users</param-name>

    <param-value>admin:password, admin2:password2</param-value> </init-param>

     

    </filter>

    <filter-mapping>

       <filter-name>javamelody</filter-name>

       <url-pattern>/*</url-pattern>

       <dispatcher>REQUEST</dispatcher>

       <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <listener>

       <listener-class>net.bull.javamelody.SessionListener</listener-class>

    </listener>

     

    Once done, please perform the following steps:

    1. Restart Artifactory

    2. Insert your JavaMelody URL (for example: http://localhost:8081/artifactory/monitoring)

    3. Add your credentials as follows:


     

    As a side note, you may want to read more about Securing JavaMelody Installation, and JavaMelody Security.

    Tips: Artifactory exposes JMX MBeans as documented here. Using this, you may monitor DB related status, such as number of active connections.