Install Sentry to Monitor Live Applications

If you’re a developer, you’re probably interested in keeping tabs on live applications. You might want to know when there are errors or exceptions to deal with. With the right tool, you can deploy those apps in a test environment and then keep track of the problems for easier debugging, before you use the app for your company or ship it to customers, clients, or consumers.
One tool that can be used internally is the Sentry real-time crash reporting application, which can be deployed with the help of Docker. Most developers won’t have any problem using Sentry. The basic steps are:
- Create a target project and add the required dependencies.
- Integrate Sentry into the application so it can capture errors in real time.
- Generate API Keys so Sentry can connect with the running app.
How you integrate Sentry into the app will depend on the language used for the app. For example, if you’re deploying a Maven app, you could integrate it with code like this:
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-servlet</artifactId>
<version>6.18.1</version>
</dependency>
However, before you get to that point, you must install Sentry and that’s exactly what we’re going to do here.
What You’ll Need
To install Sentry, you’ll need the following: A server that supports Docker and has a minimum of 4GB of RAM and two cores.
I deployed Sentry as a VM with those minimums and it ran just fine. You’ll also need a user with sudo privilege and an optional domain name pointing to the server (this is required if you’ll be monitoring apps outside your LAN. If you’ll only be monitoring apps within your LAN, this can be done via IP address.
I’ll demonstrate this on an instance of Ubuntu Server 22.04.
Install Docker and Docker Compose
The first thing you must do is install Docker and Docker Compose. If you’ve already taken care of this, you can skip these steps.
First, add the official Docker GPG key with the command:
1 2 |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | && sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg |
Next, add the Docker repository:
1 |
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
Install the required dependencies with the command:
1 |
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release git -y |
Update apt with:
1 |
sudo apt-get update |
Finally, we can install the latest version of the Docker CE runtime engine:
1 |
sudo apt-get install docker-ce docker-ce-cli containerd.io -y |
Install Docker Compose with the command:
1 |
sudo apt-get install docker-compose -y |
Add your user to the docker group with:
1 |
sudo usermod -aG docker $USER |
Log out and log back in for the changes to take effect.
Install Sentry
With Docker and Docker Compose installed, you can now install Sentry. One thing to keep in mind is that the installation can take anywhere between 30 and 60 minutes (depending on the speed of your network and server.
The first step is to clone the on-premise version of Sentry with the command:
1 |
git clone https://github.com/getsentry/onpremise |
Change into the newly-created directory with:
1 |
cd onpremise |
Next, run the install script with:
1 |
bash install.sh |
The installation script will first require you to answer y or no to agree (or disagree) to the collection of data. The only information the company collects is:
- OS username
- IP address
- Install logs
- Runtime errors
- Performance data
The next interactive step in the setup script is creating a user account. Type y for this and then type your email address. The install script will then ask you to create a password for the username but will seem like it’s paused (and doesn’t return a prompt for you to type). Go ahead and type your password and then verify it. Remember, the email address/password combination is what you’ll use to log into Sentry.
The install script will continue to run and (at least in my instance), doesn’t ever give you your prompt back. Once the installation indicates you can continue with the docker-compose command, type the following:
1 |
docker-compose up -d |
At this point, all of the required images will be pulled and deployed. Again, this will take some time, but it will finish by giving your prompt back.
Accessing Sentry
When the docker-compose command completes, open a web browser and point it to http://SERVER:9000 (where SERVER is either the IP address or domain of the hosting server). You’ll be greeted by the Sentry login window (Figure 1), where you’ll type the email address and password you used during the installation.
-
Figure 1: The Sentry login window.
In the next window (Figure 2), you can configure things like the base URL and outbound email. If you want to make any changes, do so on this page.
-
Figure 2: The Sentry web UI setup page.
Once you’ve taken care of the final setup, you’ll be presented with the Sentry main page (Figure 3), where you can create your first project for monitoring.
-
Figure 3: The Sentry web UI setup page.
Congratulations, you’re ready to monitor those apps so you can more easily debug and keep them running as expected.