Observability
Monitor the health and performance of your TopGun cluster using Prometheus metrics and structured logging.
Prometheus Metrics
The TopGun server exposes a
/metrics endpoint that is compatible with Prometheus.By default, this is available on the main server port (or a dedicated metrics port if configured).
Key Metrics
| Metric Name | Type | Description |
|---|---|---|
| topgun_connected_clients | Gauge | Number of currently connected WebSocket clients. |
| topgun_map_size_items | Gauge | Number of items in a specific map (labeled by map name). |
| topgun_ops_total | Counter | Total number of operations processed. Labels: type (PUT, GET, DELETE, SUBSCRIBE), map. |
| topgun_memory_usage_bytes | Gauge | Current heap memory usage of the server process. |
| topgun_cluster_members | Gauge | Number of active nodes in the cluster. |
Standard Node.js metrics (CPU, Event Loop, GC) are also exported with the topgun_ prefix.
Structured Logging
TopGun uses Pino for high-performance, structured JSON logging.
This makes it easy to ingest logs into systems like ELK, Datadog, or Loki.
Log Example
server.log
{
"level": 30,
"time": 1678901234567,
"pid": 12345,
"hostname": "topgun-server-0",
"msg": "Server started on port 8080",
"nodeId": "node-xyz-123"
} Logs include context such as nodeId, clientId, and requestId where applicable, allowing you to trace requests across the distributed system.