Quản lý và theo dõi lỗi thời gian thực với Sentry

sentry Mar 28, 2019

Sentry là gì?

Sentry là phần mềm mã nguồn mở giúp lập trình viên phát hiện, theo dõi, hỗ trợ sửa lỗi thời gian thực, nâng cao trải nghiệm của người dùng đối.

Ưu điểm:

  • Gửi thông báo qua email, sms, các phần mềm chat ngay khi lỗi xuất hiện.
  • Hỗ trợ phát hiện và xử lý lỗi một cách nhanh chóng
  • Thống kê phân tích lỗi toàn bộ hệ thống
  • Dashboard trực quan, dễ sử dụng
  • Cho phép quản lý theo từng project và phân quyền theo user

Hướng dẫn cài đặt cơ bản:

Cài đặt gói cơ bản:

yum install epel-release
yum install wget python-setuptools.noarch python2-pip.noarch python-devel.x86_64 libxslt.x86_64 libxslt-devel.x86_64 libxml2 libxml2-devel.x86_64 libzip libzip-devel libffi.x86_64 libffi-devel.x86_64 openssl-libs.x86_64 libpqxx libpqxx-devel libyaml libyaml-devel libjpeg libjpeg-devel libpng libpng12 libpng12-devel libpng-devel net-tools gcc gcc-c++ -y

Cài đặt redis + postgres:

yum install redis -y
systemctl enable redis.service #set redis chạy khi khởi động
systemctl start redis.service

yum install postgresql-server.x86_64 postgresql-contrib
postgresql-setup initdb
systemctl enable postgresql.service
systemctl start postgresql.service
su - postgres
psql
create user sentry with password 'type_your_password';
alter user sentry with superuser;
create database sentrydb with owner sentry;
\q
exit

Cài đặt sentry:

pip --upgrade pip
pip install sentry
sentry init /etc/sentry
vim /etc/sentry/sentry.conf.py

DATABASES = {
'default': {
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentrydb',
'USER': 'sentry',
'PASSWORD': 'your_password',
'HOST': '127.0.0.1',
'PORT': '5432',
'AUTOCOMMIT': True,
'ATOMIC_REQUESTS': False,
}
}

sentry --config /etc/sentry upgrade

Cấu hình supervisord:

pip install supervisor

[program:sentry-web]
directory=/home/sentry/sentry_app/
environment=SENTRY_CONF="/etc/sentry"
command=/usr/bin/sentry --config=/etc/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="/etc/sentry"
command=/usr/bin/sentry --config=/etc/sentry run worker
autostart=true
autorestart=true
redirect_stderr=true
user=sentry
stdout_logfile=syslog
stderr_logfile=syslog
startsecs=1
startretries=3
stopsignal=TERM
stopwaitsecs=10
stopasgroup=false
killasgroup=true

[program:sentry-cron]
directory=/home/sentry/sentry_app/
environment=SENTRY_CONF="/etc/sentry"
command=/usr/bin/sentry --config=/etc/sentry run cron
autostart=true
autorestart=true
redirect_stderr=true
user=sentry
stdout_logfile=syslog
stderr_logfile=syslog

Tags