Front-end Monitoring (Sentry)

Sentry is a platform for real-time event logging and aggregation. It focuses on error monitoring and extracting all the information it needs to deal with afterwards without relying on cumbersome user feedback. The client (currently available in Python, PHP,C#, Ruby and many other languages) is embedded in your application. When the application fails, it sends a message to the server. The server logs the message to the database and provides a web page for easy viewing. Sentry is written in Python and is open source with excellent performance and easy to extend. Its current famous users include Disqus, Path, Mozilla, Pinterest, etc.

Why Sentry?

  • free
  • Sentry can be used directly or built in-house
  • Strong compatibility, basic language restrictions, build a set of systems can be used for multiple projects.

The deployment of

Method 1: Deploy using the command line interface (CLI)

This server configuration

  • Docker 20.10.10 (Latest)
  • Docker – compose 1.28.6
  • A minimum of 2400MB RAM is required, and 8GB is recommended for further expansion

Docker, docker-compose installation

  • 1. Uninstall the old Docker
yum remove docker docker-common docker-selinux docker-engine
Copy the code
  • 2. Install dependencies
yum install -y yum-utils device-mapper-persistent-data lvm2
Copy the code
  • 3. Install docker-CE
yum -y install docker-ce
Copy the code
  • 4. Start Docker
sudo systemctl start docker
Copy the code
  • 5. Install docker-compose for the specified version
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# https://github.com/docker/compose/releases docker - compose the version number query
Copy the code

Deploy the sentry

  • 1. Pull the mirror
docker pull sentry       The latest version is 9.1.2
docker pull redis
docker pull postgres
Copy the code
  • 2. Start the service
docker run -d --name sentry-redis --restart=always redis   ### guarantee, abnormal automatically pull up
docker run -d --name sentry-postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=sentry --restart=always postgres
Copy the code
  • 3. Generate the Sentry key
docker run --rm sentry config generate-secret-key
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxddd  ### Print secret-keys
Copy the code
  • 4. Initialize the database and accounts
# Note: This process requires you to create a user and password
docker run -it --rm -e SENTRY_SECRET_KEY='xxxxx' --link sentry-postgres:postgres --link sentry-redis:redis sentry upgrade
Copy the code
  • 5. Start the Sentry Web service
docker run -d -p 9000:9000 --name my-sentry -e SENTRY_SECRET_KEY='xxxxx' --link sentry-redis:redis --link sentry-postgres:postgres --restart=always sentry
Copy the code
  • 6. Start sentry-cron/work service
docker run -d --name sentry-cron -e SENTRY_SECRET_KEY='xxxx' --link sentry-postgres:postgres --link sentry-redis:redis sentry run cron

docker run -d --name sentry-worker-1 -e SENTRY_SECRET_KEY='xxxxx' --link sentry-postgres:postgres --link sentry-redis:redis sentry run worker
Copy the code
  • 7. Login test effect

link

Method 2: Use the official onpremise

Server Configuration Requirements

  • 4-core 8GB ram
  • The Docker 17.05.0 +
  • Compose 1.23.0 +

My server is not configured enough to try this

Deploy the sentry

  • 1. Get the latest Sentry code from Github
git clone https://github.com/getsentry/onpremise.git
Copy the code
  • 2. Go to onpremise and run the install.sh script.
cd onpremise
./install.sh
Copy the code
  • 3. After installation
docker-compose up -d # After success, visit http://127.0.0.1:9000 to enter the main sentry screen
Copy the code
  • 4. Account registration
--superuser --force-update --force-update --superuser --force-update

docker-compose run --rm web createuser --superuser --force-update 
Copy the code

Then open the main screen of Sentry (http://127.0.0.1:9000) and log in with the account you just applied for. You can do some basic configuration when you log in for the first time. For example, whether to allow registration, privacy, email server configuration, etc. (because the team management in Sentry involves using email to invite users, so you can choose whether to configure the email server), after self-configuration, you can enter the main interface of Sentry management

  • Stop the Sentry service
docker-compose down
Copy the code

tip

# will only need a key to accelerate the git clone www.github.com/ back to the code base is changed to www.github.com.cnpmjs.org/ back to the code base address can realize one-click acceleration. A button to start the container # docker start $(docker ps - a | awk '{print $1}' | tail - n + 2)Copy the code

The resources

Front-end surveillance video

Complete Sentry Docker deployment in one go

Build front-end anomaly monitoring system based on Sentry