Skip to content

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

  1. Download the latest glowroot-<version>-dist.zip from 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.
  2. Add -javaagent:path/to/glowroot.jar to your application’s JVM arguments. Where these are set depends on the server; see the next sections.
  3. Make sure the user that runs the JVM can write to the glowroot directory. Glowroot stores its data and configuration there.
  4. 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:

domain.xml
...
<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:

Terminal window
java -javaagent:path/to/glowroot.jar -jar myapp.jar

Arguments 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.

References

Related notes

3 min read

SonarQube

Run SonarQube locally in Docker and analyse a Maven project with the SonarScanner for Maven.

  • Observability & Testing
  • Developer Tools
3 min read

ELK Stack

Run Elasticsearch, Logstash and Kibana in Docker, create a Kibana data view and ship Java logs to Logstash with Logback.

  • Observability & Testing
3 min read

Logback

Two Logback appenders explained: daily rolling log files with size and history limits, and log events written to a database over JNDI.

  • Java & Jakarta EE
  • Observability & Testing

Type to search the whole site.