One, foreword
Many companies set up their own error monitoring systems. I want to try to build a monitoring system, because our company’s internal small program reported an error online, and could not locate the problem in time. I happened to see a blog recommending Sentry, so I am interested in it.
Registration service
- Register for the service on the official website
- Build your own service
1. Register the service on the official website
1) Register personal or company information
Official portal
Fill in the above information according to personal or company requirements. Because I am a personal project test, fill in their own information
2) Create a project
Here is the React project. Type in the index.jsx file and copy it directly
3) Test for errors according to instructions
return <button onClick={methodDoesNotExist}>Break the world</button>;
Copy the code
4) The console has sent a sentry request
2. Build your own service (Docker)
Official website mirror portal
Docker 17.05.0+ Compose 1.23.0; The minimum storage space is 2400RMB
Actually the method is very simple. Git Clone repository, then./install.sh. This step is time-consuming because it has a lot of dependencies. If it goes well, the installation is successful and runs directly
docker-compose up -d
Copy the code
Sentry-onpremise started successfully
Open localhost:9090 and you can do the same on the official website
It may be reported during installation, and I also put forward an issue on the official website. After the mention found that there has been a similar issue github.com/getsentry/o…
Connection to Kafka failed
Copy the code
The solution is
docker-compose down
docker volume rm sentry-kafka sentry-zookeeper
docker volume rm sentry_onpremise_sentry-kafka-log sentry_onpremise_sentry-zookeeper-log
./install
Copy the code
At last I was able to run smoothly. The company can ask operations to deploy on the server, remember that it requires at least 2.4GB of space and depends on Docker
Upload sourceMap to sentry
The purpose of uploading sourceMap is to make it easy to pinpoint which line of source code to go to
The official website provides several ways
Souecemap portal
I’m using sentry-CLI here, so I’ll show you using sentry-CLI
1) Install Sentry – CLI
NPM I -g@sentry /cli sentry-cli -v Check the versionCopy the code
2) Log in and get itAuth Tokens
sentry-cli
Copy the code
The default is to connect to senty. IO, or if you want to connect your own input
sentry-cli --url https://myserver.invalid/ login
Copy the code
After open the
3) Create a directory in the root directory~/.sentryclirc
- MAC
~
On behalf of/user/ Your username
- Vim is recommended to facilitate the creation
Vim ~/. Sentryclirc/I to enter insert mode esc to exit insert mode :wq! Save and exit :q! Exit without savingCopy the code
Copy the Auth token, and configure the other tokens as well
[auth]
token=7c44fb0b77b7430b93cdad42cd8f5ad6386fcc8d7dd6477e86b48c7aa490d793
[defaults]
url=https://sentry.io/
org=116e23a13af3
project=nanlan-blog
Copy the code
I was struggling with how to check org and project before, but I checked some information later. Check org in the General Settings of Organzation Settings
Project Settings
General Settings
project
4) upload
- Create one when you upload
release
The name - Then use the
upload-sourcemaps
Upload, the following URL is localurl
, that is, after packagingbuild
ordist
File plus the following js - The default is
.map
or.js
You can change the extension of the file - Final release
There’s a pit here. I was having trouble uploading, and I forgot what the problem was. This is how I uploaded it
Sentry -cli --log-level= Debug releases files v1.0.2 upload-sourcemaps./build --rewriteCopy the code
./build is the folder that you pack locally
Uploaded successfully
Remember free is 40MB
Under the Release menu, you can view Artifacts that you just uploaded under the Release name you just set
The official website has this notation
sentry-cli releases files VERSION upload-sourcemaps . --url-prefix '~/scripts'
Copy the code
- –url-prefix is the url of the line
- ~ is the domain name of your website, for example
http://localhost:9000
Here is a screenshot from the official
There is a problem that has not been solved up to now. I did not locate the source code after the error. I do not know why release is correct
4. Set the time zone
Part (ii) will address the previous issue (currently being looked at) as well
- Reporting rules
- To distinguish the environment
- with
git commit
associated - .
What opinions or suggestions are put forward to communicate with each other