APM
Application performance monitoring for Java servers: install the Glowroot agent on GlassFish, Payara or a Spring Boot application.
1 min readUpdated
Application performance monitoring (APM) records what an application does at run time: response times of requests, slow SQL queries, errors and JVM metrics. A Java APM tool usually works as a Java agent that the JVM loads at startup with -javaagent; it instruments the application’s classes without code changes.
This note sets up Glowroot, an open-source APM for Java that runs inside the monitored JVM and serves its own web interface.
Install the Glowroot agent
- Download the latest
glowroot-<version>-dist.zipfrom the Glowroot releases and unzip it. This note was first written for 0.13.6; the current stable release is 0.14.8. The agent requires Java 8 or later. - Add
-javaagent:path/to/glowroot.jarto your application’s JVM arguments. Where these are set depends on the server; see the next sections. - Make sure the user that runs the JVM can write to the
glowrootdirectory. Glowroot stores its data and configuration there. - Start the application and open
http://localhost:4000.
By default the web interface only listens on 127.0.0.1. To reach it from another machine, change the bind address to 0.0.0.0 under Configuration > Web in the Glowroot interface, or in admin.json next to glowroot.jar.
Add the agent to GlassFish or Payara
Add the option to the existing jvm-options of the domain in glassfish/domains/domain1/config/domain.xml (the domain name may differ), then restart the domain:
... <java-config ...> <jvm-options>-javaagent:path/to/glowroot.jar</jvm-options> ... </java-config>...Add the agent to a Spring Boot application
Put the agent option before -jar:
java -javaagent:path/to/glowroot.jar -jar myapp.jarArguments after -jar myapp.jar are passed to the application as program arguments, not to the JVM, so the agent would not load.
The Glowroot wiki lists where the JVM arguments go for WildFly, Jetty, Tomcat, WebSphere and Open Liberty.