lcabaceira

Monitoring Alfresco with JavaMelody

Blog Post created by lcabaceira Employee on Nov 11, 2015

How to Monitor Alfresco with JavaMelody

I've recently wrote a post on how to monitor Alfresco using a very robust open-source stack of tools. This is still the more complete and robust way to have an integrated monitoring system covering all your Alfresco infrastructure.

For those who just want to monitor the relevant aspects of your Alfresco application and want to do a quick setup of a monitoring system, JavaMelody is a good solution. If you are troubleshooting a problem and you want to know what is happening with the machine resources (Threads, Memory, Slow JDBC queries, etc) JavaMelody is your friend. It takes no more than 10 minutes to setup.

JavaMelody it’s a simple tool used to monitor Java or Java EE application servers in QA and production environments. It’s a tool to measure and calculate statistics of real operations of an application depending on the usage of the application by users. JavaMelody it’s easy to integrate in most applications.

The tool is mainly based on statistics of requests and evolution charts, allowing us to see in real time the evolution charts of the most important aspects of our Alfresco.

It includes summary charts showing the evolution over time of the following indicators:

    • Number of executions, mean execution times and percentage of errors of http requests, sql requests, jsp pages or methods of business façades (if EJB3, Spring or Guice)

 

    • Java memory, Java CPU , User sessions, Jdbc connections ,Tomcat threads

 

    • An much much more.


These charts can be viewed on the current day, week, month, year or custom period.


javamelody

The Architecture of JavaMelody is lightweight. So it has a lower overhead as I can compare it to other available solutions. The overhead is so low that it can be enabled continuously in QA and Production environments.  A really nice thing is the storage of historical data - you can have a look at the same graphs spanning a week, a month or a year without setting up any additional infrastructure.

JavaMelody helps you to

    • Identify problems before they become too serious

 

    • Optimize based on the more limiting response times

 

    • Find the root causes of response times

 

    • Verify the real improvement after optimization

 

    • Check out the different types of memory being used (Heap, PermGen, Cache etc.)

 

    • Give facts about the average response times and number of executions

 

    • Provide data to help improve applications in QA and production


Detailed documentation can be found at https://github.com/javamelody/javamelody/wiki/UserGuide

1 Installing JavaMelody – Step 1 (Add dependencies to tomcat - jars)



First step should be to download the latest JavaMelody distribution jar from https://github.com/javamelody/javamelody/releases/download/javamelody-core-1.57.0/javamelody-1.57.0.jar and copy it to the alfresco/WEB-INF/lib lib directory.

You also need to include some dependencies to have the full features enabled (Pdf export)

    • jrobin-1.5.9.jar

 

    • iText-2.1.7.jar

 

2 Installing JavaMelody – Step 2 (Update Alfresco web.xml)


To enable the JavaMelody integration you need to update the alfresco deployment descriptor. You can include this update as part of the Tieto build project.

Location:

<tomcatHome>/webapps/alfresco/WEB-INF/web.xml

Edit the web.xm file and add the spring javamelody filter

…..

<filter>

<filter-name>monitoring</filter-name>

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

</filter>

<filter-mapping>

<filter-name>monitoring</filter-name>

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

</filter-mapping>

 

<listener>

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

</listener>

…..



 Update spring contextConfigLocation



…..



<!-- Spring Application Context location monitoring-spring-datasource.xml  monitoring-spring.xml  -->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>

classpath:net/bull/javamelody/monitoring-spring-datasource.xml

/WEB-INF/web-application-context.xml

</param-value>

<description>Spring config file location</description>

</context-param>

….



Note that The SQL time measured is the time from invoking the statement from JDBC until there is a resultset. It does not include the time to fetch the data for a select, nor does it include the time for jdbc ResultSet.next().

3 Installing JavaMelody – Step 3 (Securing JavaMelody)


If you want BASIC authentication with username and password, but do no want to use a realm and 'security-constraint' in web.xml, you can add the parameter 'authorized-users' in web.xml, in context or in system properties like the other javamelody parameters (since v1.53). For example in your WEB-INF/web.xml file:

...

<filter>

<filter-name>monitoring</filter-name>

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

<init-param>

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

<param-value>user1:pwd1, user2:pwd2</param-value>

</init-param>

</filter>



4 Accessing JavaMelody Monitorization


Now that you've done all the necessary steps, restart your tomcat (or other application server) and go to:

    • http://<server>:<port>/alfresco/monitoring


'Voilá' , you have your monitoring server up and running.

5 Disabling JavaMelody


You can disable JavaMelody using disabled=false using the init parameter in web.xml

pass -Djavamelody.disabled=true as system property

7 JavaMelody Maven Integration


You can avoid all the configuration mentioned above if you use the Maven Integration feature on your project build. The dependencies are the following :


<!-- Minimal dependencies for JavaMelody -->

<dependency>

<groupId>net.bull.javamelody</groupId>

<artifactId>javamelody-core</artifactId>

<version>1.57.0</version>

</dependency>

<dependency>

<groupId>org.jrobin</groupId>

<artifactId>jrobin</artifactId>

<version>1.5.9</version>

</dependency>



7 General Web-Application Integration


You can integrate JavaMelody on every web-app, following the example below.

<filter>

<filter-name>monitoring</filter-name>

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

<init-param>

<!-- restrict access using HTTP basic authentication -->

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

<param-value>javamelody:jm123</param-value>

</init-param>

<init-param>

<!-- set a different URL for monitoring -->

<param-name>monitoring-path</param-name>

<param-value>/admin/javamelody</param-value>

</init-param>

<init-param>

<!-- enable/disable JavaMelody -->

<param-name>disabled</param-name>

<param-value>false</param-value>

</init-param>

<init-param>

<!-- define an storage path for JavaMelodys historical data -->

<param-name>storage-directory</param-name>

<param-value>/<YOUR_PATH>/temp/javamelody</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>monitoring</filter-name>

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

</filter-mapping>

<listener>

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

</listener>



8 Conclusion


I hope you enjoy Javamelody and that you find this post useful.  Please post some comments and feedback, those help me to know that actualy anyone is reading my posts :). Seriously, i appreciate your feedback.

Keep sharing, support the Alfresco Community as the Community supports you.

To join our community click https://www.alfresco.com/community

One Love, Luis

Attachments

Outcomes