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)
-
Start services:
docker compose up -d -
Generate Grafana token at
http://localhost:3000 -
Add to
.env:GRAFANA_SERVICE_ACCOUNT_TOKEN=glsa_... -
Restart MCP:
docker compose restart grafana-mcp
Full guide: Grafana MCP Setup Guide
Grafana Dashboards
Accessing Dashboards
- Open Grafana:
http://localhost:3000 - Default credentials:
admin/admin - Navigate to Dashboards → Wealth Trading Bot
Key Dashboard Panels
| Panel | Description |
|---|---|
| P&L Overview | Total profit/loss across all exchanges |
| Active Positions | Current open positions with entry prices |
| Funding Rate Spread | Spread between exchanges |
| Execution Success Rate | Order fill rate and latency |
| Balance by Exchange | USDT balance per exchange |
| WebSocket Status | Connection health for each exchange |
Setting Up Grafana Cloud
For cloud monitoring (recommended for production):
- Create free Grafana Cloud account
- Configure OTLP export
- Import dashboard templates
See Grafana Cloud Setup for full instructions.
Key Metrics
Trading Performance
| Metric | Description | Good Value |
|---|---|---|
| Win Rate | % of profitable trades | > 60% |
| Average P&L | Mean profit per trade | > 0 |
| Fill Rate | % of orders filled | > 95% |
| Execution Latency | Order placement time | < 100ms |
System Health
| Metric | Description | Good Value |
|---|---|---|
| WebSocket Uptime | Connection stability | > 99% |
| API Success Rate | Exchange API health | > 99% |
| Memory Usage | RAM consumption | < 500MB |
| Error Rate | Errors per minute | < 1 |
View in Terminal
# Metrics info endpoint
curl http://localhost:9090/metrics | jq
Alerts
Built-in Alert Types
| Alert | Severity | Trigger |
|---|---|---|
| Low Balance | Critical | Account balance < $1,000 |
| High Error Rate | Warning | API errors > 10% |
| Position Stuck | Warning | Position open > 24 hours |
| High Slippage | Warning | Slippage > 50 bps |
| Connection Failure | Critical | WebSocket disconnected |
Configuring Alerts in Grafana
- Go to Alerting → Alert rules
- Create new alert rule
- Set condition (e.g.,
wealth_balance_total < 1000) - 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
| Level | Example |
|---|---|
| INFO | `Bot running |
| WARN | Rate limit approaching |
| ERROR | Order 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
| Service | URL | Credentials |
|---|---|---|
| Grafana | http://localhost:3000 | admin / admin |
| Prometheus | http://localhost:9090 | - |
| Bot Health | http://localhost:9090/health | - |
Recommended Monitoring Setup
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
- Grafana Cloud Setup - Cloud monitoring
- Log Collection (Loki) - Log queries
- Configuration - Metrics settings
- Troubleshooting - Common issues