GET /metrics
Exports Prometheus-compatible metrics for monitoring request rates, latencies, backend health, and WebSocket connections. This endpoint runs on a dedicated port (configured viametrics_port in config.toml) and does not require authentication.
Configuration
config.toml
Request
No parameters required.Response Format
Returns metrics in Prometheus text-based exposition format:Metrics Reference
HTTP Request Metrics
Total number of RPC requests processed.Labels:
method: HTTP method (e.g.,POST,GET)status: HTTP status code (e.g.,200,401,429,503)rpc_method: Solana RPC method from request body (e.g.,getSlot,sendTransaction,unknown)backend: Selected backend label (e.g.,mainnet-primary,noneif no backend selected)owner: API key owner from Redis (e.g.,my-client,noneif unauthenticated)
Request duration histogram with configurable buckets.Labels:
rpc_method: Solana RPC methodbackend: Backend labelowner: API key owner
[0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0]Exported metrics:rpc_request_duration_seconds_bucket{le="0.1"}: Count of requests ≤ 100msrpc_request_duration_seconds_sum: Total duration of all requestsrpc_request_duration_seconds_count: Total number of requests
Backend Health Metrics
Current health status of each backend (1 = healthy, 0 = unhealthy).Labels:
backend: Backend label
health_check.interval_secs seconds. Use this metric to monitor backend availability and trigger alerts when backends go unhealthy.WebSocket Metrics
Total WebSocket connection attempts.Labels:
backend: Backend label (ornone)owner: API key owner (ornone)status: Connection status:connected: Successfully upgraded and connected to backendauth_failed: Invalid or missing API keyrate_limited: API key exceeded rate limitno_backend: No healthy WebSocket backends availablebackend_connect_failed: Failed to connect to backend WebSocketerror: Internal error during validation
Currently active WebSocket connections.Labels:
backend: Backend labelowner: API key owner
Total WebSocket messages relayed.Labels:
backend: Backend labelowner: API key ownerdirection: Message direction:client_to_backend: Client → Backendbackend_to_client: Backend → Client
WebSocket connection duration (time from upgrade to disconnect).Labels:
backend: Backend labelowner: API key owner
rpc_request_duration_seconds.Example Output
Metrics Sample
Grafana Queries
Request Rate by Method
P95 Latency by Backend
Error Rate
Auth Failure Rate
Rate Limit Hit Rate
Active WebSocket Connections
WebSocket Message Throughput
Backend Request Distribution
Prometheus Configuration
Add the router to your Prometheus scrape targets:prometheus.yml
Alerting Rules
alerts.yml
Histogram Buckets
The router uses carefully selected histogram buckets optimized for RPC latency patterns:- Sub-10ms:
[0.001, 0.005, 0.01]- Fast cache hits, local requests - 10-100ms:
[0.025, 0.05, 0.1]- Typical RPC response times - 100ms-1s:
[0.25, 0.5, 1.0]- Slower methods, network variance - 1s+:
[2.5, 5.0, 10.0]- Timeouts, degraded backends
histogram_quantile().