citruspi

Self-Hosting Sentry

Installing Sentry Exception Tracking

Platform

I'm currently running Sentry on a 32 bit Micro EC2 instance with Amazon Linux.

Database

Sentry requires a database and can use any of the following

However, according to the Documentation, SQLite is not fully supported, so you should probably switch to Postgres or MySQL (Amazon RDS, anyone?) at some point.

I opted to stick with SQLite for now because I just wanted to get it running. I'll most likely setup AWS RDS in the near future.

Installation

I'm going to assume that, by now, you have:

$ ssh -i ~/.ssh/public.pem ec2-user@ElasticIP
$ sudo yum install gcc python-devel
$ sudo easy_install -U sentry

Setup

After the installation has finished, run

$ sentry init

A config file named sentry.conf.py will be created in ~/ec2-user/.sentry/:

Configuration file created at '/home/ec2-user/.sentry/sentry.conf.py'

You don't have to modify any of the settings right now, but we will later.

Now, run

$ sentry upgrade

If it prints out

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no):

Enter yes and fill out the fields it provides. The user you create right now will be the superuser for your Sentry installation.

When it finishes setting up Sentry, you'll be ready to go to the next section.

Is It Up?

In your console, run

$ sentry start

It should start up three workers:

2013-03-14 02:38:26 [1440] [INFO] Starting unicorn 0.17.2
2013-03-14 02:38:26 [1440] [INFO] Listening at: http://0.0.0.0:9000 (1440)
2013-03-14 02:38:26 [1440] [INFO] Using worker: sync
2013-03-14 02:38:26 [1449] [INFO] Booting worker with pid: 1449
2013-03-14 02:38:26 [1450] [INFO] Booting worker with pid: 1450
2013-03-14 02:38:26 [1451] [INFO] Booting worker with pid: 1451

In your browser, open ElasticIP:9000. You should be greeted with a login prompt:

It works!

Now, you can login, setup teams and projects, and get to work.

Extra Credit

Disable Sign Ups

Right now, any one who stumbles upon your install can create an account. This isn't really a big problem because they'll be greeted with

You are not a member of any teams in Sentry and you do not have access to create a new team.

However, it's still a nuisance.

To disable user registrations, just add

SENTRY_ALLOW_REGISTRATION = False

to the sentry.conf.py file.

You'll need to run

$ sentry upgrade

again (no prompt this time) and kill and restart the Sentry process for the changes to take effect.

If you read the docs, there's a ton of other config options.

Reverse Proxy

I don't want to have to type in http://174.129.196.120:9000/ every time, so I set up a reverse proxy with Nginx on my Linode VPS.

 1 server {
 2     server_name sentry.domain.com;
 3     access_log /you_pick/logs/access.log;
 4     error_log /you_pick/logs/error.log;
 5 
 6     keepalive_timeout 5;
 7 
 8     location / {
 9         proxy_pass         http://ElasticIP:9000;
10         proxy_redirect     off;
11 
12         proxy_set_header   Host              $host;
13         proxy_set_header   X-Real-IP         $remote_addr;
14         proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
15         proxy_set_header   X-Forwarded-Proto $scheme;
16     }
17 }

It's A Service

You should probably manage Sentry processes some way. I decided to go with Supervisor.

If you do too, install Supervisor:

$ sudo easy_install supervisor

Create and edit the .conf file:

$ sudo vim /etc/supervisord.conf

and add

[program:sentry-web]
command=/usr/bin/sentry start http
autostart=true
autorestart=true
redirect_stderr=true

to it. Then, run it with

$ supervisord -c /etc/supervisord.conf

Plugins

You can extend Sentry with plugins. There are plugins for

A full list of plugins and download links can be found here.


Published on 13 March 2013.