业务日志监控工具Sentry

2023年 5月 4日 50.5k 0

Sentry 是一个日志平台,分为客户端和服务端,客户端(目前客户端有Python, PHP,C#, Ruby等多种语言)就嵌入在你的应用程序中间,程序出现异常就向服务端发送消息,服务端将消息记录到数据库中并提供一个web节目方便查看。Sentry由python编写,源码开放,性能卓越,易于扩展,目前著名的用户有Disqus, Path, mozilla, Pinterest等

文章目录

  • Sentry 介绍
  • 部署配置要求
  • 环境设置
  • 部署组件
  • Docker 及Docker-compose安装
  • 安装配置Sentry
  • 访问
  • 配置Nginx 开启SSL
  • 官方项目文档:https://github.com/getsentry/self-hosted

    Sentry 介绍

    Sentry 是一个日志平台,分为客户端和服务端,客户端(目前客户端有Python, PHP,C#, Ruby等多种语言)就嵌入在你的应用程序中间,程序出现异常就向服务端发送消息,服务端将消息记录到数据库中并提供一个web节目方便查看。Sentry由python编写,源码开放,性能卓越,易于扩展,目前著名的用户有Disqus, Path, mozilla, Pinterest等

    部署配置要求

  • Docker 19.03.6+
  • Compose 1.28.0+
  • 4 CPU Cores
  • 8 GB RAM
  • 20 GB Free Disk Space
  • 1640679316791.png

    环境设置

    环境特定的配置可以在.env.custom文件中完成。它将位于 Sentry 安装的根目录中。
    默认情况下,不存在.env.custom文件。在这种情况下,您可以通过将文件复制.env到新.env.custom文件并调整文件中的设置来手动添加此.env.custom文件。
    .env当您执行 Sentry 升级时,请记住检查文件是否有更改,以便您可以.env.custom根据需要进行相应的调整。

    部署组件

  • sentry
  • nginx
  • kafka
  • zookeeper
  • redis
  • memcache
  • clickhouse
  • Docker 及Docker-compose安装

    Docker版本要求19.03.6+,Compose版本要求1.28.0+

    #使用脚本安装docker
    
    export VERSION=19.03
    curl -fsSL "https://get.docker.com/" | bash -s -- --mirror Aliyun
    
    #安装Docker-compose
    curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    
    #abcdocker提供国内下载地址(网络不好可以使用我提供地址)
    curl https://d.frps.cn/file/tools/sentry/docker-compose -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    

    查看版本号

    [root@abcdocker ~]# docker-compose -version
    docker-compose version 1.29.2, build 5becea4c
    
    [root@abcdocker ~]# docker version
    Client: Docker Engine - Community
     Version:           19.03.15
     API version:       1.40
     Go version:        go1.13.15
     Git commit:        99e3ed8919
     Built:             Sat Jan 30 03:17:57 2021
     OS/Arch:           linux/amd64
     Experimental:      false
    
    Server: Docker Engine - Community
     Engine:
      Version:          19.03.15
      API version:      1.40 (minimum version 1.12)
      Go version:       go1.13.15
      Git commit:       99e3ed8919
      Built:            Sat Jan 30 03:16:33 2021
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.4.12
      GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
     runc:
      Version:          1.0.2
      GitCommit:        v1.0.2-0-g52b36a2
     docker-init:
      Version:          0.18.0
      GitCommit:        fec3683

    安装配置Sentry

    接下来我们下载官方Sentry一键脚本

    wget https://d.frps.cn/file/tools/sentry/self-hosted-master.zip
    unzip self-hosted-master.zip
    cd self-hosted-master/
    ./install.sh

    接下来进入等待环节1640678823765.png
    创建用户

    执行Y我们创建一个管理员用户

    1640680877036.png
    1640681001437.png
    安装完成我们执行docker-compose up -d运行服务1640681084063.png

    访问

    接下来我们就可以通过IP:9000端口访问1640683425469.png

    用户名: im@i4t.com
    密码:123456789
    #我这里设置为如上

    下面这里是配置域名smtp等信息,建议域名直接配置好,不建议这里写IP地址1640683479392.png
    首页效果图1640683568937.png

    配置Nginx 开启SSL

    接下来我们配置Nginx,并开启SSL证书

    yum install pcre pcre-devel openssl openssl-devel gcc gcc-c++ automake autoconf libtool make wget vim lrzsz -y
    cd /opt/
    wget http://nginx.org/download/nginx-1.14.1.tar.gz
    tar xf nginx-1.14.1.tar.gz
    cd /opt/nginx-1.14.1
    ./configure --prefix=/opt/nginx/ --with-pcre --with-http_ssl_module --with-http_stub_status_module --with-stream --with-http_stub_status_module --with-http_gzip_static_module && make && make install
    
    #配置nginx.conf
    cat >/opt/nginx/conf/nginx.conf<<EOF
    worker_processes  1;
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
    
        server {
            listen       80;
            server_name  localhost;
    
            location / {
                root   html;
                index  index.html index.htm;
            proxy_pass http://127.0.0.1:9000;
            }
        }
    
        # HTTPS server
        server {
            listen       443 ssl;
            server_name  localhost;
            #ssl_certificate      cert.pem;
            #ssl_certificate_key  cert.key;
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
            ssl_ciphers  HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
    
            location / {
                root   html;
                index  index.html index.htm;
            proxy_pass http://127.0.0.1:9000;
            }
        }
    
    }
    EOF
    
    #启动nginx
    [root@abcdocker conf]# /opt/nginx/sbin/nginx  -t

    我这里没有配置域名,就用ip 80端口演示1640684078107.png

    相关文章:

    1. Kubernetes 1.14 二进制集群安装
    2. Docker 镜像及Docker仓库配置 [四]
    3. Kuerbernetes 1.11 集群二进制安装
    4. Docker 核心技术与实现原理

    相关文章

    KubeSphere 部署向量数据库 Milvus 实战指南
    探索 Kubernetes 持久化存储之 Longhorn 初窥门径
    征服 Docker 镜像访问限制!KubeSphere v3.4.1 成功部署全攻略
    那些年在 Terraform 上吃到的糖和踩过的坑
    无需 Kubernetes 测试 Kubernetes 网络实现
    Kubernetes v1.31 中的移除和主要变更

    发布评论