Skip to content

🎛️A Python-based indexer for tracking USDT transactions, deployed on AWS EC2 with real-time metrics via Prometheus and visualized on Grafana. Features a custom dashboard and alerts for significant transactions.

Notifications You must be signed in to change notification settings

bce99/USDT-Contract-Indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

USDT-Contract-Indexer

Overview

This project involves developing and deploying an ERC20 smart contract indexer application on an AWS EC2 instance that integrates with Prometheus for metrics collection and Grafana for visualization. The application tracks USDT transactions and other relevant data. To verify if certain step is fulfill, you can refer to screenshots in /contract-indexer/screenshots.

Table of Contents

Features

  • Indexer application to track USDT transactions and approvals.
  • Prometheus for collecting metrics.
  • Grafana for visualizing metrics and creating dashboards.
  • Alerts for significant token transfers.

Setup

Prerequisites

  • Docker
  • Prometheus
  • Grafana Cloud account
  • Terraform

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo.git
    cd your-repo
  2. Install Terraform:

    Follow the instructions here to install Terraform.

  3. Initialize Terraform & Apply Terraform Plan:

    Change the configurations in '/contract-indexer/terraform_setup/main.tf' to match your AWS details. Run the following command in the root of your Terraform directory:

    terraform init
    terraform apply

    This will provision an EC2 instance, set up the necessary networking, and install Docker. To ssh into your EC2 instance, follow this guide

  4. Verify Deployment:

    After the Terraform plan is applied, verify that the EC2 instance is running and that Docker is installed.

  5. Download Prometheus

    To download Prometheus into your EC2 instance, run the following commands:

    wget https://github.com/prometheus/prometheus/releases/download/v2.36.0/prometheus-2.36.0.linux-amd64.tar.gz
    tar xvf prometheus-2.36.0.linux-amd64.tar.gz
    cd prometheus-2.36.0.linux-amd64
  6. Configure prometheus.yml and run Prometheus:

    You should first create a free account on Grafana Cloud and request for your own authentication details. Then fill in the 'remote-write' section and replace the two 'targets' parameter with indexer and node-exporter container IP respectively, using the following commands:

    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my-indexer-container
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' node-exporter

    Run Prometheus detached mode:

    nohup ./prometheus --config.file=prometheus.yml > prometheus.log 2>&1 &

    You are now good to connect your data source on Grafana Cloud and establish dashboards!

Usage

  • Access Prometheus:

    Open your browser and go to http://<EC2-PUBLIC-IP>:9090/targets?search=.

    You can expect something like this:

    http://<EC2-PUBLIC-IP>:9090/targets?search=

  • Access all metrics on node-exporter:

    Open your browser and go to http://<EC2-PUBLIC-IP>:9100.

    You can expect something like this:

    http://<EC2-PUBLIC-IP>:9100

  • Access indexer output:

    Open your browser and go to http://<EC2-PUBLIC-IP>:9200.

    You can expect something like this:

    http://<EC2-PUBLIC-IP>:9200

  • Final Dashboard:

    You should see something like this!

    final-dashboard

Metrics

  • tx_per_second: Shows the rate of transactions per second.
  • token_transferred_per_second: Shows the rate of tokens transferred per second.
  • approvals_per_second: Shows the rate of approvals per second.
  • approval_amount_metric: Shows the rate of tokens approved per second.

Alerting

  1. Create an alert rule in Grafana Cloud:

    Set up an alert to trigger when the rate of token transfers exceeds a threshold.

    • Metric: token_transferred_per_second
    • Condition: Is above a certain value (e.g., 100 tokens)

Troubleshooting

  • Issue: No data in Grafana dashboard.

    Solution: Verify that the indexer container is running and exposing metrics on port 9200.

  • Issue: Prometheus target is down.

    Solution: Ensure that Prometheus can access the indexer container on the specified port.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

🎛️A Python-based indexer for tracking USDT transactions, deployed on AWS EC2 with real-time metrics via Prometheus and visualized on Grafana. Features a custom dashboard and alerts for significant transactions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published