Set up metrics, logs, and alerts to track your trading system
- Prometheus server
- Grafana
- Access to application logs in
logs/
- The application exposes Prometheus metrics on port
8000by default. - Configure Prometheus to scrape:
scrape_configs: - job_name: 'trading_system' static_configs: - targets: ['localhost:8000']
- Import our sample dashboard JSON into Grafana (file:
monitoring/grafana_dashboard.json). - Key panels:
- Tick Latency: p50/p99 latency of tick processing
- Signal Rate: Signals generated per minute
- Order Errors: Failed order count
- Logs are written to
logs/trading.login JSON format. - To centralize logs, forward to a log collector (e.g., Loki, ELK):
# Example using promtail (Loki client) promtail --config.file=promtail-config.yaml
- Create Prometheus alerts:
alert: HighTickLatency expr: tick_latency_p99 > 0.02 for: 1m labels: severity: warning annotations: summary: "High tick processing latency" description: "p99 > 20ms"
- Configure Alertmanager for email or Slack notifications.
Monitoring gives you confidence and early warnings if something goes wrong.