异常分析平台sentry部署

官方地址:https://docs.sentry.io
安装环境:centos7.6
sentry版本:9.1.2

1、安装基础环境

$ yum install -y python-setuptools python-devel libxslt1-devel gcc libffi-devel libjpeg-devel libxml2-devel libxslt-devel libyaml-devel libpq-devel gcc-c++

2、安装sentry

$ pip install sentry==9.1.2

问题1:
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-SL8ohy/pycparser/ You are using pip version 8.1.2, however version 19.1.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
解决办法:$ pip install --upgrade pip
还是报错:
ERROR: Complete output from command python setup.py egg_info: ERROR: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-5OHP7Q/pycparser/setup.py", line 65, in <module> cmdclass={'install': install, 'sdist': sdist}, File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup _setup_distribution = dist = klass(attrs) File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__ _Distribution.__init__(self,attrs) File "/usr/lib64/python2.7/distutils/dist.py", line 287, in __init__ self.finalize_options() File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 302, in finalize_options ep.load()(self, ep.name, value) File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2341, in load return self.resolve() File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2351, in resolve raise ImportError(str(exc)) ImportError: 'module' object has no attribute 'check_specifier' ---------------------------------------- ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-5OHP7Q/pycparser/
解决办法:$ pip install --upgrade setuptools==30.1.0
问题2:
redis-py-cluster 1.3.5 has requirement redis>=2.10.6, but you'll have redis 2.10.5 which is incompatible.
解决办法:sentry 9.1.2依赖redis 2.10.5,redis-py-cluster 1.3.5依赖redis>=2.10.6,降级redis-py-cluster

$ pip install redis-py-cluster==1.3.4

3、初始化及配置

sentry init /etc/sentry
在/etc/sentry目录下会生成config.yml、sentry.conf.py两个文件
$ cat /etc/sentry/config.yml | egrep -v ‘#|$’

mail.backend: 'smtp'  # Use dummy if you want to disable email entirely
mail.host: 'smtp.exmail.qq.com'
mail.port: 587  #坑爹的腾讯企业邮箱25、465端口都不可用
mail.username: 'xxx@xxx.com'
mail.password: 'xxxxxx'
mail.use-tls: true
mail.from: 'xxx@xxx.com'
system.secret-key: 'c&d!amh81^%7f*h6yzz4x5_gn#@rqyoi9%)_5%85u2rn=v0(hn'
redis.clusters:
  default:
    hosts:
      0:
        host: xxxxxx
        port: 6379
        password: xxxxxx
        db: 0
filestore.backend: 'filesystem'
filestore.options:
  location: '/tmp/sentry-files'

$ cat /etc/sentry/sentry.conf.py | egrep -v ‘#|$’

from sentry.conf.server import *
import os.path
CONF_ROOT = os.path.dirname(__file__)
DATABASES = {
    'default': {
        'ENGINE': 'sentry.db.postgres',
        'NAME': 'sentry',
        'USER': 'xxxx',
        'PASSWORD': 'xxxx',
        'HOST': 'xxxxx',
        'PORT': '3433',
        'AUTOCOMMIT': True,
        'ATOMIC_REQUESTS': False,
    }
}
SENTRY_USE_BIG_INTS = True
SENTRY_SINGLE_ORGANIZATION = True
DEBUG = False
SENTRY_CACHE = 'sentry.cache.redis.RedisCache'
BROKER_URL = 'redis://:xxxx@xxxx:6379/0'
SENTRY_RATELIMITER = 'sentry.ratelimits.redis.RedisRateLimiter'
SENTRY_BUFFER = 'sentry.buffer.redis.RedisBuffer'
SENTRY_QUOTAS = 'sentry.quotas.redis.RedisQuota'
SENTRY_TSDB = 'sentry.tsdb.redis.RedisTSDB'
SENTRY_DIGESTS = 'sentry.digests.backends.redis.RedisBackend'
SENTRY_WEB_HOST = '0.0.0.0'
SENTRY_WEB_PORT = 9000
SENTRY_WEB_OPTIONS = {
     'workers': 4,  # the number of web workers
    # 'protocol': 'uwsgi',  # Enable uwsgi protocol instead of http
}
创建sentry数据库

$ createdb -E utf-8 sentry

初始化数据结构

$ sentry upgrade

创建数据库管理员用户

$ sentry createuser

用supervisor管理sentry进程

$ yum install supervisor

$ cat sentry.conf

[program:sentry-web]
directory=/home/apple/
environment=SENTRY_CONF="/etc/sentry"
command=/bin/sentry run web
user=root
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/sentry-web.log

[program:sentry-worker]
directory=/home/apple/
environment=SENTRY_CONF="/etc/sentry"
command=/bin/sentry run worker -c 8
user=apple
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/sentry-worker.log

[program:sentry-cron]
directory=/home/apple/
environment=SENTRY_CONF="/etc/sentry"
command=/bin/sentry run cron
user=apple
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/sentry-cron.log

$ systemctl enable supervisord
$ systemctl start supervisord
$ supervisorctl update
$ supervisorctl status

4、安装钉钉插件和ldap配置

安装钉钉插件

$ pip install sentry-dingding
$ sentry plugins list

sentry_dingding: sentry-dingding 0.0.3 (/usr/lib/python2.7/site-packages)
安装ldap插件

ldap集成依赖于第三方提供的插件,具体配置方法参考链接:https://github.com/Banno/getsentry-ldap-auth

$ yum install openldap-devel
$ pip install sentry-ldap-auth

在/etc/sentry/sentry.conf.py 增加配置

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfUniqueNamesType

AUTH_LDAP_SERVER_URI = 'ldap://xxxxx:389'
AUTH_LDAP_BIND_DN = 'cn=Manager,dc=xxxx,dc=com'
AUTH_LDAP_BIND_PASSWORD = 'xxxx'

AUTH_LDAP_USER_SEARCH = LDAPSearch(
    'dc=xxxx,dc=com',
    ldap.SCOPE_SUBTREE,
    '(cn=%(user)s)',
)

AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
    '',
    ldap.SCOPE_SUBTREE,
    '(objectClass=groupOfUniqueNames)'
)

AUTH_LDAP_GROUP_TYPE = GroupOfUniqueNamesType()
AUTH_LDAP_REQUIRE_GROUP = None
AUTH_LDAP_DENY_GROUP = None

AUTH_LDAP_USER_ATTR_MAP = {
    'username': 'cn',
    'first_name': 'cn',
    'email': 'mail'
}

AUTH_LDAP_FIND_GROUP_PERMS = False
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600

AUTH_LDAP_DEFAULT_SENTRY_ORGANIZATION = 'sentry'
AUTH_LDAP_SENTRY_ORGANIZATION_ROLE_TYPE = 'member'
#AUTH_LDAP_SENTRY_GROUP_ROLE_MAPPING = {
#    'owner': ['sysadmins'],
#    'admin': ['devleads'],
#    'member': ['developers', 'seniordevelopers']
#}
AUTH_LDAP_SENTRY_ORGANIZATION_GLOBAL_ACCESS = True
AUTH_LDAP_SENTRY_USERNAME_FIELD = 'uid'

AUTHENTICATION_BACKENDS = AUTHENTICATION_BACKENDS + (
    'sentry_ldap_auth.backend.SentryLdapBackend',
)

import logging
logger = logging.getLogger('django_auth_ldap')
logger.addHandler(logging.StreamHandler())
logger.setLevel('DEBUG')

参考文档

Installing sentry 9.0.0 with postgresql in Centos7
故障分析平台 Sentry 的 LDAP 集成搭建
CentOS搭建异常监控服务平台:Sentry

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值