Lightweight monitoring compatible with the Sentry protocol, GlitchTip
The previous article discussed restarting Sentry. Because the process was too troublesome, I once thought about abandoning Sentry and switching to other lighter open-source monitoring systems.
目录10 个章节
Foreword
The previous article discussed restarting Sentry
Because the process was so cumbersome, I once thought about giving up Sentry and switching to another, more lightweight open-source monitoring system
And just like that, I found two others
This time, let's try out this GlitchTIP
After using it, I realized it's also developed with Django, and it's compatible with the Sentry protocol. Even the SDK uses Sentry's...
It's essentially a lightweight drop-in replacement for Sentry
Environment Preparation
Compared to Sentry, GlitchTip is extremely lightweight, using only Redis and Celery.
Log data is stored in PostgreSQL.
This makes things much easier—deployment is significantly simpler compared to heavyweight frameworks like Sentry.
The deployment described in this article is based on a modified version of the official docker-compose configuration.
PostgreSQL
First, prepare the database
The official compose file includes a database, but since I already have a database on my server, I don't want to create additional redundant containers.
services:
db:
image: postgres
container_name: pgsql
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=数据库管理员密码
expose:
- 5432
ports:
- 5432:5432
volumes:
- ./data:/var/lib/postgresql/data
networks:
- default
networks:
default:
name: pgsql
After starting pgsql, create the database and user used by GlitchTip.
-- Create user: Use the CREATE ROLE or CREATE USER command to create a new user.
CREATE USER glitchtip WITH PASSWORD 'glitchtip用户密码';
-- Grant privileges: To ensure the glitchtip user can only access the glitchtip database, set appropriate permissions.
GRANT ALL PRIVILEGES ON DATABASE glitchtip TO glitchtip;
-- Grant permission to create tables in the public schema
GRANT CREATE ON SCHEMA public TO glitchtip;
-- Grant usage permission in the public schema
GRANT USAGE ON SCHEMA public TO glitchtip;
The database setup is now complete.
Extension: Adminer
If you want to manage the database via a web interface, you can start an Adminer service.
services:
adminer:
image: adminer
container_name: adminer
restart: always
networks:
- swag
- pgsql
- mysql
networks:
swag:
name: swag
external: true
pgsql:
name: pgsql
external: true
mysql:
name: mysql
external: true
After starting the service, simply configure a reverse proxy for port 8000 in SWAG.
Redis
Redis is relatively lightweight, so it's recommended to use the one provided by GlitchTip instead of a shared Redis instance.
Unless you're building a cluster.
Installing GlitchTip
I modified the official Compose configuration provided.
A few things to note:
- The email address and password need to be escaped using
urllib.parse.quote(). I'm still using a corporate email here, but trying both thesmtp://andsmtps://prefixes didn't work for sending. - I removed the top-level volumes from the official setup and placed the data in the current directory for easier management. For large amounts of data, you might consider using OSS.
- We are using the PostgreSQL database we deployed earlier, instead of spinning up another one in the Compose file.
x-environment: &default-environment
DATABASE_URL: postgres://glitchtip:glitchtip用户密码@pgsql:5432/glitchtip
SECRET_KEY: 建议32位随机密码 # 可以使用命令生成 openssl rand -hex 32
PORT: 8000
EMAIL_URL: smtp://邮箱地址:邮箱密码@smtp.exmail.qq.com:465
GLITCHTIP_DOMAIN: https://glitchtip.example.com
DEFAULT_FROM_EMAIL: 邮箱地址
CELERY_WORKER_AUTOSCALE: "1,3"
CELERY_WORKER_MAX_TASKS_PER_CHILD: "10000"
x-depends_on: &default-depends_on
- redis
services:
redis:
image: redis
restart: unless-stopped
networks:
- default
web:
image: glitchtip/glitchtip
depends_on: *default-depends_on
ports:
- "8000:8000"
environment: *default-environment
restart: unless-stopped
volumes:
- ./uploads:/code/uploads
networks:
- default
- pgsql
- swag
worker:
image: glitchtip/glitchtip
command: ./bin/run-celery-with-beat.sh
depends_on: *default-depends_on
environment: *default-environment
restart: unless-stopped
volumes:
- ./uploads:/code/uploads
networks:
- default
- pgsql
migrate:
image: glitchtip/glitchtip
depends_on: *default-depends_on
command: "./manage.py migrate"
environment: *default-environment
networks:
- pgsql
- default
networks:
default:
name: glitchtip
swag:
name: swag
external: true
pgsql:
name: pgsql
external: true
Then simply start it up.
After the first startup, a migration is required. The worker will throw errors during this time, which is normal. Just wait for the migration to complete.
After logging in, register and create a new organization, and you can start using it normally.
Usage in Code
Using GlitchTip Only
If you're solely using GlitchTip, you can treat it just like Sentry.
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn="YOUR-GLITCHTIP-DSN-HERE",
integrations=[DjangoIntegration()],
auto_session_tracking=False,
traces_sample_rate=0.01,
release="1.0.0",
environment="production",
)
That's all there is to it.
Using with Sentry
PS:
Why would you need to use it with Sentry?
sentry_sdk does not natively support initializing multiple instances simultaneously.
Therefore, we implement this functionality with some additional logic.
class GlitchtipSentrySdk:
def __init__(self, dsn):
self.client = sentry_sdk.Hub(sentry_sdk.Client(dsn))
def capture_exception(self, exc):
with self.client:
sentry_sdk.capture_exception(exc)
glitchtip = GlitchtipSentrySdk('https://balabalaba@glitchtip.example.com/1')
That's it.
Summary
After a simple test, GlitchTip really feels much more basic.
However, it still has the most fundamental error collection capabilities.
If server performance is insufficient, it can serve as a decent budget-friendly alternative (平替) to Sentry.
There's also Highlight that I haven't deployed yet; the configuration there is a bit complex.
_EOF_
Lightweight monitoring compatible with the Sentry protocol, GlitchTip
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
持续集成指南:GitHubAction 自动构建+部署AspNetCore项目
又一个无聊的自动化教程:GitHub Actions构建AspNetCore Docker镜像推送到阿里云,再用本地runner部署。简化workflow?谁在乎这些细节?代理配置太烦人。
2023-11-15 · DevOps · 约 1 分钟
重启sentry+升级ExceptionLess版本,docker排坑记录
折腾的过程真的是究极折磨,写这篇文章仿佛又被折磨了一遍……
2024-07-19 · DevOps · 约 1 分钟
Sentry的安装、配置、使用
前言 上一篇文章介绍了ExceptionLess这个日志收集系统:ExceptionLess的安装、配置、使用 由于ExceptionLess官方提供的客户端只有.Net/.NetCore平台和js的,本文继续介绍另一个日志收集系统:Sentry Sentry 是一个实时事件日志记录和聚合平台。(官方说的是错误监控 Error Monitor)它专门用于监视错误和提取执行适当的事后操作所需的所有信
2022-07-23 · DevOps · 约 1 分钟
lighthouse-fw:一个管理腾讯云轻量服务器防火墙的终端工具
公网IP一换手动改防火墙?这效率也配叫程序员? 一个增量diff引擎+系统钥匙串+TUI/CLI双模,443行重构包完事。 uvx直接跑,别告诉我还要pip install。
2026-05-02 · DevOps · 约 1 分钟
讨论
共 0 条加载评论中…