Performance analysis with Glowroot

In case of performance problems, Relution support may ask for an analysis using Glowroot →. Glowroot records which requests take how long and shows the result in a web interface of its own.

The activation of Glowroot via environment variables of the container, built in up to Relution 27.0, has been removed with Relution 27.1; these variables are ignored as of Relution 27.1. The following guide works on all supported versions — on versions up to 27.0, the old activation just must not be set at the same time, otherwise Glowroot is included twice.

Downloading and verifying Glowroot

The Glowroot package is downloaded from repo.relution.io. It matches the Java version of the Relution image (currently Java 25); the Java version contained in the image in use is shown by:

docker run --rm relution/relution:latest java -version

The checksum ensures that the package arrived unmodified:

wget https://repo.relution.io/glowroot/glowroot-java25-dist.zip
echo "3b9db6b0fc0903233c5e17b6cfa7b022ef8ba6d71ae7d39a9fff6f637608f20c  glowroot-java25-dist.zip" | sha256sum -c
unzip glowroot-java25-dist.zip

The commands are run in the directory containing the docker-compose.yml. Unpacking creates the glowroot directory there. If the check reports FAILED instead of OK, the package must not be used.


Making the web interface reachable

By default, Glowroot binds its web interface to localhost inside the container only. For it to leave the container, the file glowroot/admin.json is created before the start:

echo '{"web": {"bindAddress": "0.0.0.0"}}' > glowroot/admin.json

Glowroot writes its configuration, recordings and logs next to the agent. The directory therefore has to be owned by the container’s user (UID 20001):

sudo chown -R 20001:20001 glowroot

Configuring the container

In the docker-compose.yml, the directory is mounted into the container and the agent is included via JAVA_TOOL_OPTIONS:

  relution:
    image: relution/relution:latest
    environment:
      - JAVA_TOOL_OPTIONS=-javaagent:/opt/glowroot/glowroot.jar
    volumes:
      - ./glowroot:/opt/glowroot
    ports:
      - '127.0.0.1:4000:4000'

If JAVA_TOOL_OPTIONS is already set, the -javaagent entry is appended to the existing value instead of replacing it. After recreating the container (docker compose up -d), the interface is available on port 4000. Thanks to the mounted directory, the recordings are kept even when the container is recreated.

The port mapping 127.0.0.1:4000:4000 binds the interface to the loopback address of the server; it is therefore only reachable from the server itself at http://localhost:4000 — from a workstation, for example, through an SSH tunnel (ssh -L 4000:localhost:4000 <server>).

The interface on port 4000 reveals database queries, response times and stack traces and is initially not protected by a password. It must never be reachable from the internet — therefore do not widen the port mapping 127.0.0.1:4000:4000 to 4000:4000.

Protecting the interface with a password

In addition to the loopback binding, the interface can be protected with a password, for example against other users of the same server. To do so, a user with the Administrator role and a password is created in the interface under Administration → Users, and the anonymous user is removed afterwards. Glowroot stores the password hash in glowroot/admin.json; thanks to the mounted directory it survives restarts.

Since the interface speaks unencrypted HTTP, the password does not replace the loopback binding: over an open port mapping it would be transmitted in plain text.


Disabling Glowroot

Glowroot remains included only for as long as the analysis takes. To disable it, the JAVA_TOOL_OPTIONS line and the port mapping are removed again and the container is recreated. The glowroot directory can be deleted afterwards; if it is kept, the previous recordings are available again for a later analysis.

How helpful was this article?