How to setup self-hosted Sentry

8grams
5 min readApr 27, 2023

--

Sentry

Introduction

In today's fast-paced world of software development, having an efficient alert system, error reporting, and application performance monitoring solution is crucial for maintaining the overall performance and stability of applications. Sentry is an open-source tool designed for this purpose, offering a user-friendly, straightforward experience for developers. With a variety of libraries and frameworks available for integration, Sentry stands out as a reliable choice for development teams. This article will delve into Sentry's features, its open-source nature, and the advantages of using it with docker-compose on a dedicated VM.

About 8grams

We are a small DevOps Consulting Firm that has a mission to empower businesses with modern DevOps practices and technologies, enabling them to achieve digital transformation, improve efficiency, and drive growth.

Ready to transform your IT Operations and Software Development processes? Let’s join forces and create innovative solutions that drive your business forward.

Features of Sentry

  1. Alert System: Sentry provides an effective alert system that notifies developers about critical issues in real-time. This allows teams to proactively address problems, ensuring the application's stability and reducing downtime.
  2. Error Reporting: Sentry's error reporting feature collects and aggregates errors from various sources, presenting them in a comprehensive and easily understandable manner. This helps developers identify and fix issues faster, improving application performance and user experience.
  3. Application Performance Monitoring: Sentry's APM feature enables developers to track and monitor the performance of applications, making it easier to identify bottlenecks and optimize code for better performance.

Integration and Compatibility

Sentry's ease of use is further enhanced by its compatibility with various programming languages and frameworks. With numerous libraries available for integration, developers can seamlessly incorporate Sentry into their projects, regardless of the language or framework they are working with.

Open Source and Self-Hosted

One of the many advantages of Sentry is its open-source nature, which allows developers to access its source code and customize it to suit their specific requirements. Additionally, Sentry can be installed as a self-hosted solution, offering flexibility in terms of deployment options. This enables teams to choose between Kubernetes and docker-compose for their preferred hosting method.

Kubernetes vs. Docker-Compose: Stability Matters

While both Kubernetes and docker-compose are viable options for hosting Sentry, our experience has shown that running Sentry on docker-compose on a dedicated VM provides a more stable environment. In contrast, Sentry installations on Kubernetes have been found to be full of glitches, leading to a less reliable experience.

Integrations with Communication Platforms

Sentry's versatility extends beyond its compatibility with various programming languages and frameworks. It also boasts excellent integration capabilities with popular communication platforms like Slack, Telegram, and Discord. This makes it incredibly easy to incorporate Sentry into a ChatOps architecture design.

ChatOps refers to the use of chat tools and services to facilitate efficient communication and collaboration within development and operations teams. By integrating Sentry with these communication platforms, developers can receive real-time alerts and notifications directly in their chat tools, making it easier to collaborate and address issues as they arise.

This seamless integration with chat platforms contributes to a more streamlined and efficient workflow for developers, as they can quickly discuss and troubleshoot issues without having to switch between multiple applications. The ability to involve Sentry in ChatOps architecture designs further strengthens its value as a comprehensive solution for alert systems, error reporting, and application performance monitoring.

Sentry vs. Datadog vs. New Relic

Selecting the right monitoring solution for your development team can be a challenging task, given the multitude of tools available in the market. In this comparison table below, we provide a fair comparison of three popular monitoring solutions: Sentry, Datadog, and New Relic. While Datadog and New Relic may be considered more feature-rich than Sentry, it's essential to assess each solution based on its unique features, ease of use, and overall effectiveness to make an informed decision.

Sentry vs New Relic vs Datadog

Setup Self-hosted Sentry

We recommend to setup self-hosted Sentry using Docker Compose rather than install it on Kubernetes, since we see many glitches in installation on Kubernetes. Installing Sentry on VM via Docker Compose is pretty straightforward.

Prerequisites

We require a minimum of one virtual machine (VM) with appropriate specifications to ensure optimal performance. Sentry demands significant CPU resources; therefore, it is essential to allocate sufficient CPU power to your VM. The following example illustrates a Terraform resource configuration for setting up a VM with a 4-core CPU and 16 GB of RAM on Google Cloud Platform (GCP). Alternatively, you can choose to manually create a VM tailored to your specific requirements.

Apply Terraform:

~$ terraform apply

After executing the aforementioned Terraform configuration, we will obtain a Public IP Address. To associate this IP address with your domain, create an A Record in your DNS management system. For instance:

A 32.322.322.344 sentry.example.com

We need to install both Docker and Docker Compose which can be done through these commands, assuming we are using Ubuntu Linux here

~$ sudo apt-get update

~$ sudo apt-get install ca-certificates curl gnupg unzip wget

~$ sudo install -m 0755 -d /etc/apt/keyrings

~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

~$ sudo chmod a+r /etc/apt/keyrings/docker.gpg

~$ echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

~$ sudo apt-get update

~$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

~$ sudo groupadd docker

~$ sudo usermod -aG docker $USER

~$ newgrp docker

~$ sudo apt install docker-compose

Install Docker and Docker Compose

Install Sentry

Download Sentry latest release:

~$ wget https://github.com/getsentry/self-hosted/archive/refs/tags/23.4.0.zip

~$ unzip 23.4.0.zip

~$ cd self-hosted-23.4.0

Download Sentry Dependencies by executing install.sh and wait a few minutes until it's done.

~$ sudo chmod +x install.sh

~$ ./install.sh

Run Docker Compose to setup Sentry:

~$ docker-compose up -d

Setup Nginx as Reverse Proxy

Sentry Web Application is running on localhost:9000 and cannot be accessed from outside. We will install Nginx along with Certbot to get SSL Certificate for our Sentry VM.

~$ sudo apt install nginx

Create a Nginx Configuration to handle request for Sentry Web:

~$ sudo vim /etc/nginx/conf.d/sentry.conf

Restart Nginx:

~$ sudo service nginx restart

Install Certbot to get Let's Encrypt SSL Certificate:

~$ sudo certbot --nginx -d sentry.example.com

Boom! You now have Sentry Self-hosted installed on your VM. Access it on https://sentry.example.com

--

--

8grams

We are a DevOps Consulting Firm with a mission to empower businesses with modern DevOps practices and technologies