sentry功能
Sentry是一个实时事件的日志聚合平台。它专门监测错误并提取所有有用信息用于分析,不再麻烦地依赖用户反馈来定位问题。
What’s Sentry?
Sentry fundamentally is a service that helps you monitor and fix crashes in realtime. The server is in Python, but it contains a full API for sending events from any language, in any application。
环境信息
centos7.x
docker-ce Version: 18.09.0
docker-compose version 1.25.4
https://sentry.io
https://github.com/getsentry/sentry
https://github.com/docker-library/docs/tree/master/sentry
sentry9.1.2(优化版)
https://github.com/getsentry/onpremise/releases/tag/9.1.2
https://gitee.com/m0p/onpremise/repository/archive/9.1.2.1?format=tar.gz ###优化原版安装报错,设置postgres密码
sentry架构
部署sentry9.1.2
https://gitee.com/m0p/onpremise/repository/archive/9.1.2.1?format=tar.gz
安装
chmod +x install.sh
./install.sh ###脚本一键检测基础环境及初始化sentry,过程中需要填写认证的账户信息(登录主页的superuser)
设置认证账户
启动服务
docker-compose up -d //启动服务
登录
http://ip:9000/
设置语言
创建项目
注意:提示对应相关配置(保留起来,后续会用到的)
引入sentry sdk测试异常告警
设置sentry邮箱发送告警
注意:这里使用的qq邮箱服务,需要开启pop3/smtp
新增配置config.yml
config.yml
mail.backend: 'smtp' # Use dummy if you want to disable email entirely
mail.host: 'smtp.qq.com'
mail.port: 25
mail.username: 'mvpbang@qq.com'
mail.password: '客户端授权码'
mail.use-tls: false
mail.from: 'mvpbang@qq.com' ## The email address to send on behalf of
停止sentry服务及重新打包升级配置
[root@c_3 ~]# docker-compose stop ###t停止
[root@c_3 ~]# docker-compose build ###重新build
[root@c_3 ~]# docker-compose run --rm web upgrade ###升级配置
[root@c_3 ~]# docker-compose up -d
查看邮箱配置
测试邮件是否可以收到
邮件设置(方法)
环境变量可以写入.env
SENTRY_SERVER_EMAIL 邮件的发送地址
SENTRY_EMAIL_HOST smtp 服务器主机地址
SENTRY_EMAIL_USER smtp 服务器用户
SENTRY_EMAIL_PASSWORD smtp 服务器密码
SENTRY_EMAIL_PORT smtp 服务器端口
SENTRY_EMAIL_USE_TLS 是否使用 TLS,默认为 false
docker-compose.yml 注释掉 SENTRY_EMAIL_HOST配置,防止覆盖.env的变量
#update sentry
docker-compose build --pull # Build the services again after updating, and make sure we're up to date on patch version
docker-compose run --rm web upgrade # Run new migrations
docker-compose up -d # Recreate the services
uninstall all
注意:慎用,请明白操作的含义
docker-compose stop
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
docker rmi -f $(docker images -qa)
reference:
https://blog.csdn.net/shenhonglei1234/article/details/100998627
https://www.cnblogs.com/watchslowly/p/11309052.html
https://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=371