DocsGuidesObservability

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 NameTypeDescription
topgun_connected_clientsGaugeNumber of currently connected WebSocket clients.
topgun_map_size_itemsGaugeNumber of items in a specific map (labeled by map name).
topgun_ops_totalCounterTotal number of operations processed. Labels: type (PUT, GET, DELETE, SUBSCRIBE), map.
topgun_memory_usage_bytesGaugeCurrent heap memory usage of the server process.
topgun_cluster_membersGaugeNumber 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.