【Sentry运维】Docker下Sentry安装及使用

32 篇文章 1 订阅
9 篇文章 1 订阅

安装

>>> 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()
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值