Skip to main content

NATS Server Monitoring

Insights automatically collects and indexes data from NATS server monitoring endpoints, providing historical analysis and real-time visibility into your infrastructure.

Monitoring Endpoints​

NATS servers expose their monitoring data both as HTTP endpoints and as requests on the system account. Insights uses the system account requests, so it needs no HTTP access to the servers. Each epoch starts by discovering servers with $SYS.REQ.SERVER.PING, then requests every endpoint below. A request addresses all servers at once ($SYS.REQ.SERVER.PING.<ENDPOINT>) or one server by id ($SYS.REQ.SERVER.<id>.<ENDPOINT>).

EndpointSystem requestHTTP equivalentPurpose
varz$SYS.REQ.SERVER.PING.VARZ/varzServer-wide variables and statistics
connz$SYS.REQ.SERVER.PING.CONNZ/connzClient connection details
routez$SYS.REQ.SERVER.PING.ROUTEZ/routezCluster route connections
gatewayz$SYS.REQ.SERVER.PING.GATEWAYZ/gatewayzSuper-cluster gateway information
leafz$SYS.REQ.SERVER.PING.LEAFZ/leafzLeaf node connections
subsz$SYS.REQ.SERVER.PING.SUBSZ/subszSubscription statistics
accountz$SYS.REQ.SERVER.PING.ACCOUNTZ/accountzAccount information
accstatz$SYS.REQ.ACCOUNT.PING.STATZ/accstatzPer-account statistics summary
jsz$SYS.REQ.SERVER.PING.JSZ/jszJetStream information
healthz$SYS.REQ.SERVER.PING.HEALTHZ/healthzHealth check endpoint
ipqueuesz$SYS.REQ.SERVER.PING.IPQUEUESZ/ipqueueszInternal IP queue status
raftz$SYS.REQ.SERVER.PING.RAFTZ/raftzRaft group status

The discovery reply is the server's statsz. A server whose varz reply is missed but which still answers discovery gets a stats row built from that reply, marked statsz_fallback in hx.server_stats, and readers treat it as not having reported. Each epoch also records how many servers it expected and how many it reached on hx.epochs.

What Insights Collects​

For each epoch (scrape interval), Insights captures a snapshot from every monitored server across all endpoints. This data is indexed into DuckDB, enabling:

  • Time-series analysis — Track metrics like CPU, memory, connections, and throughput over time
  • Cross-server correlation — Compare metrics across servers in a cluster
  • Per-account breakdown — View resource usage by account in multi-tenant deployments
  • JetStream health — Monitor streams, consumers, replication lag, and API errors
  • Cluster topology — Track routes, gateways, and leaf node connectivity

Key Metrics​

Server Health​

MetricSourceDescription
CPU UsagevarzCPU utilization (stacked by core count)
MemoryvarzResident memory allocation
ConnectionsvarzCurrent client connections vs configured maximum
Slow ConsumersvarzClients unable to keep up with message delivery
Stale ConnectionsvarzConnections detected as stale

JetStream​

MetricSourceDescription
Memory/Storage UsagejszCurrent usage vs reserved limits
API Error RatejszJetStream API errors relative to total calls
Stream CountjszNumber of streams and consumer count
HA AssetsjszReplicated assets count per server
Replication StatusraftzRaft group health and catching-up state

Cluster​

MetricSourceDescription
Route RTTroutezRound-trip time between cluster members
Leaf RTTleafzLatency to leaf node connections
Route CountvarzConnected routes vs expected topology
Gateway StatusgatewayzSuper-cluster gateway connectivity

Checks​

Insights runs over 140 automated checks against the collected data on every epoch — operational checks against that epoch's state, optimization checks across a trailing window — identifying health issues, performance problems, and configuration concerns. When a finding changes state, the transition is published on $INS.sys.<id>.feed.finding.> and can be delivered to webhook or Alertmanager endpoints (see Configuration → notifications). See Checks for details.

Further Reading​