docker下Sentry安装及使用 - Go语言中文社区

docker下Sentry安装及使用


安装

>>> git clone https://github.com/getsentry/onpremise
>>> cd onpremise

安装前先检查一下9000端口是否被占用:

>>> netstat -nltp|grep 9000
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      22202/docker-proxy

看到了吧,已经被占用了

如果9000端口被占用,我强烈建议是把9000端口收回或者换一台没有被占用的服务器进行部署,而不是尝试修改默认端口,因为我折腾好长时间,发现此路不通,而且官方似乎也不建议修改默认的9000端口

开始安装:

>>> ./install.sh
Would you like to create a user account now? [Y/n]: Y
Email: xxxxxxx@qq.com
Password:
Repeat for confirmation:
User created: xxxxxxx@qq.com
Added to organization: sentry
Creating missing DSNs
Correcting Group.num_comments counter

▶ Migrating file storage ...
[proxychains] DLL init: proxychains-ng 4.14-git-39-g918855d
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
596ba82af5aa: Pulling fs layer
596ba82af5aa: Download complete
596ba82af5aa: Pull complete
Digest: sha256:d9a7354e3845ea8466bb00b22224d9116b183e594527fb5b6c3d30bc01a20378
Status: Downloaded newer image for alpine:latest

▶ Generating Relay credentials ...
[proxychains] DLL init: proxychains-ng 4.14-git-39-g918855d
[proxychains] DLL init: proxychains-ng 4.14-git-39-g918855d
[proxychains] DLL init: proxychains-ng 4.14-git-39-g918855d
[proxychains] DLL init: proxychains-ng 4.14-git-39-g918855d
Relay credentials written to relay/credentials.json

▶ Setting up GeoIP integration ...
Setting up IP address geolocation ...
Installing (empty) IP address geolocation database ... [proxychains] DLL init: proxychains-ng 4.14-git-39-g918855d
done.
IP address geolocation is not configured for updates.
See https://develop.sentry.dev/self-hosted/geolocation/ for instructions.
Error setting up IP address geolocation.


-----------------------------------------------------------------

You're all done! Run the following command to get Sentry running:

  docker-compose up -d

-----------------------------------------------------------------

如果卡在

...
▶ Fetching and updating Docker images ...

则是因为国内网络问题,自己想办法把(逃
如果卡在

>>> apt-get update && apt-get install -y --no-install-recommends cron && 

则可以通过修改为国内镜像源加速

>>> vim cron/Dockerfile
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf 
    && sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list 
    && apt-get clean && apt-get update && apt-get install -y --no-install-recommends cron && 
    rm -r /var/lib/apt/lists/*
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

接下来启动:

>>> docker-compose up -d
Starting sentry_onpremise_smtp_1                 ... done
Starting sentry_onpremise_zookeeper_1            ... done
Starting sentry_onpremise_memcached_1            ... done
Starting sentry_onpremise_symbolicator_1         ... done
Starting sentry_onpremise_postgres_1             ... done
Starting sentry_onpremise_redis_1                ... done
Creating sentry_onpremise_geoipupdate_1                              ... done
Starting sentry_onpremise_clickhouse_1           ... done
Creating sentry_onpremise_symbolicator-cleanup_1                     ... done
Starting sentry_onpremise_kafka_1                ... done
Starting sentry_onpremise_snuba-subscription-consumer-transactions_1 ... done
Starting sentry_onpremise_snuba-sessions-consumer_1                  ... done
Starting sentry_onpremise_snuba-api_1                                ... done
Starting sentry_onpremise_snuba-transactions-consumer_1              ... done
Starting sentry_onpremise_snuba-outcomes-consumer_1                  ... done
Starting sentry_onpremise_snuba-subscription-consumer-events_1       ... done
Starting sentry_onpremise_snuba-consumer_1                           ... done
Starting sentry_onpremise_snuba-replacer_1                           ... done
Creating sentry_onpremise_relay_1                                    ... done
Creating sentry_onpremise_snuba-cleanup_1                            ... done
Creating sentry_onpremise_sentry-cleanup_1                           ... done
Creating sentry_onpremise_ingest-consumer_1                          ... done
Creating sentry_onpremise_subscription-consumer-transactions_1       ... done
Creating sentry_onpremise_post-process-forwarder_1                   ... done
Creating sentry_onpremise_web_1                                      ... done
Creating sentry_onpremise_subscription-consumer-events_1             ... done
Creating sentry_onpremise_worker_1                                   ... done
Creating sentry_onpremise_cron_1                                     ... done
Creating sentry_onpremise_nginx_1                                    ... done

一切正常
打开网页看看
xx.xx.xx.xx:9001
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

测试

Flask

import sentry_sdk
from flask import Flask
from sentry_sdk.integrations.flask import FlaskIntegration

sentry_sdk.init(
    dsn="http://b0e6dfb01da64419ba2f68b42b2bc844@10.11.206.141:9000/2",
    integrations=[FlaskIntegration()],
    traces_sample_rate=1.0
)

app = Flask(__name__)

@app.route('/debug-sentry')
def trigger_error():
    division_by_zero = 1 / 0

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000
>>> python3 sentry_test.py

在这里插入图片描述
在这里插入图片描述

connexion

import connexion
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration

from swagger_server import encoder
import sys
import os

sys.path.insert(1, os.getcwd()+'/swagger_server')
import config

def main():
    app = connexion.App(
        __name__, specification_dir='./swagger/', options={"swagger_ui": False}, debug= False
        )
    app.app.json_encoder = encoder.JSONEncoder
    app.add_api('swagger.yaml', arguments={'title': 'wxapp_api'}, pythonic_params=True)
    # 设置logger
    app.app.logger = config.get_logger('wxapp_api')
    ip = config.bindIp
    port = config.bindPort
    sentry_sdk.init(
        integrations=[FlaskIntegration()], 
        dsn="http://b0e6dfb01da64419ba2f68b42b2bc844@10.11.206.141:9000/2",
        traces_sample_rate=1.0
        )
    app.run(host=ip, port=port)

if __name__ == '__main__':
    main()
版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/MacwinWin/article/details/115111304
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢