Go to file
Kirill Fedoseev fc6baff634 Add raw_message field 2022-06-22 18:42:23 +03:00
.github/workflows CI linting 2022-05-22 16:32:05 +04:00
cmd Small DB functions refactor 2022-06-01 23:27:08 +04:00
config Rework tx link formatting 2022-05-30 20:44:10 +04:00
contract Endpoint for pending messages search 2022-06-11 11:17:53 +03:00
db Add raw_message field 2022-06-22 18:42:23 +03:00
entity Add raw_message field 2022-06-22 18:42:23 +03:00
ethclient Update metrics 2022-06-02 15:13:22 +04:00
grafana Update metrics 2022-06-02 15:13:22 +04:00
logging Rework presenter internals 2022-05-25 13:53:42 +04:00
monitor Add raw_message field 2022-06-22 18:42:23 +03:00
presenter Endpoint for pending messages search 2022-06-11 11:17:53 +03:00
prometheus Add alert for offline validators 2022-05-08 13:13:13 +02:00
repository Add raw_message field 2022-06-22 18:42:23 +03:00
utils Universal logs search 2022-05-25 22:00:21 +04:00
.dockerignore Utils for splitting blocks and logs ranges 2022-05-22 14:19:09 +04:00
.env.example Fix prometheus credentials provisioning 2022-04-05 14:35:21 +04:00
.gitignore Utils for splitting blocks and logs ranges 2022-05-22 14:19:09 +04:00
.golangci.yml Generic events search in API 2022-05-29 19:25:56 +04:00
Dockerfile Add script for fixing block_timestamps 2022-05-21 16:45:30 +04:00
README.md Update README.md 2022-05-24 10:45:13 +04:00
config.schema.json Rework tx link formatting 2022-05-30 20:44:10 +04:00
config.yml Rework tx link formatting 2022-05-30 20:44:10 +04:00
docker-compose.dev.yml Separate command for events reprocessing 2022-05-25 23:48:20 +04:00
docker-compose.prod.yml Release v0.1.3 2022-06-11 11:22:51 +03:00
go.mod Lint imports 2022-05-22 15:29:01 +04:00
go.sum Bump dependencies 2022-05-06 19:05:06 +02:00

README.md

Tokenbridge monitor

This repo provides a real-time monitoring solution for the AMB/XDAI bridge contracts. It performs a real-time chain indexing for the configured bridged instances, and alerts in case of some important events or outages.

Tech layout

  • Monitor (Golang)
  • PostgreSQL
  • Prometheus
  • Alertmanager (Slack alerts)
  • Grafana (Stats visualization)
  • Traefik for HTTPS routing

Configuration

Monitor configuration is managed through the yml file, processed during the startup (./config.yml). Config schema is described in (./config.schema.json). Config supports env variable interpolation (see INFURA_PROJECT_KEY).

Local start-up

  1. Create env file with INFURA_PROJECT_KEY:
cp .env.example .env
nano .env
  1. Build monitor docker container:
docker-compose -f docker-compose.dev.yml build
  1. In the need of testing Slack alerts in the local deployment, do the following:
# HTTP Basic auth password for prometheus -> alertmanager authentication.
nano ./prometheus/admin_password.txt
# Slack webhook URL for sending alerts. Double check that there is no newline in the end of the file.
printf 'https://hooks.slack.com/services/...' > ./prometheus/slack_api_url.txt
  1. Put bcrypt password hash of ./prometheus/admin_password.txt in ./prometheus/web.yml. Hash can be generated at https://bcrypt-generator.com:
# Set bcrypt hash for admin user
nano ./prometheus/web.yml
  1. Start up:
# Background services
docker-compose -f docker-compose.dev.yml up -d postgres prometheus grafana
# Optionally startup alertmanager
# docker-compose -f docker-compose.dev.yml up -d alertmanager
# Startup monitor
docker-compose -f docker-compose.dev.yml up monitor
  1. Take a look:

Deployment

For final deployment, you will need a VM with a static IP and a DNS domain name attached to that IP. SSL certificates will be managed by a Traefik and Let's Encrypt automatically.

git clone https://github.com/poanetwork/tokenbridge-monitor.git
cd tokenbridge-monitor

cp .env.example .env
nano .env # put valid INFURA_PROJECT_KEY and valid domain names
nano config.yml # modify monitor config if necessary (e.g. disable/enable particular bridges monitoring)

# HTTP Basic auth password for prometheus -> alertmanager authentication.
nano ./prometheus/admin_password.txt
# Slack webhook URL for sending alerts. Double check that there is no newline in the end of the file.
printf 'https://hooks.slack.com/services/...' > ./prometheus/slack_api_url.txt
# Set bcrypt hash for admin user
nano ./prometheus/web.yml

docker-compose -f docker-compose.prod.yml pull
docker-compose -f docker-compose.prod.yml up -d

After a small delay you should be able to access all the services via the provided DNS names through HTTPS. Make sure to change the default admin password in Grafana at the first login.