System Events


目录

NATS servers leverage Accounts support and generate events such as:

In addition the server supports a limited number of requests that can be used to query for account connections, server stat summaries, and pinging servers in the cluster.

These events are enabled by configuring system_account and subscribing/requesting using a system account user.

Accounts are used so that subscriptions from your applications, say >, do not receive system events and vice versa. Using accounts requires either:

N.B. The default global account $G does not publish advisories.

Available Events and Services

System Account

The system account publishes messages under well known subject patterns.

Server initiated events:

In addition other tools with system account privileges, can initiate requests (Examples can be found here):

Monitoring endpoints as listed in the table below are accessible as system services using the following subject pattern:

Endpoint Endpoint Name
General Server Information VARZ
Connections CONNZ
Routing ROUTEZ
Gateways GATEWAYZ
Leaf Nodes LEAFZ
Subscription Routing SUBSZ
JetStream JSZ
Accounts ACCOUNTZ
Health HEALTHZ
Endpoint Endpoint Name
Connections CONNZ
Leaf Nodes LEAFZ
Subscription Routing SUBSZ
JetStream JSZ
Account INFO

Servers like nats-account-server publish system account messages when a claim is updated, the nats-server listens for them, and updates its account information accordingly:

With these few messages you can build useful monitoring tools:

Local Configuration

To make use of System events, just using accounts, your configuration can look like this:

accounts: {
    USERS: {
        users: [
            {user: a, password: a}
        ]
    },
    SYS: { 
        users: [
            {user: admin, password: changeit}
           ]
    },
}
system_account: SYS

Please note that applications now have to authenticate such that a connection can be associated with an account. In this example username and password were chosen for simplicity of the demonstration. Subscribe to all system events like this nats sub -s nats://admin:changeit@localhost:4222 ">" and observe what happens when you do something like nats pub -s "nats://a:a@localhost:4222" foo bar. Examples on how to use system services can be found here.


版本号 #3
由 cocobook-sync 创建于 2026-10-28 11:14:25 UTC
由 cocobook-sync 更新于 2026-10-29 01:42:39 UTC