Tag Archives: Glowroot

How to run Glowroot in containers for a Java application? Auto generated using GPT

Generated using: https://chat.openai.com/g/g-uOPo2Wffl-liferay-helper-works-on-open-internet

Running Glowroot on containers, specifically within Docker containers, involves setting up the Glowroot agent to monitor Java applications. Here’s a step-by-step guide to achieve this:

1. Get the Glowroot Agent:

– First, download the Glowroot agent from the [official Glowroot repository](https://github.com/glowroot/glowroot).

– You can download the .zip file of the latest release.

2. Create a Dockerfile for Your Java Application:

– Ensure you have a Dockerfile for your Java application. This Dockerfile will be modified to include the Glowroot agent.

– Here’s an example snippet to include Glowroot in a Dockerfile:

“`Dockerfile

# Use an official Java runtime as a parent image

FROM openjdk:8-jdk-alpine

# Set the working directory in the container

WORKDIR /usr/src/myapp

# Copy the current directory contents into the container at /usr/src/myapp

COPY . /usr/src/myapp

# Copy Glowroot agent

COPY path/to/glowroot /usr/glowroot

# Make port available to the world outside this container

EXPOSE 8080

# Define environment variable

ENV JAVA_OPTS=””

# Run the application

CMD java $JAVA_OPTS -javaagent:/usr/glowroot/glowroot.jar -jar your-app.jar

“`

– Replace path/to/glowroot with the path where you have the Glowroot agent and your-app.jar with your application’s jar file name.

3. Build and Run Your Docker Container:

– Build your Docker image using the command docker build -t your-app-name ..

– Run your Docker container using docker run -p 8080:8080 your-app-name.

4. Access Glowroot UI:

– By default, Glowroot opens on port 4000. If your container is running on your local machine, you can access the Glowroot UI at http://localhost:4000.

– In a production environment, ensure to configure the networking appropriately to access the Glowroot UI.

5. Configure Glowroot (Optional):

– You can configure Glowroot settings by modifying the glowroot.admin.json or through the UI.

– Make sure to set up appropriate security settings, especially if your Glowroot UI is exposed to the internet.

6. Persist Glowroot Data (Optional):

– To persist the data collected by Glowroot, consider mounting a volume to the Glowroot directory in the container. This can be done by adding a volume in your Docker run command like -v your-local-glowroot-dir:/usr/glowroot.

7. Security Considerations:

– Ensure that the Glowroot UI is secure, especially if exposed on the internet. Implement appropriate authentication and access controls.

This setup allows Glowroot to monitor your Java application running inside a Docker container, giving you insights into performance and potential issues.

For more detailed and specific configurations, it’s advisable to consult the [Glowroot documentation](https://glowroot.github.io/glowroot/) and the Docker documentation relevant to your specific setup.

If you need further assistance or have more complex requirements, feel free to reach out to me at Neil@HarwaniSystems.in, visit my blog at www.TechAndTrain.com/blog, check my website www.HarwaniSystems.in, or connect with me on LinkedIn at https://www.linkedin.com/in/neil27/.

Performance tuning in Liferay – Part 2

Following up on the Performance tuning in Liferay – Part 1 post – here are some additional points for performance tuning:

  1. The blue circle in Glowroot slow traces indicates that the transaction is still ongoing whereas yellow indicates it’s completed. Red indicates there is an error.
  2. You can change the JVM gauges as needed to see lot of different types of details of JVM
  3. You can use instrumentation from configuration using type ahead drop down (AJAX style)
  4. You can allocate specific cores to a JVM if need be using an argument on core allotment
  5. You can see thread profiles and take heap dumps from Glowroot itself
  6. Glowroot has sections on errors, queries and service calls
  7. You can get Glowroot to sustain it’s data through restarts using arguments
  8. For frequent garbage collection, check if some queries, etc. are continuously filling up memory and any fine tuning on caching can help
  9. It helps to follow these sections in no particular order and check them regularly: JVM – guages, MBeans (You can search your cache related things here – it’s like seeing things in VisualVM), threads and more, transactions, slow traces (all three areas throughput/etc.), thread profiles (search “blocked” here), queries, service calls, errors, sorting options in transactions, instrumentation, etc.
  10. Latest Glowroot works with Java 11 that is compatible with Liferay for customizations and product usage but not source code compile. This latest Glowroot gives lot many more options especially in transactions.
  11. If you are using Java 8, check if your Glowroot version is compatible with it. Typically 0.13.6 and below are compatible with Java 8 as far as I know.

Email me: Neil@HarwaniSystems.in

Glowroot resources – Part 1

Here are some good Glowroot resources – Part 1. Glowroot is a lightweight, Open source Java APM. Resources / links / blogs here provide details on how to install Glowroot, what are its two deployment types, how to instrument Liferay with it, how to monitor Liferay during upgrade with Glowroot and StackOverflow links on Glowroot.

Email me: Neil@HarwaniSytems.in