介紹
sentry是一個(gè)開(kāi)源的監(jiān)控系統(tǒng),能支持服務(wù)端與客戶端的監(jiān)控,還有個(gè)強(qiáng)大的后臺(tái)錯(cuò)誤分析、報(bào)警平臺(tái)。
搭建sentry:
官網(wǎng)推薦使用docker
依賴環(huán)境:docker,docker-compose
- git clone https://github.com/getsentry/onpremise.git
- 進(jìn)入onpremise文件夾,執(zhí)行./install.sh, 這個(gè)過(guò)程會(huì)建立管理賬號(hào)
這是sentry需要docker最小內(nèi)存2400M, 需要在docker里面設(shè)置內(nèi)存,只要大于2400M就沒(méi)這個(gè)問(wèn)題了。
3.啟動(dòng)sentry :docker-compose up -d
通過(guò)localhost:9000 可以訪問(wèn)sentry了。

img
通過(guò)剛剛設(shè)置的賬號(hào)和密碼可以進(jìn)入到后臺(tái)。
到這里, 我們sentry的后臺(tái)就已經(jīng)部署好了。
平臺(tái)地址
http://report.eyunying.com.cn:11205/auth/login/sentry/
vue項(xiàng)目接入
- 接入
yarn add @sentry/vue @sentry/tracing
main.js
import * as Sentry from "@sentry/vue";
import { Integrations } from "@sentry/tracing";
Sentry.init({
Vue,
dsn: "http://ca54b1ca19d14347844d19046c0ea302@report.eyunying.com.cn:11205/9",
integrations: [
new Integrations.BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ["localhost", "my-site-url.com", /^\//]
})
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0
});
.sentryclirc
[defaults]
### 你的域名
url='http://report.eyunying.com.cn:11205'
### 組織團(tuán)隊(duì)名默認(rèn)是 sentry
org=sentry
### 項(xiàng)目名稱
project=demo
### 步驟1創(chuàng)建的
[auth]
# 本地
token=3dfb4982a8b1403ea8ea8aa1d4e36618b723587bdfa2496098c629468c0fb71c
[http]
keepalive=false
[dsym]
max_upload_size=209715200
[log]
level=debug
token 生成

image-20211115093756018

image-20211115093833880
- 配置webpack
yarn add @sentry/webpack-plugin
vue.config.js
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
在 plugins
new SentryWebpackPlugin({
release: process.env.RELEASE_VERSION, //版本號(hào)
include: path.join(__dirname, `.${process.env.VUE_APP_BASE}js/`), //需要上傳到sentry服務(wù)器的資源目錄,會(huì)自動(dòng)匹配js 以及map文件
ignore: ["node_modules", "vue.config.js"], //忽略文件目錄,當(dāng)然我們?cè)趇nclude中制定了文件路徑,這個(gè)忽略目錄可以不加
configFile: ".sentryclirc",
urlPrefix: `~${process.env.VUE_APP_BASE}js` // 線上對(duì)應(yīng)的url資源的相對(duì)路徑 比如我的域名是 http://XXX .com/,靜態(tài)資源都在 static文件夾里面,
})
- 釘釘報(bào)警

image-20211115094927696
報(bào)警規(guī)則

image-20211115095108803