Monday, March 21, 2016

Managing and Monitoring Spring Boot Applications with ManageCat

In this post I will show how to manage and monitor Spring Boot applications with ManageCat cloud platform.

According to the Spring Boot web site, Spring Boot makes it easy to create Spring-powered, production-grade applications and services with absolute minimum fuss. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need.

Spring Boot platform include embedded Apache Tomcat server to launch the applications via simple "java -jar application.jar or mvn spring-boot:run" command.

Getting Started

Adding Dependencies to Spring Boot Project

In this post I assumed that the project is a maven based Java project. 
  • If you have not already registered to use the ManageCat SaaS Platform, you have to register from here
  • Download ManageCat Spring Boot JAR file from here
  • Currently ManageCat Spring Boot JAR is not listed in Maven central repository. Therefore, run the following command in your system to add it to your local repository,
    • mvn install:install-file -Dfile=managecat-spring-boot.jar -DgroupId=com.managecat -DartifactId=managecat-spring-boot -Dversion=1.0.1 -Dpackaging=jar
  • Add below content to your POM dependency section:

  • Open your application main java class file which launches your application and update it to include Managecat Embedded Servlet Container Factory and ManageCat properties file. ManageCat properties file configures the ManageCat agent.
    • @ComponentScan
      public class SampleWebUiApplication {

              public EmbeddedServletContainerFactory servletContainerFactory() {
                      return new ManageCatTomcatEmbeddedContainerFactory();

              public static void main(String[] args) throws Exception {
                      SpringApplication springApplication = new SpringApplication(SampleWebUiApplication.class);
                      springApplication.addListeners(new ApplicationPidFileWriter(), new EmbeddedServerPortFileWriter());
  • Add file to your Spring Boot configuration directory (src/main/resources) with the following content
    • managecat.servername=default
    • managecat.accountKey=Your managecat account key sent with email.
      managecat.hostname=Tomcat HOST, example:
      managecat.port=Tomcat PORT, example 80 (if you use HTTPS true otherwise false)
To access your Tomcat from ManageCat SaaS Cloud Platform, TOMCAT_HOST:TOMCAT_PORT must be accessible from internet. You may need to open the TOMCAT_PORT from your firewall.

Here is the explanation of these fields:

  • managecat.warpath : console.war file must be downloaded from ManageCat SaaS Platform main page.  Spring Boot application uses Apache Tomcat 8 embedded Tomcat server. Therefore, you need to download Tomcat 8 console.war file.
  • Copy the downloaded console.war file to managecat.warpath location.
  • Compile and product executable JAR file. (mvn spring-boot:run)
  • If everything is done, you can start your application, you will see a similar log content like:

Now, you can login into the ManageCat UI platform and see your registered server. Open with your registered username and password and click Managed Servers view.

You will see some Tomcat related monitoring metrics in servers table. You can also connect to your
 Spring Boot Tomcat server instance via the Connect IconImage title

It will open a new browser window to manage and monitor your Spring Boot application. Below screenshot shows the realtime Tomcat connector listening in 9092 port.

You can inspect lots of different aspects of your Spring Boot application.

Take a trial from FREE TRIAL


No comments: