Chain Monitoring using Python, Prometheus & Grafana
There are three services in this repository:
- Chain Moniroting Python app - main application that handles querying the chain
- Prometheus - open-source systems monitoring and alerting tool
- Grafana - open-source data visualization tool
to-do
This is a running list of all the metrics being monitored in this project.
ovl_token_minted
- Number of OVL tokens mintedupnl
- Unrealized profit and losscsgo_index
- Current CSGO Skins Index; this metric is calculated from the Siwa app
- to-do
You can choose from two options for local development: (1) Docker Setup or (2) Bare Python app. The docker setup is more recommended to understand how the whole architecture works.
We're leveraging docker and docker compose for this project. This makes it easy to run multiple services that are integral to the Chain Monitoring system. Follow the steps below on how to setup for local development.
- Install docker on your local machine: https://docs.docker.com/engine/install/
- Run docker compose. This command runs all services specified in docker-compose.yml
docker-compose up
- Check if the containers are running
This command should return a list of running containers like so:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c0271363ffd6 alpine:3.10 "/bin/sh -c '\n apk …" 9 seconds ago Up 8 seconds chainmonitoring-grafana-dashboards-1 44598b06ec1c prom/prometheus "/bin/prometheus --c…" 9 seconds ago Up 8 seconds 0.0.0.0:9091->9090/tcp prometheus-svc-2 13bfaded8fac grafana/grafana "/run.sh" 9 seconds ago Up 8 seconds 0.0.0.0:3000->3000/tcp chainmonitoring-grafana-1 2c45966746cf chain-monitoring "/bin/sh -c 'python …" 9 seconds ago Up 8 seconds 0.0.0.0:81->8000/tcp chain-monitoring
- Once all containers are running, you should be able to access the following services in your browser:
- Grafana - http://localhost:3000/
- Prometheus - http://localhost:9091/
- Chain Monitoring Python application - http://localhost:81/
When there are new python packages in your changes, make sure to add them to the requirements.txt file:
pip install <package_name>
pip freeze > requirements.txt
If there are code changes to the python application, re-build the docker container for the python application before running docker-compose up
.
docker-compose build chain-monitoring
This only runs the Python application. To emulate the complete monitoring functionality in your local machine, opt for the Docker setup instead.
- Install requirements
pip install -r requirements.txt
- Run python app
python chain_monitoring.py
Running the following command runs all tests in the tests/ directory.
pytest
- to-do