Sentry: running self-hosted errors tracking system on an AWS EC2

Running Sentry

root@bttrm-sentry:/home/admin# mkdir /opt/sentry
root@bttrm-sentry:/home/admin# cd /opt/sentry/
root@bttrm-sentry:/opt/sentry# git clone https://github.com/getsentry/onpremise.git
root@bttrm-sentry:/opt/sentry# cd onpremise/
root@bttrm-sentry:/opt/sentry/onpremise# docker volume create — name=sentry-data && docker volume create — name=sentry-postgres
sentry-data
sentry-postgres
root@bttrm-sentry:/opt/sentry/onpremise# cp -n .env.example .env
root@bttrm-sentry:/opt/sentry/onpremise# docker-compose build
smtp uses an image, skipping
memcached uses an image, skipping
redis uses an image, skipping
postgres uses an image, skipping
Building web
Step 1/1 : FROM sentry:9.1-onbuild
9.1-onbuild: Pulling from library/sentry

Successfully built 4840fec904c8
Successfully tagged onpremise_worker:latest
root@bttrm-sentry:/opt/sentry/onpremise# docker-compose run — rm web config generate-secret-key
Creating network “onpremise_default” with the default driver
Pulling smtp (tianon/exim4:)…
latest: Pulling from tianon/exim4

Status: Downloaded newer image for tianon/exim4:latest
Pulling memcached (memcached:1.5-alpine)…
1.5-alpine: Pulling from library/memcached

Status: Downloaded newer image for memcached:1.5-alpine
Pulling redis (redis:3.2-alpine)…
3.2-alpine: Pulling from library/redis

Status: Downloaded newer image for redis:3.2-alpine
Pulling postgres (postgres:9.5)…
9.5: Pulling from library/postgres

Creating onpremise_smtp_1 … done
Creating onpremise_postgres_1 … done
Creating onpremise_memcached_1 … done
Creating onpremise_redis_1 … done
y0%***1yz
root@bttrm-sentry:/opt/sentry/onpremise# docker-compose run — rm web upgrade
Starting onpremise_redis_1 … done
Starting onpremise_postgres_1 … done
Starting onpremise_memcached_1 … done
Starting onpremise_smtp_1 … done
12:06:24 [WARNING] sentry.utils.geo: settings.GEOIP_PATH_MMDB not configured.
12:06:27 [INFO] sentry.plugins.github: apps-not-configured
Syncing…
Creating tables …
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table south_migrationhistory
Installing custom SQL …
Installing indexes …
Installed 0 object(s) from 0 fixture(s)
Migrating…
Running migrations for sentry:
- Migrating forwards to 0472_auto__add_field_sentryapp_author.

Created internal Sentry project (slug=internal, id=1)
Would you like to create a user account now? [Y/n]: y
Email: admin@example.com
Password:
Repeat for confirmation:
Should this user be a superuser? [y/N]: Y
User created: admin@example.com
Added to organization: sentry
root@bttrm-sentry:/opt/sentry/onpremise# docker-compose up
onpremise_redis_1 is up-to-date
onpremise_memcached_1 is up-to-date
onpremise_postgres_1 is up-to-date
onpremise_smtp_1 is up-to-date
Creating onpremise_worker_1 … done
Creating onpremise_web_1 … done
Creating onpremise_cron_1 … done
root@bttrm-sentry:/opt/sentry/onpremise# docker ps
root@bttrm-sentry:/opt/sentry/onpremise# systemctl edit — force sentry
[Unit]
Description=Sentry service
Requires=docker.service
After=docker.service

[Service]
Restart=always
WorkingDirectory=/opt/sentry/onpremise

# Compose up
ExecStart=/usr/local/bin/docker-compose -f docker-compose.yml up

# Compose down, remove containers and volumes
ExecStop=/usr/local/bin/docker-compose -f docker-compose.yml down -v

[Install]
WantedBy=multi-user.target
[Unit]
Description=Sentry service
Requires=docker.service
After=docker.service

[Service]
Restart=always
WorkingDirectory=/opt/sentry/onpremise

# Compose up
ExecStart=
ExecStart=/usr/local/bin/docker-compose -f docker-compose.yml up

# Compose down, remove containers and volumes
ExecStop=/usr/local/bin/docker-compose -f docker-compose.yml down -v

[Install]
WantedBy=multi-user.target
root@bttrm-sentry:/opt/sentry/onpremise# systemctl start sentry
root@bttrm-sentry:/opt/sentry/onpremise# systemctl status sentry
● sentry.service — Sentry service
Loaded: loaded (/etc/systemd/system/sentry.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/sentry.service.d
└─override.conf
Active: active (running) since Sat 2019–05–18 12:39:21 UTC; 12min ago
Main PID: 9209 (docker-compose)
root@bttrm-sentry:/opt/sentry/onpremise# systemctl enable sentry

Email

...
SENTRY_EMAIL_HOST: email-smtp.us-east-1.amazonaws.com
SENTRY_EMAIL_PORT: 587
SENTRY_EMAIL_PASSWORD: BH3***gpM
SENTRY_EMAIL_USER: AKI***OAQ
SENTRY_EMAIL_USE_TLS: "true"
SENTRY_SERVER_EMAIL: no-reply@example.com
...
root@bttrm-sentry:/opt/sentry/onpremise# systemctl restart sentry

Python Sentry

[setevoy@setevoy-arch-work ~ ] $ sudo pip install sentry-sdk
[setevoy@setevoy-arch-work ~ ] $ python

>>> import sentry_sdk
>>> sentry_sdk.init(“https://96e***c44@sentry.example.com/2")
<sentry_sdk.hub._InitGuard object at 0x7efd4c487128>
>>> sentry_sdk.capture_message(“Hello World”)
‘736347c534cb4e3eb27fb3e3c0641439’

--

--

--

Cloud Infrastructure and DevOps engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Pre-screening developer candidates

Metrics vs Events: A Conversation About Controlling Volume — Honeycomb

Two people sitting at a table with drinks in their hands.

Introduction to Swift Collections

Best Application Development Software For Small Business

Anti-Agile

Static Libraries in C

Network Topology Setup in such a way that System A can ping System B and System C but both these…

Guide to connect to google colab with ssh from terminal and run jupyter lab

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arseny Zinchenko (setevoy)

Arseny Zinchenko (setevoy)

Cloud Infrastructure and DevOps engineer

More from Medium

[AWS API Gateway, EKS] Access an Amazon EKS Cluster with an API Gateway!!

How to integrate Hubot with Jenkins and Slack? (ChatOps)

How to host multiple domains on Amazon ec2 with Nginx reverse proxy

AWS — Part 2