Skip to content

Serverless solution for monitoring RPC nodes response time across different blockchains and regions using Vercel Functions

Notifications You must be signed in to change notification settings

chainstacklabs/chainstack-rpc-dashboard-functions

Repository files navigation

Public RPC Dashboard

Deploy with Vercel

A serverless solution for monitoring RPC nodes response time across different blockchains and regions using Vercel Functions and Grafana Cloud. The project collects metrics from HTTP/WS endpoints for multiple blockchains and pushes them to Grafana Cloud for visualization.

📚 Public RPC Dashboard Documentation

Features

  • 🌐 Multi-region monitoring: US West, Germany, Singapore
  • 📊 Real-time metrics visualization in Grafana Cloud
  • 🔗 Support for multiple blockchains:
    • Ethereum
    • Base
    • Solana
    • TON

Architecture

  • Serverless functions run every minute in configured regions
  • Metrics are collected and pushed to Grafana Cloud
  • Authentication for production endpoints using CRON_SECRET
  • Preview deployments for testing with SKIP_AUTH

Deployment options

1. Single region quick deploy

  1. Fork this repository
  2. Click the "Deploy with Vercel" button above
  3. Configure the required environment variables (see below)
  4. Deploy!

2. Multi-region svetup

To monitor RPC providers from multiple regions:

  1. Create three separate Vercel projects for different regions:

    • Project 1: your-project-iad1 (US East)
    • Project 2: your-project-sfo1 (US West)
    • Project 3: your-project-hkg1 (Asia)
  2. Link each project to the same repository

  3. Configure region override in each project:

    • Project Settings → Functions → Function Region
    • Select the corresponding region (iad1/sfo1/hkg1)
  4. Configure shared environment variables:

    • Team Settings → Environment Variables → Link To Projects

Environment variables

Production required variables

# Grafana Cloud configuration
GRAFANA_URL=https://influx-...-east-0.grafana.net/api/v1/push/influx/write
GRAFANA_USER=your_grafana_user_id
GRAFANA_API_KEY=your_grafana_api_key

# Monitoring configuration
METRIC_NAME=response_latency_seconds
METRIC_REQUEST_TIMEOUT=35
METRIC_MAX_LATENCY=35

# Security
CRON_SECRET=your_production_cron_secret  # Required for production
SKIP_AUTH=FALSE                          # Should be FALSE in production

# RPC configuration
ENDPOINTS={"providers":[{"blockchain":"Ethereum","name":"Provider1"...}]}

Preview environment variables

For development and testing:

METRIC_NAME=test_response_latency_seconds  # Add prefix to avoid metric conflicts
SKIP_AUTH=TRUE                            # Allows direct URL access

Local development

  1. Clone and setup:
git clone https://github.com/chainstacklabs/chainstack-rpc-dashboard-functions.git
cd chainstack-rpc-dashboard-functions
  1. Create and activate virtual environment:
# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
  1. Configure environment:
cp .env.local.example .env.local   # Update with your values
cp endpoints.json.example endpoints.json
  1. Install dependencies:
pip install -r requirements.txt
  1. Run development server:
python run_local.py
  1. Test endpoints:
curl http://localhost:8000/api/chains/ethereum

RPC provider configuration

Configure your RPC providers in endpoints.json (for local development) or in ENDPOINTS environment variable:

{
    "providers": [
        {
            "blockchain": "Ethereum",
            "name": "Chainstack-Free",
            "region": "Global",
            "websocket_endpoint": "wss://ethereum-mainnet.core.chainstack.com/...",
            "http_endpoint": "https://ethereum-mainnet.core.chainstack.com/...",
            "data": {}
        }
    ]
}

Project structure

.
├── api/                      # Vercel Serverless Functions
│   └── chains/              # Blockchain-specific handlers
│       ├── base.py          
│       ├── ethereum.py      
│       ├── solana.py        
│       └── ton.py           
├── common/                   # Shared utilities
│   ├── base_metric.py       # Base metric collection
│   ├── factory.py           # Metric factory pattern
│   ├── metric_config.py     # Configuration classes
│   ├── metric_types.py      # Metric type definitions
│   └── metrics_handler.py   # Core metrics handler
├── metrics/                  # Blockchain-specific metrics
│   ├── base.py              
│   ├── ethereum.py          
│   ├── solana.py            
│   └── ton.py               
└── config files...          # Configuration and setup files

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -am 'Add YourFeature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Create a Pull Request

About

Serverless solution for monitoring RPC nodes response time across different blockchains and regions using Vercel Functions

Topics

Resources

Stars

Watchers

Forks

Languages