How to install Sentry on AWS EC2?

Davod
3 min readJul 15, 2022

--

Sentry is an open-source full-stack error tracking system which supports a wide range of platforms. Since it is an open-source system, the code is available online to deploy on your own infrastructure.

To have your own on-premise Sentry on Amazon you can do these wizard steps:

1. Create your instance on EC2

Create an Instance EC2 with this configuration:

  • OS: Ubuntu 22
  • Type: T2.Large
  • HDD: 40 GB gp3

2. Install Requirements

Start by installing the packages that is required to install docker with the following command:

$ sudo apt update && upgrade$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

3. Install Docker

Add Docker’s GPG key by downloading it with the following command:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Then, add the Docker repository with the following command:

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"$ sudo apt-cache policy docker-ce$ sudo apt update$ sudo apt install docker-ce

Start and check the status of docker with the following command.

$ sudo systemctl start docker
$ sudo systemctl status docker

You can confirm the installation with the version command.

$ docker version

4. Install docker-compose

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

$ sudo chmod +x /usr/local/bin/docker-compose

Verify your installation by this command:

$ docker-compose --version

5. Get Sentry Package

$ cd /home/
$ git clone https://github.com/getsentry/self-hosted sentry
$ cd sentry/

6. Edit config files

Before installing Sentry you should edit the pre-config files which are two: config.yml and sentry.conf.py which is more advanced.

$ nano ./sentry/config-sample.yml
  • mail.* configuration to send email through SMTP
  • system.secret-key by adding a solid secret string

Also, editing sentry.conf.py:

$ nano ./sentry/sentry.conf.py
  • SENTRY_OPTIONS[“mail.from”] you can change from email address variable
  • or you can set your domain name instead of “localhost” in SENTRY_OPTIONS[“mail.list-namespace”]

By default Sentry will use port 9000 which we use on CloudFront, if you change the port number here, consider changing it on CloudFront too.

7. Add GeoLite API database

Sentry could work with GeoLite2 database, and you just need to create a file which contains user & api key that could be retrieved through MaxMind website and you can populate data by this command:

$ sudo nano geoip/GeoIP.conf

Put these data there and save it:

AccountID HereisYourAccountID
LicenseKey HereisYourLicenseKey
EditionIDs GeoLite2-City

8. Install sentry

$ cd /sentry/
$ ./install.sh

During the installation, you should enter your email and password to set up an admin account.

9. Set the alias for sentry

$ alias sentry="docker-compose run --rm web"

Then you can run other commands for sentry directly, like:

$ sentry createuser

Also, you can change the config files after installation and run docker-compose again.

$ docker-compose up -d

10. Setup a CloudFront distribution

Create a distribution with you EC2 domain address.

and these configurations on Default cache behavior:

  • Cache policy — Legacy: Headers/Query Strings/Cookies: All
  • Allowed HTTP Methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
  • Viewer protocol policy: HTTPS Only
  • Compress objects automatically: No

That’s all, then you can complete the web installation wizard with your CloudFront URL.

--

--

Davod
Davod

No responses yet