{"id":250720,"date":"2022-08-28T10:26:09","date_gmt":"2022-08-28T02:26:09","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=250720"},"modified":"2022-08-22T14:27:24","modified_gmt":"2022-08-22T06:27:24","slug":"sentry-log-monitor","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/sentry-log-monitor.html","title":{"rendered":"\u90e8\u7f72Sentry\u65e5\u5fd7\u76d1\u63a7\u7cfb\u7edf"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nSentry\u662f\u7a0b\u5e8f\u7684\u54e8\u5175\uff0c\u5b83\u53ef\u4ee5\u76d1\u63a7\u6211\u4eec\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u9879\u76ee\u7684\u8fd0\u884c\u72b6\u6001\uff0c\u4e00\u65e6\u67d0\u6bb5\u4ee3\u7801\u8fd0\u884c\u62a5\u9519\uff0c\u6216\u8005\u5f02\u5e38\uff0c\u4f1a\u7b2c\u4e00\u65f6\u95f4\u628a\u62a5\u9519\u7684\u8def\u7531\uff0c\u5f02\u5e38\u6587\u4ef6\uff0c\u8bf7\u6c42\u65b9\u5f0f \u7b49\u4e00\u4e9b\u975e\u5e38\u8be6\u7ec6\u7684\u4fe1\u606f\u4ee5\u6d88\u606f\u6216\u8005\u90ae\u4ef6\u7ed9\u6211\u4eec\uff0c\u8ba9\u6211\u4eec\u7b2c\u4e00\u65f6\u95f4\u77e5\u9053\uff1a\u7a0b\u5e8f\u51fa\u9519\u4e86\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u4eceSentry\u7ed9\u6211\u4eec\u7684\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u4e2d\u77ac\u95f4\u627e\u5230\u6211\u4eec\u9700\u8981\u5904\u7406\u7684\u4ee3\u7801\uff0c\u4ece\u800c\u5feb\u901f\u5730\u4fee\u590dBug\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

Sentry\u7b80\u4ecb<\/strong><\/div>\n

\u5728\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u4ee3\u7801\u8fd0\u884c\u65f6\u96be\u514d\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c\u800c\u4e14\u9879\u76ee\u5728\u90e8\u7f72\u5230\u6d4b\u8bd5\u3001\u751f\u4ea7\u73af\u5883\u540e\uff0c\u6211\u4eec\u4fbf\u4e0d\u53ef\u80fd\u50cf\u5728\u5f00\u53d1\u65f6\u90a3\u6837\u5bb9\u6613\u7684\u53ca\u65f6\u53d1\u73b0\u5904\u7406\u9519\u8bef\u4e86\u3002<\/p>\n

\u4e00\u822c\u6211\u4eec\u90fd\u662f\u5728\u9519\u8bef\u53d1\u751f\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u9519\u8bef\u4fe1\u606f\u624d\u4f1a\u4f20\u9012\u5230\u5f00\u53d1\u2f08\u5458\u90a3\u91cc\uff0c\u7136\u540e\u4e00\u987f\u64cd\u4f5c\u67e5\u770b\u7a0b\u5e8f\u8fd0\u884c\u7684\u65e5\u5fd7\uff0c\u4f46\u662f\u5f80\u5f80\u6211\u4eec\u4f1a\u56e0\u4e3a\u65e5\u5fd7\u4e2d\u7f3a\u5c11\u4e0a\u4e0b\u6587\u5173\u7cfb\uff0c\u5bfc\u81f4\u5f88\u96be\u5206\u6790\u771f\u6b63\u7684\u9519\u8bef\u662f\u4ec0\u4e48\u3002<\/p>\n

Sentry\u7531\u6b64\u5e94\u8fd0\u800c\u751f\u6210\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u4e00\u4e2a\u5f88\u597d\u7684\u5de5\u5177\uff0c\u8bbe\u8ba1\u4e86\u8bf8\u591a\u7279\u6027\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5feb\u3001\u66f4\u65b9\u4fbf\u3001\u66f4\u76f4\u89c2\u7684\u76d1\u63a7\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n

Sentry\u662f\u4ec0\u4e48\uff1fSentry\u662f\u7a0b\u5e8f\u7684\u54e8\u5175\uff0c\u5b83\u53ef\u4ee5\u76d1\u63a7\u6211\u4eec\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u9879\u76ee\u7684\u8fd0\u884c\u72b6\u6001\uff0c\u4e00\u65e6\u67d0\u6bb5\u4ee3\u7801\u8fd0\u884c\u62a5\u9519\uff0c\u6216\u8005\u5f02\u5e38\uff0c\u4f1a\u7b2c\u4e00\u65f6\u95f4\u628a\u62a5\u9519\u7684\u8def\u7531\uff0c\u5f02\u5e38\u6587\u4ef6\uff0c\u8bf7\u6c42\u65b9\u5f0f \u7b49\u4e00\u4e9b\u975e\u5e38\u8be6\u7ec6\u7684\u4fe1\u606f\u4ee5\u6d88\u606f\u6216\u8005\u90ae\u4ef6\u7ed9\u6211\u4eec\uff0c\u8ba9\u6211\u4eec\u7b2c\u4e00\u65f6\u95f4\u77e5\u9053\uff1a\u7a0b\u5e8f\u51fa\u9519\u4e86\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u4eceSentry\u7ed9\u6211\u4eec\u7684\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u4e2d\u77ac\u95f4\u627e\u5230\u6211\u4eec\u9700\u8981\u5904\u7406\u7684\u4ee3\u7801\uff0c\u4ece\u800c\u5feb\u901f\u5730\u4fee\u590dBug\u3002<\/p>\n

Sentry\u662f\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u65e5\u5fd7\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5177\u5907\u4ee5\u4e0b\u4f18\u70b9\uff1a<\/p>\n

  • \u591a\u9879\u76ee\uff0c\u591a\u7528\u6237<\/li>\n
  • \u754c\u9762\u53cb\u597d<\/li>\n
  • \u53ef\u4ee5\u914d\u7f6e\u5f02\u5e38\u89e6\u53d1\u89c4\u5219\uff0c\u4f8b\u5982\u76d1\u63a7\u5230\u7a0b\u5e8f\u51fa\u73b0\u5f02\u5e38\u540e\u53d1\u9001\u90ae\u4ef6<\/li>\n
  • \u652f\u6301\u591a\u79cd\u4e3b\u6d41\u8bed\u8a00\u548c\u6846\u67b6\uff0c\u5982 React\u3001Angular\u3001Node\u3001Django\u3001PHP\u3001Android\u3001.NET\u3001JAVA\u7b49<\/li>\n

    Sentry\u76ee\u524d\u652f\u6301\u7684\u8bed\u8a00\u548c\u6846\u67b6\u4f17\u591a\uff0c\u4e0b\u9762\u5c55\u793a\u4e00\u90e8\u5206:<\/p>\n

    \"\"<\/p>\n

    Sentry\u90e8\u7f72<\/strong><\/div>\n

    sentry\u5206\u4e3a\u6536\u8d39\u7248\u548c\u514d\u8d39\u81ea\u5efa\u7248\uff0c\u672c\u6587\u4e3b\u8981\u662f\u4ecb\u7ecd\u514d\u8d39\u7248\u3002\u5b98\u65b9\u63d0\u4f9b\u4e86docker-compose\uff0c\u4e5f\u662f\u5b83\u63a8\u8350\u7684\u90e8\u7f72\u65b9\u5f0f\uff0c\u53c2\u8003\u5730\u5740https:\/\/github.com\/getsentry\/onpremise\u3002\u90e8\u7f72\u8981\u6c42\u5982\u4e0b\uff1a<\/p>\n

    \r\nDocker 19.03.6+\r\nCompose 1.28.0+\r\nPython 3\r\n4 \u6838\r\n8 GB \u5185\u5b58\r\n20 GB \u53ef\u7528\u78c1\u76d8\u7a7a\u95f4\r\n<\/pre>\n

    \u672c\u7bc7\u4ec5\u4ecb\u7ecd\u5728ubuntu18.04\u4e0b\u7684\u5b89\u88c5\u3002<\/p>\n

    1\u3001\u5b89\u88c5docker<\/strong><\/span><\/div>\n
    \r\nsudo apt-get remove docker docker-engine docker-ce docker.io\r\nsudo apt-get update\r\nsudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common\r\ncurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo apt-key add -\r\nsudo add-apt-repository \"deb [arch=amd64] https:\/\/mirrors.aliyun.com\/docker-ce\/linux\/ubuntu $(lsb_release -cs) stable\"\r\nsudo apt-get update\r\nsudo apt-get install -y docker-ce\r\nsudo systemctl start docker<\/pre>\n
    2\u3001\u5b89\u88c5docker-compose<\/strong><\/span><\/div>\n
    \r\nsudo apt-get install python-pip\r\nsudo pip install docker-compose<\/pre>\n
    3\u3001\u5b89\u88c5git<\/strong><\/span><\/div>\n
    \r\nsudo apt-get update -y\r\nsudo apt install git<\/pre>\n
    4\u3001sentry\u90e8\u7f72]\/erji]<\/p>\n
    \r\ngit clone https:\/\/github.com\/getsentry\/onpremise.git\r\ncd onpremise\r\nsudo .\/install.sh\r\n\u5b89\u88c5\u671f\u95f4\u5b9a\u4e49\u7528\u6237\u540d\u548c\u5bc6\u7801\r\nEmail:[xxxxxxxx@qq.com](mailto:326968597@qq.com)\r\nPawword:xxxxxx<\/pre>\n

    [erji]5\u3001\u542f\u52a8<\/strong><\/span><\/div>\n

    \r\n`sudo docker-compose up -d`\r\n<\/pre>\n
    6\u3001\u767b\u5f55sentry\u5ba2\u6237\u7aef<\/strong><\/span><\/div>\n

    \u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165\uff1ahttp:\/\/ip:9000\/\uff0c\u5373\u53ef\u663e\u793a\u5982\u4e0b\u56fe\uff1a<\/p>\n

    \"\"<\/p>\n

    Sentry\u4f7f\u7528<\/strong><\/div>\n

    \u672c\u7bc7\u4ec5\u4ecb\u7ecd\u5728django\u4e2d\u7684\u5e94\u7528\uff0c\u5176\u5b83\u8bed\u8a00\u81ea\u884c\u9605\u8bfb\u5b98\u65b9\u6587\u6863\u3002<\/p>\n

    1\u3001\u5b89\u88c5\u4f9d\u8d56<\/strong><\/span><\/div>\n
    pip install --upgrade sentry-sdk<\/pre>\n
    2\u3001\u5728settings.py\u4e2d\u914d\u7f6e<\/strong><\/span><\/div>\n
    \r\nimport sentry_sdk\r\nfrom sentry_sdk.integrations.django import DjangoIntegration\r\nsentry_sdk.init(\r\n    dsn=\"https:\/\/xxxxxxxxxxxx.sentry.io\/0\",\r\n    integrations=[DjangoIntegration()],\r\n    traces_sample_rate=1.0,\r\n    send_default_pii=True,\r\n)\r\n\r\n<\/pre>\n
    3\u3001\u9a8c\u8bc1\u60a8\u7684 Sentry \u5b89\u88c5<\/strong><\/span><\/div>\n
    \r\nfrom django.urls import path\r\ndef trigger_error(request):\r\n  division_by_zero = 1 \/ 0\r\nurlpatterns = [\r\n  path('sentry-debug\/', trigger_error),\r\n]<\/pre>\n

    \u6dfb\u52a0\u5b8c\u6210\u4e4b\u540e\u6211\u4eec\u8bbf\u95ee\u8fd9\u4e2a\u8def\u7531\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Sentry\u540e\u53f0\u770b\u5230\u544a\u8b66\u4fe1\u606f\u5982\u4e0b\u56fe\uff1a<\/p>\n

    \"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u5728\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u4ee3\u7801\u8fd0\u884c\u65f6\u96be\u514d\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c\u800c\u4e14\u9879\u76ee\u5728\u90e8\u7f72\u5230\u6d4b\u8bd5\u3001\u751f\u4ea7\u73af\u5883\u540e\uff0c\u6211\u4eec\u4fbf\u4e0d\u53ef\u80fd\u50cf\u5728\u5f00\u53d1\u65f6\u90a3\u6837\u5bb9\u6613 […]<\/p>\n","protected":false},"author":317,"featured_media":244617,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-250720","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/250720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=250720"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/250720\/revisions"}],"predecessor-version":[{"id":250727,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/250720\/revisions\/250727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/244617"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=250720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=250720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=250720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}