observability

Guide for observability

Observability Stack

Local development observability using Prometheus and Grafana.
For instructions on generating load to see these metrics in action, see Load Testing Guide.

Location

loh-ops-tools/observability/

Quick Start

cd loh-ops-tools/observability
docker compose up -d
ServiceURLCredentials
Prometheushttp://localhost:9090-
Grafanahttp://localhost:6006admin / admin

Components

  • Prometheus: Metrics collection (scrapes /metrics every 5s)
  • Grafana: Dashboard visualization (pre-provisioned)
  • Node Exporter: Host metrics (CPU, Memory, Disk, Network)

Game Server Integration

The api-game crate exposes metrics at GET /metrics:
MetricTypeDescription
loh_connected_playersGaugeCurrent WebSocket connections
loh_game_tick_durationHistogramGame loop tick latency (ms)
loh_messages_processed_totalCounterTotal messages handled
loh_messages_by_typeCounterMessages by type label
loh_ws_connections_totalCounterTotal WS connections
loh_ws_disconnections_totalCounterTotal WS disconnections
loh_db_query_durationHistogramDatabase query latency

Usage in Code

use api_game::metrics;

// In game loop:
metrics::set_connected_players(count);
metrics::record_tick_duration(elapsed_ms);
metrics::increment_messages_processed();

SRE Dashboard Panels

The pre-built loh-sre-dashboard.json includes:
  • CPU Usage (%)
  • Memory Usage
  • Connected Players (live gauge)
  • Game Tick Duration (p50/p99)
  • Network I/O (RX/TX)
  • Messages per Second

Files

observability/
├── docker-compose.yml
├── prometheus/
│   └── prometheus.yml
├── grafana/
│   ├── dashboards/
│   │   └── loh-sre-dashboard.json
│   └── provisioning/
│       ├── dashboards/dashboards.yml
│       └── datasources/datasources.yml
└── README.md

Cleanup

docker compose down -v