Sentry is an error tracking software product which has many different subscriptions options. Its software is open source and can be difficult to install if you are unfamiliar with the server side of things and hosting. They do offer a free hosted option for up to 10k events per month, 1 user and up to seven days retention.
In this example, I'm using an updated Ubuntu 16.04.2 LTS install. To get started, we will install several packages. Note, this will install Redis and PostgreSQL. Typically, you would want to install these on their own servers.
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y python-virtualenv python-setuptools python-pip libxslt1-dev gcc
sudo apt-get install -y libffi-dev libjpeg-dev libxml2-dev libxslt-dev libyaml-dev python-dev
sudo apt-get install -y python-setuptools python-dev libxslt1-dev gcc libffi-dev libjpeg-dev
sudo apt-get install -y libxml2-dev libxslt-dev libyaml-dev libpq-dev nginx
sudo apt-get install -y postgresql-server-dev-9.5 supervisor nodejs
sudo apt-get install -y postgresql redis-server
We'll then create a sentry user that will be running the software. We will also allow this use to be a sudoer.
sudo adduser sentry
sudo adduser sentry sudo
Next, we need to create our database. To do this, we will login as the postgres user and open the template1 database. We'll create a sentry database user and password. Be sure to change this password. We then need to create the citext
extension.
sudo su - postgres
psql template1
create extension citext;
create user sentry with password 'sentry';
create database sentrydb with owner sentry;
\q
exit
We will then login as the sentry user and create a virtual environment for sentry.
sudo su - sentry
virtualenv ~/sentry_app/
source ~/sentry_app/bin/activate
Let's install sentry
pip install -U sentry
sentry init
Let's configure the sentry.conf.py
with vi
, nano
or whatever your preferred editor is.
nano ~/.sentry/sentry.conf.py
DATABASES = {
'default': {
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentrydb',
'USER': 'sentry',
'PASSWORD': 'sentry', # <-- or whatever you set with the psql command
'HOST': 'localhost',
'PORT': '5432',
}
}
We're now ready to upgrade! This will migrate the database; building the tables and initial data. You will also be asked to create a user which will be your login information.
sentry upgrade
Let's log out of the sentry
user and make sentry
startup whenever the server boots.
exit
sudo nano /etc/supervisor/conf.d/sentry.conf
We'll then paste this into sentry.conf
[program:sentry-web]
directory=/home/sentry/sentry_app/
environment=SENTRY_CONF="/home/sentry/.sentry"
command=/home/sentry/sentry_app/bin/sentry run web
autostart=true
autorestart=true
redirect_stderr=true
user=sentry stdout_logfile=syslog
stderr_logfile=syslog
[program:sentry-worker]
directory=/home/sentry/sentry_app/
environment=SENTRY_CONF="/home/sentry/.sentry"
command=/home/sentry/sentry_app/bin/sentry run worker
autostart=true
autorestart=true
redirect_stderr=true
user=sentry
stdout_logfile=syslog
stderr_logfile=syslog
[program:sentry-cron]
directory=/home/sentry/sentry_app/
environment=SENTRY_CONF="/home/sentry/.sentry"
command=/home/sentry/sentry_app/bin/sentry run cron
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=syslog
stderr_logfile=syslog
We'll then update supervisor
and check its status.
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl status
The app will then be available at http://localhost:9000
. If you want to set up SSL or run sentry
on port 80, we can create an NGINX proxy.
sudo nano /etc/nginx/sites-enabled/default
Then replace the location /
with the following.
location /
{
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
If you need to configure your email settings, you can edit /home/sentry/.sentry/config.yml
.
You can also setup crontab
to cleanup the sentry data periodically.
crontab -e
0 3 * * * sentry cleanup --days=30
Your site will be live at http://x.x.x.x/auth/login
. Start a project and and tracking errors now!