Monitoring Guide

Monitor your Wealth trading bot's performance with built-in dashboards and AI-powered queries.

Table of Contents


Overview

The bot provides multiple monitoring options:

  • 🤖 AI Queries - Ask questions in natural language via Grafana MCP
  • 📊 Dashboards - Visual monitoring in Grafana
  • 📈 Metrics - Real-time performance data via OpenTelemetry
  • 🔔 Alerts - Automated notifications for important events
  • ❤️ Health Endpoint - Quick status checks

Quick Health Check

CLI Commands

# Overall health status
curl http://localhost:9090/health | jq

# Check positions
wealth positions

# Check balances
wealth balance

# View configuration
wealth config

Health Endpoint Response

{
  "status": "healthy",
  "timestamp": "2024-01-15T10:30:00Z",
  "uptime_seconds": 3600,
  "components": {
    "websockets": {
      "binance": { "connected": true, "last_update": "2024-01-15T10:29:58Z", "error_count": 0 },
      "bybit": { "connected": true, "last_update": "2024-01-15T10:29:59Z", "error_count": 0 }
    },
    "exchanges": {
      "binance_api": { "reachable": true, "consecutive_failures": 0 },
      "bybit_api": { "reachable": true, "consecutive_failures": 0 }
    },
    "strategy": {
      "active_positions": 2,
      "fresh_funding_rates": 15
    }
  }
}

AI-Powered Monitoring

Ask your AI assistant (GitHub Copilot, Claude, etc.) natural language questions:

Examples:

  • "What's my current P&L?"
  • "Show funding rates for BTCUSDT"
  • "Are there any firing alerts?"
  • "Which exchange has the best execution performance?"
  • "What's the average position holding time?"

No need to write queries or navigate dashboards - AI queries metrics automatically.

Setup (5 minutes)

  1. Start services:

    docker compose up -d
    
  2. Generate Grafana token at http://localhost:3000

  3. Add to .env:

    GRAFANA_SERVICE_ACCOUNT_TOKEN=glsa_...
    
  4. Restart MCP:

    docker compose restart grafana-mcp
    

Full guide: Grafana MCP Setup Guide


Grafana Dashboards

Accessing Dashboards

  1. Open Grafana: http://localhost:3000
  2. Default credentials: admin / admin
  3. Navigate to DashboardsWealth Trading Bot

Key Dashboard Panels

PanelDescription
P&L OverviewTotal profit/loss across all exchanges
Active PositionsCurrent open positions with entry prices
Funding Rate SpreadSpread between exchanges
Execution Success RateOrder fill rate and latency
Balance by ExchangeUSDT balance per exchange
WebSocket StatusConnection health for each exchange

Setting Up Grafana Cloud

For cloud monitoring (recommended for production):

  1. Create free Grafana Cloud account
  2. Configure OTLP export
  3. Import dashboard templates

See Grafana Cloud Setup for full instructions.


Key Metrics

Trading Performance

MetricDescriptionGood Value
Win Rate% of profitable trades> 60%
Average P&LMean profit per trade> 0
Fill Rate% of orders filled> 95%
Execution LatencyOrder placement time< 100ms

System Health

MetricDescriptionGood Value
WebSocket UptimeConnection stability> 99%
API Success RateExchange API health> 99%
Memory UsageRAM consumption< 500MB
Error RateErrors per minute< 1

View in Terminal

# Metrics info endpoint
curl http://localhost:9090/metrics | jq

Alerts

Built-in Alert Types

AlertSeverityTrigger
Low BalanceCriticalAccount balance < $1,000
High Error RateWarningAPI errors > 10%
Position StuckWarningPosition open > 24 hours
High SlippageWarningSlippage > 50 bps
Connection FailureCriticalWebSocket disconnected

Configuring Alerts in Grafana

  1. Go to AlertingAlert rules
  2. Create new alert rule
  3. Set condition (e.g., wealth_balance_total < 1000)
  4. Add notification channel (email, Slack, Discord)

Example Alert Rule

# Low Balance Alert
condition: wealth_balance_total{exchange="binance"} < 1000
for: 5m
severity: critical

Log Viewing

Real-time Logs

# Follow bot logs
wealth run 2>&1 | tee -a bot.log

# Or with Docker
docker compose logs -f wealth

Log Levels

LevelExample
INFO`Bot running
WARNRate limit approaching
ERROROrder placement failed

Searching Logs in Grafana (Loki)

# All errors
{service="wealth-bot"} |= "ERROR"

# Order execution logs
{service="wealth-bot"} |= "arbitrage"

# WebSocket issues
{service="wealth-bot"} |= "WebSocket"

Docker Compose Monitoring Stack

The included compose.yml provides:

  • Grafana - Dashboards and visualization
  • OpenTelemetry Collector - Metrics aggregation
  • Prometheus - Metrics storage
  • Loki - Log aggregation
  • Tempo - Distributed tracing

Starting the Stack

# Start all services
docker compose up -d

# Check service status
docker compose ps

# View logs
docker compose logs -f

Accessing Services

ServiceURLCredentials
Grafanahttp://localhost:3000admin / admin
Prometheushttp://localhost:9090-
Bot Healthhttp://localhost:9090/health-

Development / Paper Trading

  • Local Grafana (Docker Compose)
  • Terminal logs
  • Health endpoint checks

Production / Live Trading

  • Grafana Cloud (free tier available)
  • Alert notifications (email/Slack)
  • AI-powered monitoring (MCP)
  • 24/7 uptime monitoring

Quick Reference

# Health check
curl http://localhost:9090/health | jq

# View positions
wealth positions

# View balances  
wealth balance

# Start monitoring stack
docker compose up -d

# View Grafana
open http://localhost:3000

# Follow logs
docker compose logs -f wealth

See Also