Go to file
Kirill Fedoseev ebb71e50f5 Release v0.0.18 2022-04-04 12:22:24 +04:00
.github/workflows Config JSON schema 2022-03-27 01:47:51 +04:00
config Rework event handlers 2022-04-04 12:21:58 +04:00
contract Rework event handlers 2022-04-04 12:21:58 +04:00
db Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
entity Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
ethclient Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
grafana Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
logging Slack alerts 2021-09-25 21:23:30 +03:00
monitor Rework event handlers 2022-04-04 12:21:58 +04:00
presenter Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
prometheus Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
repository Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
utils Start alertManager only after bridge logs are fully synced 2021-09-27 01:33:12 +03:00
.dockerignore Bump go version 2021-09-20 01:15:37 +03:00
.env.example Add README.md 2022-03-28 12:31:02 +04:00
.gitignore Add README.md 2022-03-28 12:31:02 +04:00
Dockerfile Alarms for auto executed home-to-foreign messages 2022-03-27 14:12:48 +04:00
README.md Add README.md 2022-03-28 12:31:02 +04:00
config.schema.json Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
config.yml Support erc-to-native bridge 2022-04-02 15:49:18 +04:00
docker-compose.dev.yml Grafana provision 2022-03-28 11:28:10 +04:00
docker-compose.prod.yml Release v0.0.18 2022-04-04 12:22:24 +04:00
go.mod Add simple json presenter 2021-10-08 23:28:27 +03:00
go.sum Add simple json presenter 2021-10-08 23:28:27 +03:00
main.go Listen for validator set update events 2022-03-14 13:43:14 +04:00

README.md

Tokenbridge AMB monitor

This repo provides a real-time monitoring solution for the AMB 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/amb-monitor.git
cd amb-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.