Skip to content

NATS

NATS server monitoring and read-only JetStream streams, consumers, messages, KV and object stores

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/nats/index.md to help me query NATS with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Compare server load and JetStream availability

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT server_name, version, jetstream_enabled, connections,
  round(uptime_seconds / 3600, 1) AS uptime_hours
FROM nats.main.server_info()
ORDER BY server_name

Quick start

Choose where to run NATS, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'nats' AS nats (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-nats'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

nats credentials

Connection to a NATS server or cluster: server URLs, one authentication method (token, user/password, NKey seed or a .creds file's contents), optional TLS, and the HTTP monitoring URL.

Get these credentials →
secret.sql
CREATE SECRET nats (
    TYPE nats,
    servers          '<servers>',
    token            '<NATS_TOKEN>',  -- secret
    user             '<user>',
    password         '<NATS_PASSWORD>',  -- secret
    nkey_seed        '<NATS_NKEY_SEED>',  -- secret
    creds            '<NATS_CREDS>',  -- secret
    tls_ca           '<tls_ca>',
    tls_cert         '<tls_cert>',
    tls_key          '<TLS_KEY>',  -- secret
    monitoring_url   '<monitoring_url>',
    jetstream_domain '<jetstream_domain>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT server_name, version, jetstream_enabled, connections,
  round(uptime_seconds / 3600, 1) AS uptime_hours
FROM nats.main.server_info()
ORDER BY server_name
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'nats' AS nats (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

NATS and JetStream as SQL tables in DuckDB: server, connection, account and JetStream monitoring, plus read-only streams, consumers with lag, stream messages, KV buckets and object stores.

Catalog

Everything nats exposes once attached — read straight from the worker's released build.

nats 1 schema
main 23 functions

Read-only SQL over one NATS deployment: server monitoring, JetStream streams and messages, KV and object stores.

Schema examples (23)
Examples (23)

Version, JetStream status and load of every server

SELECT server_name, version, jetstream_enabled, connections,
  round(uptime_seconds / 3600, 1) AS uptime_hours
FROM nats.main.server_info()
ORDER BY server_name;

The 20 connections that published the most messages

SELECT name, account, ip, in_msgs, out_msgs
FROM nats.main.connections(sort := 'msgs_from', max_rows := 20)
ORDER BY in_msgs DESC;

Cluster routes by round-trip time

SELECT server_name, remote_name, rtt_seconds * 1000 AS rtt_ms, pending_bytes
FROM nats.main.routes()
ORDER BY rtt_ms DESC;

Super-cluster gateway connections of every server

SELECT server_name, direction, remote_gateway, rtt_seconds
FROM nats.main.gateways()
ORDER BY server_name, direction, remote_gateway;
19 more examples

Leaf-node connections and their accounts

SELECT server_name, name, account, rtt_seconds
FROM nats.main.leafnodes()
ORDER BY server_name, name;

Who receives a message published on orders.eu.created

SELECT account, subject, queue_group, msgs
FROM nats.main.subscriptions(test_subject := 'orders.eu.created')
ORDER BY account, subject;

Interest-graph size and match-cache efficiency per server

SELECT server_name, num_subscriptions, round(cache_hit_rate, 3) AS hit_rate,
  max_fanout
FROM nats.main.subscription_stats()
ORDER BY server_name;

Every account, which one is the system account and where JetStream is on

SELECT account, is_system, jetstream_enabled, client_connections
FROM nats.main.accounts()
ORDER BY account;

Messages published and delivered per account across the cluster

SELECT account, sum(received_msgs) AS published, sum(sent_msgs) AS delivered
FROM nats.main.account_stats()
GROUP BY account
ORDER BY published DESC;

JetStream file-storage use per server

SELECT server_name, storage_bytes, max_storage_bytes,
  round(100.0 * storage_bytes / nullif(max_storage_bytes, 0), 1) AS pct_used
FROM nats.main.jetstream_servers()
ORDER BY pct_used DESC;

The ten largest streams across all accounts

SELECT account, stream, messages, bytes
FROM nats.main.jsz_streams()
ORDER BY bytes DESC
LIMIT 10;

Lagging consumers across every account

SELECT account, stream, consumer, lag, num_ack_pending
FROM nats.main.jsz_consumers()
WHERE lag > 0
ORDER BY lag DESC;

Health check of every server

SELECT server_name, status, error
FROM nats.main.health()
ORDER BY server_name;

JetStream usage and limits of the account

SELECT streams, consumers, storage_bytes, max_storage_bytes
FROM nats.main.account_info();

Streams by size, without the KV and object-store backing streams

SELECT stream, subjects, messages, bytes, consumer_count
FROM nats.main.streams()
WHERE kind = 'stream'
ORDER BY bytes DESC;

Message count per subject in the ORDERS stream

SELECT subject, messages
FROM nats.main.stream_subjects('ORDERS')
ORDER BY messages DESC, subject;

Lagging consumers, worst first

SELECT stream, consumer, lag, num_ack_pending, num_redelivered
FROM nats.main.consumers()
WHERE lag > 0
ORDER BY lag DESC;

European order events, oldest first

SELECT sequence, subject, timestamp, payload_text
FROM nats.main.messages('ORDERS', subject := 'orders.eu.*')
ORDER BY sequence;

Every KV bucket with its size and history depth

SELECT bucket, keys, values, history, bytes
FROM nats.main.kv_buckets()
ORDER BY bucket;

Current value of every key in the config bucket

SELECT key, value_text, revision
FROM nats.main.kv_entries('config')
ORDER BY key;

Object stores by size

SELECT bucket, objects, size_bytes
FROM nats.main.object_stores()
ORDER BY size_bytes DESC;

Objects in the files store by size

SELECT name, size, chunks, modified
FROM nats.main.objects('files')
ORDER BY size DESC;

Subjects of a stream that a wildcard subscription would receive

SELECT subject, messages
FROM nats.main.stream_subjects('ORDERS')
WHERE nats.main.subject_matches('orders.*.created', subject)
ORDER BY subject;
Scalar functions
subject_matches (pattern VARCHAR, subject VARCHAR) 3 examples

True when a NATS subscription pattern (with * and > wildcards) receives a subject

Arguments
pattern VARCHAR
Subscription subject, possibly with * (one token) and > (one or more trailing tokens) wildcards; NULL in, NULL out.
subject VARCHAR
Subject to test, e.g. a message's subject; NULL in, NULL out.
ReturnsBOOLEAN
Examples (3)

Subjects of a stream that a wildcard subscription would receive

SELECT subject, messages
FROM nats.main.stream_subjects('ORDERS')
WHERE nats.main.subject_matches('orders.*.created', subject)
ORDER BY subject;
SELECT p, nats.main.subject_matches(p, 'orders.eu.created') AS matches
FROM (VALUES ('orders.*.created'), ('orders.>'), ('orders.*'), ('orders.us.created')) t(p)
ORDER BY p;
SELECT nats.main.subject_matches('orders.>', 'orders') AS matches;
Link
Table functions
account_info (secret_name := VARCHAR) 2 examples

JetStream usage and limits of the secret's account

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
domain VARCHAR
JetStream domain; NULL when none.
memory_bytes BIGINT
Memory storage in use.
storage_bytes BIGINT
File storage in use.
reserved_memory_bytes BIGINT
Memory reserved by stream limits.
reserved_storage_bytes BIGINT
File storage reserved by stream limits.
streams BIGINT
Streams in the account.
consumers BIGINT
Consumers in the account.
max_memory_bytes BIGINT
Account memory limit; NULL when unlimited.
max_storage_bytes BIGINT
Account storage limit; NULL when unlimited.
max_streams BIGINT
Stream limit; NULL when unlimited.
max_consumers BIGINT
Consumer limit; NULL when unlimited.
max_ack_pending BIGINT
Per-consumer ack-pending limit; NULL when unlimited.
api_total BIGINT
JetStream API requests made by the account.
api_errors BIGINT
JetStream API requests that failed.
api_level BIGINT
JetStream API level of the server.
tiers VARCHAR
Per-replica-tier usage and limits as JSON (clustered accounts with tiered limits); NULL when not tiered.
Examples (2)

JetStream usage and limits of the account

SELECT streams, consumers, storage_bytes, max_storage_bytes
FROM nats.main.account_info();

Share of the account's storage limit in use

SELECT round(100.0 * storage_bytes / max_storage_bytes, 1) AS pct_storage_used
FROM nats.main.account_info()
WHERE max_storage_bytes IS NOT NULL;
Link
account_stats (include_unused := BOOLEAN, secret_name := VARCHAR) 2 examples

Per-account connection and message counters (/accstatz)

Named arguments
include_unused := BOOLEAN
Include accounts with no connections on a server (default true). · default true
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
account VARCHAR
Account name (or public key).
name VARCHAR
Account display name.
connections BIGINT
Current client connections on this server.
leafnodes BIGINT
Current leaf-node connections on this server.
total_connections BIGINT
Client plus leaf-node connections.
subscriptions BIGINT
Subscriptions in the account on this server.
sent_msgs BIGINT
Messages the server delivered to the account's clients.
sent_bytes BIGINT
Bytes the server delivered to the account's clients.
received_msgs BIGINT
Messages the account's clients published.
received_bytes BIGINT
Bytes the account's clients published.
slow_consumers BIGINT
Slow-consumer events in the account.
Examples (2)

Messages published and delivered per account across the cluster

SELECT account, sum(received_msgs) AS published, sum(sent_msgs) AS delivered
FROM nats.main.account_stats()
GROUP BY account
ORDER BY published DESC;

Accounts with at least one connection

SELECT account, connections
FROM nats.main.account_stats(include_unused := false)
ORDER BY connections DESC;
Link
accounts (secret_name := VARCHAR) 2 examples

Accounts with connections, JetStream status, imports and exports (/accountz)

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
account VARCHAR
Account name (or public key in decentralized auth).
name_tag VARCHAR
Human-readable account name from its JWT.
is_system BOOLEAN
Whether this is the system account.
jetstream_enabled BOOLEAN
Whether JetStream is enabled for the account.
client_connections BIGINT
Client connections bound to the account on this server.
leafnode_connections BIGINT
Leaf-node connections bound to the account on this server.
subscriptions BIGINT
Subscriptions in the account.
expired BOOLEAN
Whether the account JWT has expired.
complete BOOLEAN
Whether the account's configuration was fully resolved.
imports BIGINT
Number of stream and service imports.
exports BIGINT
Number of stream and service exports.
update_time TIMESTAMP WITH TIME ZONE
When the account was last updated.
detail VARCHAR
The account's complete /accountz detail document as JSON (imports, exports, JWT claims).
Examples (2)

Every account, which one is the system account and where JetStream is on

SELECT account, is_system, jetstream_enabled, client_connections
FROM nats.main.accounts()
ORDER BY account;

Accounts that import or export streams or services

SELECT account, imports, exports
FROM nats.main.accounts()
WHERE imports > 0 OR exports > 0
ORDER BY account;
Link
connections (state := VARCHAR, sort := VARCHAR, account := VARCHAR, user := VARCHAR, cid := BIGINT, subject := VARCHAR, skip := BIGINT, max_rows := BIGINT, secret_name := VARCHAR) 2 examples

Client connections with server-side state, account, user, sort and paging filters (/connz)

Named arguments
state := VARCHAR
Which connections: 'open' (default), 'closed' (recently closed, kept by the server) or 'any'. · default "open"
sort := VARCHAR
Server-side sort order before paging, e.g. 'bytes_to' for the heaviest receivers first (stop/reason need state 'closed').
account := VARCHAR
Only connections bound to this account.
user := VARCHAR
Only connections authenticated as this user.
cid := BIGINT
Only the connection with this connection id.
subject := VARCHAR
Only connections with a subscription that receives this subject (wildcard subscriptions are matched).
skip := BIGINT
Skip this many connections per server (the server-side offset for paging). · default 0
max_rows := BIGINT
At most this many connections per server (server-side limit).
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
cid BIGINT
Connection id, unique per server.
kind VARCHAR
Connection kind: 'Client', 'Leafnode', ...
type VARCHAR
Client type: 'nats', 'mqtt', 'websocket'.
name VARCHAR
Name the client gave on connect.
ip VARCHAR
Remote IP address.
port BIGINT
Remote port.
account VARCHAR
Account the connection is bound to.
authorized_user VARCHAR
Authenticated user name.
lang VARCHAR
Client library language.
client_version VARCHAR
Client library version.
start_time TIMESTAMP WITH TIME ZONE
When the connection was established.
last_activity TIMESTAMP WITH TIME ZONE
Time of the last message in either direction.
stop_time TIMESTAMP WITH TIME ZONE
When a closed connection closed; NULL when open.
reason VARCHAR
Why a closed connection closed; NULL when open.
uptime_seconds DOUBLE
Connection age in seconds (server clock).
idle_seconds DOUBLE
Seconds since last_activity (server clock).
rtt_seconds DOUBLE
Last measured round-trip time in seconds.
pending_bytes BIGINT
Bytes queued to the client but not yet sent.
in_msgs BIGINT
Messages received from the client.
out_msgs BIGINT
Messages sent to the client.
in_bytes BIGINT
Bytes received from the client.
out_bytes BIGINT
Bytes sent to the client.
subscriptions BIGINT
Number of subscriptions.
subscriptions_list VARCHAR[]
The connection's subscription subjects.
tls_version VARCHAR
TLS version; NULL for plaintext.
tls_cipher_suite VARCHAR
TLS cipher suite; NULL for plaintext.
mqtt_client VARCHAR
MQTT client id for MQTT connections.
Examples (2)

The 20 connections that published the most messages

SELECT name, account, ip, in_msgs, out_msgs
FROM nats.main.connections(sort := 'msgs_from', max_rows := 20)
ORDER BY in_msgs DESC;

Open connections and pending bytes per account

SELECT account, count(*) AS conns, sum(pending_bytes) AS pending
FROM nats.main.connections()
GROUP BY account
ORDER BY conns DESC;
Link
consumers (stream := VARCHAR, secret_name := VARCHAR) 2 examples

JetStream consumers with delivery state, ack floor and lag

Named arguments
stream := VARCHAR
Only this stream's consumers (default: every stream).
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
stream VARCHAR
Stream the consumer reads.
consumer VARCHAR
Consumer name.
durable BOOLEAN
Whether the consumer is durable (survives without subscribers).
description VARCHAR
Consumer description.
push BOOLEAN
Whether it is a push consumer (has a deliver subject).
deliver_subject VARCHAR
Push consumer's deliver subject; NULL for pull consumers.
deliver_group VARCHAR
Push consumer's queue group.
filter_subjects VARCHAR[]
Subjects the consumer is filtered to (empty: all).
deliver_policy VARCHAR
'all', 'last', 'new', 'by_start_sequence', 'by_start_time' or 'last_per_subject'.
ack_policy VARCHAR
'explicit', 'all' or 'none'.
ack_wait_seconds DOUBLE
Redelivery timeout in seconds.
max_deliver BIGINT
Delivery attempts before giving up; NULL when unlimited.
max_ack_pending BIGINT
Outstanding-ack limit; NULL when unlimited.
replay_policy VARCHAR
'instant' or 'original'.
inactive_threshold_seconds DOUBLE
Idle time before an ephemeral consumer is removed.
created TIMESTAMP WITH TIME ZONE
When the consumer was created.
delivered_consumer_seq BIGINT
Consumer sequence of the last delivery.
delivered_stream_seq BIGINT
Stream sequence of the last delivered message.
last_delivered TIMESTAMP WITH TIME ZONE
When the last message was delivered; NULL if never.
ack_floor_consumer_seq BIGINT
Consumer sequence below which everything is acknowledged.
ack_floor_stream_seq BIGINT
Stream sequence below which everything is acknowledged.
last_ack TIMESTAMP WITH TIME ZONE
When the ack floor last moved; NULL if never.
num_pending BIGINT
Messages matching the consumer not yet delivered.
lag BIGINT
Consumer lag: the same value as num_pending, named as in the other messaging workers.
num_ack_pending BIGINT
Delivered messages awaiting acknowledgement.
num_redelivered BIGINT
Messages delivered more than once.
num_waiting BIGINT
Outstanding pull requests.
paused BOOLEAN
Whether the consumer is paused.
push_bound BOOLEAN
Whether a push consumer has an active subscriber.
leader VARCHAR
Server leading the consumer; NULL when not clustered.
config VARCHAR
The complete consumer configuration as JSON.
Examples (2)

Lagging consumers, worst first

SELECT stream, consumer, lag, num_ack_pending, num_redelivered
FROM nats.main.consumers()
WHERE lag > 0
ORDER BY lag DESC;

Delivery position and lag of the ORDERS consumers

SELECT consumer, delivered_stream_seq, ack_floor_stream_seq, lag
FROM nats.main.consumers(stream := 'ORDERS')
ORDER BY consumer;
Link
gateways (secret_name := VARCHAR) 2 examples

Outbound and inbound super-cluster gateway connections (/gatewayz)

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
gateway VARCHAR
This server's gateway (cluster) name.
direction VARCHAR
'outbound' or 'inbound'.
remote_gateway VARCHAR
Name of the remote gateway (cluster).
configured BOOLEAN
Whether the remote gateway is in the config (rather than discovered).
cid BIGINT
Connection id of the gateway connection.
remote_server VARCHAR
Server name of the remote end.
ip VARCHAR
Remote IP address.
port BIGINT
Remote port.
start_time TIMESTAMP WITH TIME ZONE
When the gateway connection was established.
last_activity TIMESTAMP WITH TIME ZONE
Time of the last message on the connection.
rtt_seconds DOUBLE
Round-trip time in seconds.
in_msgs BIGINT
Messages received.
out_msgs BIGINT
Messages sent.
in_bytes BIGINT
Bytes received.
out_bytes BIGINT
Bytes sent.
subscriptions BIGINT
Subscriptions on the connection.
Examples (2)

Super-cluster gateway connections of every server

SELECT server_name, direction, remote_gateway, rtt_seconds
FROM nats.main.gateways()
ORDER BY server_name, direction, remote_gateway;

Bytes sent to each remote cluster

SELECT remote_gateway, sum(out_bytes) AS bytes_sent
FROM nats.main.gateways()
WHERE direction = 'outbound'
GROUP BY remote_gateway
ORDER BY bytes_sent DESC;
Link
health (js_enabled_only := BOOLEAN, js_server_only := BOOLEAN, secret_name := VARCHAR) 2 examples

Server and JetStream health check per server (/healthz)

Named arguments
js_enabled_only := BOOLEAN
Only check that JetStream is enabled (skip stream and consumer health). · default false
js_server_only := BOOLEAN
Check JetStream server health but not individual streams and consumers. · default false
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
status VARCHAR
'ok', 'unavailable' or 'error'.
healthy BOOLEAN
status = 'ok'.
status_code BIGINT
HTTP-style status code when unhealthy (e.g. 503).
error VARCHAR
Why the server is unhealthy; NULL when healthy.
Examples (2)

Health check of every server

SELECT server_name, status, error
FROM nats.main.health()
ORDER BY server_name;

How many servers fail the JetStream server health check

SELECT count(*) FILTER (WHERE NOT healthy) AS unhealthy
FROM nats.main.health(js_server_only := true);
Link
jetstream_servers (secret_name := VARCHAR) 2 examples

JetStream storage, memory, API and meta-cluster state per server (/jsz)

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
enabled BOOLEAN
Whether JetStream runs on this server.
domain VARCHAR
JetStream domain; NULL when none.
memory_bytes BIGINT
Memory-storage bytes in use.
storage_bytes BIGINT
File-storage bytes in use.
reserved_memory_bytes BIGINT
Memory reserved by account limits.
reserved_storage_bytes BIGINT
Storage reserved by account limits.
max_memory_bytes BIGINT
Configured memory-storage limit.
max_storage_bytes BIGINT
Configured file-storage limit.
store_dir VARCHAR
JetStream storage directory on the server.
accounts BIGINT
Accounts with JetStream enabled.
ha_assets BIGINT
Replicated (Raft) assets: streams and consumers with replicas > 1.
streams BIGINT
Streams placed on this server.
consumers BIGINT
Consumers placed on this server.
messages BIGINT
Messages stored on this server.
bytes BIGINT
Bytes stored on this server.
api_total BIGINT
JetStream API requests served.
api_errors BIGINT
JetStream API requests that failed.
api_level BIGINT
JetStream API level the server supports.
meta_leader VARCHAR
Current meta-cluster leader; NULL when not clustered.
meta_cluster_size BIGINT
Number of peers in the meta cluster.
Examples (2)

JetStream file-storage use per server

SELECT server_name, storage_bytes, max_storage_bytes,
  round(100.0 * storage_bytes / nullif(max_storage_bytes, 0), 1) AS pct_used
FROM nats.main.jetstream_servers()
ORDER BY pct_used DESC;

Streams, consumers and API errors on every JetStream server

SELECT server_name, streams, consumers, api_errors
FROM nats.main.jetstream_servers()
WHERE enabled
ORDER BY server_name;
Link
jsz_consumers (account := VARCHAR, secret_name := VARCHAR) 2 examples

Consumers of every account with lag and ack state, from JetStream monitoring (/jsz)

Named arguments
account := VARCHAR
Only this account's streams (pushed down as /jsz?acc=).
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
account VARCHAR
Account owning the stream.
stream VARCHAR
Stream the consumer reads.
consumer VARCHAR
Consumer name.
created TIMESTAMP WITH TIME ZONE
When the consumer was created.
leader VARCHAR
Server currently leading the consumer.
delivered_stream_seq BIGINT
Stream sequence of the last delivered message.
ack_floor_stream_seq BIGINT
Stream sequence below which everything is acknowledged.
num_pending BIGINT
Messages matching the consumer not yet delivered: the consumer lag.
lag BIGINT
Consumer lag (same as num_pending), named as in the other messaging workers.
num_ack_pending BIGINT
Delivered messages awaiting acknowledgement.
num_redelivered BIGINT
Messages delivered more than once.
num_waiting BIGINT
Outstanding pull requests.
last_active TIMESTAMP WITH TIME ZONE
When the consumer last delivered a message.
Examples (2)

Lagging consumers across every account

SELECT account, stream, consumer, lag, num_ack_pending
FROM nats.main.jsz_consumers()
WHERE lag > 0
ORDER BY lag DESC;

Total consumer lag per account

SELECT account, sum(lag) AS total_lag
FROM nats.main.jsz_consumers()
GROUP BY account
ORDER BY total_lag DESC;
Link
jsz_streams (account := VARCHAR, secret_name := VARCHAR) 2 examples

Streams of every account with state, from JetStream monitoring (/jsz)

Named arguments
account := VARCHAR
Only this account's streams (pushed down as /jsz?acc=).
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
account VARCHAR
Account owning the stream.
stream VARCHAR
Stream name.
created TIMESTAMP WITH TIME ZONE
When the stream was created.
cluster VARCHAR
Cluster the stream is placed in.
leader VARCHAR
Server currently leading the stream.
messages BIGINT
Messages in the stream.
bytes BIGINT
Bytes in the stream.
first_seq BIGINT
Sequence of the oldest message.
first_ts TIMESTAMP WITH TIME ZONE
Timestamp of the oldest message.
last_seq BIGINT
Sequence of the newest message.
last_ts TIMESTAMP WITH TIME ZONE
Timestamp of the newest message.
num_subjects BIGINT
Distinct subjects in the stream.
num_deleted BIGINT
Interior deleted messages.
consumer_count BIGINT
Consumers on the stream.
Examples (2)

The ten largest streams across all accounts

SELECT account, stream, messages, bytes
FROM nats.main.jsz_streams()
ORDER BY bytes DESC
LIMIT 10;

Stream count and storage per account

SELECT account, count(*) AS streams, sum(bytes) AS bytes
FROM nats.main.jsz_streams()
GROUP BY account
ORDER BY bytes DESC;
Link
kv_buckets (secret_name := VARCHAR) 2 examples

JetStream key-value buckets with size, history depth and TTL

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
bucket VARCHAR
Bucket name.
description VARCHAR
Bucket description.
stream VARCHAR
Backing stream (KV_<bucket>).
values BIGINT
Stored entries, including history and delete markers.
keys BIGINT
Distinct keys with stored entries (including deleted keys' markers).
history BIGINT
Revisions kept per key.
ttl_seconds DOUBLE
Entry expiry in seconds; NULL when entries never expire.
max_value_size BIGINT
Largest value accepted; NULL when unlimited.
max_bytes BIGINT
Bucket size limit; NULL when unlimited.
bytes BIGINT
Bytes stored.
storage VARCHAR
'file' or 'memory'.
replicas BIGINT
Replica count.
compressed BOOLEAN
Whether the backing stream is S2-compressed.
last_revision BIGINT
Revision (stream sequence) of the newest entry.
last_update TIMESTAMP WITH TIME ZONE
When the newest entry was written; NULL when empty.
metadata MAP(VARCHAR, VARCHAR)
User metadata on the bucket.
Examples (2)

Every KV bucket with its size and history depth

SELECT bucket, keys, values, history, bytes
FROM nats.main.kv_buckets()
ORDER BY bucket;

Buckets whose entries expire

SELECT bucket, ttl_seconds
FROM nats.main.kv_buckets()
WHERE ttl_seconds IS NOT NULL
ORDER BY ttl_seconds;
Link
kv_entries (bucket VARCHAR, key := VARCHAR, include_history := BOOLEAN, include_deleted := BOOLEAN, secret_name := VARCHAR) 2 examples

Latest values or full revision history of a JetStream KV bucket

Positional arguments
bucket VARCHAR
KV bucket name.
Named arguments
key := VARCHAR
Key or key pattern; NATS wildcards * and > allowed (default '>': every key). Pushed down as the filter subject. · default "\u003e"
include_history := BOOLEAN
Return every stored revision of each key (up to the bucket's history depth), not just the latest. · default false
include_deleted := BOOLEAN
Include delete and purge markers (operation DEL / PURGE). · default false
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
bucket VARCHAR
KV bucket name.
key VARCHAR
Entry key.
revision BIGINT
Revision: the entry's sequence in the bucket's stream.
operation VARCHAR
'PUT', 'DEL' (deleted) or 'PURGE' (purged).
created TIMESTAMP WITH TIME ZONE
When this revision was written.
value BLOB
Value bytes; NULL for DEL and PURGE markers.
value_text VARCHAR
The value as text when it is valid UTF-8; otherwise NULL.
Examples (2)

Current value of every key in the config bucket

SELECT key, value_text, revision
FROM nats.main.kv_entries('config')
ORDER BY key;

Change history of one key

SELECT revision, operation, value_text, created
FROM nats.main.kv_entries('config', key := 'app.color', include_history := true)
ORDER BY revision;
Link
leafnodes (account := VARCHAR, secret_name := VARCHAR) 2 examples

Leaf-node connections with account, RTT and traffic (/leafz)

Named arguments
account := VARCHAR
Only leaf-node connections bound to this account.
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
leaf_id BIGINT
Connection id of the leaf-node connection.
name VARCHAR
Server name of the remote end.
is_spoke BOOLEAN
Whether the remote is a spoke (it connected to this hub).
account VARCHAR
Account the leaf-node connection is bound to.
ip VARCHAR
Remote IP address.
port BIGINT
Remote port.
rtt_seconds DOUBLE
Round-trip time in seconds.
in_msgs BIGINT
Messages received.
out_msgs BIGINT
Messages sent.
in_bytes BIGINT
Bytes received.
out_bytes BIGINT
Bytes sent.
subscriptions BIGINT
Subscriptions (interest) over the connection.
compression VARCHAR
Compression mode.
Examples (2)

Leaf-node connections and their accounts

SELECT server_name, name, account, rtt_seconds
FROM nats.main.leafnodes()
ORDER BY server_name, name;

Leaf-node connections per account

SELECT account, count(*) AS leafs
FROM nats.main.leafnodes()
GROUP BY account
ORDER BY leafs DESC;
Link
messages (stream VARCHAR, subject := VARCHAR, start_seq := BIGINT, start_time := TIMESTAMP WITH TIME ZONE, max_msgs := BIGINT, secret_name := VARCHAR) 3 examples

Read a stream's messages without consuming them; subject, sequence and time filters pushed down

Positional arguments
stream VARCHAR
Stream to read.
Named arguments
subject := VARCHAR
Only messages on this subject; NATS wildcards * and > allowed (pushed down as the consumer's filter subject).
start_seq := BIGINT
First stream sequence to read (default: the oldest message).
start_time := TIMESTAMP WITH TIME ZONE
Read messages stored at or after this time (ignored when start_seq is given).
max_msgs := BIGINT
Stop after this many messages.
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
stream VARCHAR
Stream the message is stored in.
subject VARCHAR
Subject the message was published on.
sequence BIGINT
Stream sequence number (unique and increasing within the stream).
timestamp TIMESTAMP WITH TIME ZONE
When the stream stored the message.
key VARCHAR
The message key in the shared messaging vocabulary: for NATS, the subject.
payload BLOB
Message payload bytes.
payload_text VARCHAR
The payload as text when it is valid UTF-8; otherwise NULL.
payload_bytes BIGINT
Payload size in bytes.
headers MAP(VARCHAR, VARCHAR)
Message headers; a header with several values is a JSON array of strings.
redelivered BOOLEAN
Always NULL: a stream read has no delivery history (kept for the shared messaging vocabulary).
Examples (3)

European order events, oldest first

SELECT sequence, subject, timestamp, payload_text
FROM nats.main.messages('ORDERS', subject := 'orders.eu.*')
ORDER BY sequence;

Message count and bytes per subject after sequence 5 (the sequence filter is pushed down)

SELECT subject, count(*) AS msgs, sum(payload_bytes) AS bytes
FROM nats.main.messages('ORDERS')
WHERE sequence > 5
GROUP BY subject
ORDER BY subject;

Decode JSON payloads and count created orders per region

SELECT json_extract_string(payload_text, '$.region') AS region,
  count(*) AS orders
FROM nats.main.messages('ORDERS', subject := 'orders.*.created', max_msgs := 1000)
GROUP BY region
ORDER BY region;
Link
object_stores (secret_name := VARCHAR) 2 examples

JetStream object stores with object counts and size

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
bucket VARCHAR
Object store name.
description VARCHAR
Object store description.
stream VARCHAR
Backing stream (OBJ_<bucket>).
objects BIGINT
Live (not deleted) objects.
size_bytes BIGINT
Bytes stored, including chunk and metadata overhead.
ttl_seconds DOUBLE
Object expiry in seconds; NULL when objects never expire.
max_bytes BIGINT
Store size limit; NULL when unlimited.
storage VARCHAR
'file' or 'memory'.
replicas BIGINT
Replica count.
sealed BOOLEAN
Whether the store is sealed (read-only).
compressed BOOLEAN
Whether the backing stream is S2-compressed.
metadata MAP(VARCHAR, VARCHAR)
User metadata on the store.
Examples (2)

Object stores by size

SELECT bucket, objects, size_bytes
FROM nats.main.object_stores()
ORDER BY size_bytes DESC;

How many object stores and objects the account has

SELECT count(*) AS stores, sum(objects) AS objects
FROM nats.main.object_stores();
Link
objects (bucket VARCHAR, include_deleted := BOOLEAN, include_content := BOOLEAN, max_content_bytes := BIGINT, secret_name := VARCHAR) 2 examples

Objects in a JetStream object store, with optional content download

Positional arguments
bucket VARCHAR
Object store name.
Named arguments
include_deleted := BOOLEAN
Also list deleted objects (their delete markers). · default false
include_content := BOOLEAN
Download each object into the content column (default false: content is NULL). · default false
max_content_bytes := BIGINT
With include_content: objects larger than this many bytes get NULL content (default 16 MiB). · default 16777216
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
bucket VARCHAR
Object store name.
name VARCHAR
Object name.
description VARCHAR
Object description.
size BIGINT
Object size in bytes.
chunks BIGINT
Number of chunks the object is stored in.
digest VARCHAR
Content digest, e.g. 'SHA-256=...'.
modified TIMESTAMP WITH TIME ZONE
When the object was last written.
nuid VARCHAR
Unique id of this object version.
deleted BOOLEAN
Whether this is a delete marker.
link VARCHAR
For a link: '<bucket>/<name>' it points to; NULL otherwise.
headers MAP(VARCHAR, VARCHAR)
Object headers; a header with several values is a JSON array of strings.
metadata MAP(VARCHAR, VARCHAR)
Object metadata.
content BLOB
The object bytes when include_content := true and size <= max_content_bytes; otherwise NULL.
content_text VARCHAR
content as text when it is valid UTF-8; otherwise NULL.
Examples (2)

Objects in the files store by size

SELECT name, size, chunks, modified
FROM nats.main.objects('files')
ORDER BY size DESC;

Read small text objects

SELECT name, content_text
FROM nats.main.objects('files', include_content := true, max_content_bytes := 1024)
WHERE content_text IS NOT NULL
ORDER BY name;
Link
routes (secret_name := VARCHAR) 2 examples

Cluster routes between servers with RTT and traffic (/routez)

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
rid BIGINT
Route id on this server.
remote_id VARCHAR
Server ID of the peer.
remote_name VARCHAR
Server name of the peer.
did_solicit BOOLEAN
Whether this server initiated the route.
is_configured BOOLEAN
Whether the route is in the config (rather than gossiped).
ip VARCHAR
Peer IP address.
port BIGINT
Peer port.
start_time TIMESTAMP WITH TIME ZONE
When the route was established.
last_activity TIMESTAMP WITH TIME ZONE
Time of the last message on the route.
rtt_seconds DOUBLE
Round-trip time in seconds.
pending_bytes BIGINT
Bytes queued to the peer.
in_msgs BIGINT
Messages received over the route.
out_msgs BIGINT
Messages sent over the route.
in_bytes BIGINT
Bytes received over the route.
out_bytes BIGINT
Bytes sent over the route.
subscriptions BIGINT
Interest (subscriptions) propagated over the route.
account VARCHAR
Pinned account for a dedicated per-account route; NULL for shared routes.
compression VARCHAR
Route compression mode.
Examples (2)

Cluster routes by round-trip time

SELECT server_name, remote_name, rtt_seconds * 1000 AS rtt_ms, pending_bytes
FROM nats.main.routes()
ORDER BY rtt_ms DESC;

How many routes each server has (a full mesh has n-1 or more)

SELECT server_name, count(*) AS routes
FROM nats.main.routes()
GROUP BY server_name
ORDER BY server_name;
Link
server_info (secret_name := VARCHAR) 2 examples

Server version, uptime, resources and traffic counters (/varz), one row per server

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
version VARCHAR
nats-server version, e.g. '2.11.4'.
git_commit VARCHAR
Git commit the server was built from.
go_version VARCHAR
Go toolchain the server was built with.
host VARCHAR
Client listen host.
port BIGINT
Client listen port.
cluster VARCHAR
Cluster name; NULL when not clustered.
jetstream_enabled BOOLEAN
Whether JetStream runs on this server.
jetstream_domain VARCHAR
JetStream domain; NULL when none is configured.
auth_required BOOLEAN
Whether clients must authenticate.
tls_required BOOLEAN
Whether clients must use TLS.
start_time TIMESTAMP WITH TIME ZONE
When the server started.
now TIMESTAMP WITH TIME ZONE
The server's clock when it answered.
uptime_seconds DOUBLE
now - start_time in seconds.
config_load_time TIMESTAMP WITH TIME ZONE
When the configuration was last (re)loaded.
mem_bytes BIGINT
Resident memory of the server process.
cores BIGINT
CPU cores the server sees.
cpu_percent DOUBLE
CPU use in percent of one core.
connections BIGINT
Current client connections.
total_connections BIGINT
Client connections accepted since start.
routes BIGINT
Current cluster routes.
gateways BIGINT
Current outbound gateway (super-cluster) connections.
leafnodes BIGINT
Current leaf-node connections.
subscriptions BIGINT
Subscriptions in the server's interest graph.
in_msgs BIGINT
Messages received since start.
out_msgs BIGINT
Messages sent since start.
in_bytes BIGINT
Bytes received since start.
out_bytes BIGINT
Bytes sent since start.
slow_consumers BIGINT
Slow-consumer events since start.
max_connections BIGINT
Configured connection limit.
max_payload BIGINT
Largest message payload accepted, in bytes.
system_account VARCHAR
Name of the system account; NULL when none.
tags VARCHAR[]
Server tags (placement tags).
varz VARCHAR
The complete /varz document as JSON, for fields without a column.
Examples (2)

Version, JetStream status and load of every server

SELECT server_name, version, jetstream_enabled, connections,
  round(uptime_seconds / 3600, 1) AS uptime_hours
FROM nats.main.server_info()
ORDER BY server_name;

Cluster-wide message totals and slow-consumer events

SELECT sum(in_msgs) AS msgs_in, sum(out_msgs) AS msgs_out,
  sum(slow_consumers) AS slow
FROM nats.main.server_info();
Link
stream_subjects (stream VARCHAR, filter := VARCHAR, secret_name := VARCHAR) 2 examples

Distinct subjects in a stream with message counts, filtered by the server

Positional arguments
stream VARCHAR
Stream name.
Named arguments
filter := VARCHAR
Subject filter with NATS wildcards (default '>': every subject), applied by the server. · default "\u003e"
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
stream VARCHAR
Stream name.
subject VARCHAR
A subject holding messages in the stream.
messages BIGINT
Messages currently stored on the subject.
Examples (2)

Message count per subject in the ORDERS stream

SELECT subject, messages
FROM nats.main.stream_subjects('ORDERS')
ORDER BY messages DESC, subject;

Created orders per region, counted by the server

SELECT split_part(subject, '.', 2) AS region, sum(messages) AS msgs
FROM nats.main.stream_subjects('ORDERS', filter := 'orders.*.created')
GROUP BY region
ORDER BY region;
Link
streams (secret_name := VARCHAR) 2 examples

Every JetStream stream with configuration and state

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
stream VARCHAR
Stream name.
kind VARCHAR
'stream', 'kv' (a KV bucket's KV_<bucket> stream) or 'object_store' (OBJ_<bucket>).
description VARCHAR
Stream description.
subjects VARCHAR[]
Subjects the stream captures (empty for mirrors).
retention VARCHAR
'limits', 'interest' or 'workqueue'.
storage VARCHAR
'file' or 'memory'.
replicas BIGINT
Configured replica count.
max_msgs BIGINT
Message limit; NULL when unlimited.
max_bytes BIGINT
Byte limit; NULL when unlimited.
max_age_seconds DOUBLE
Maximum message age in seconds; NULL when unlimited.
max_msgs_per_subject BIGINT
Per-subject message limit; NULL when unlimited.
max_msg_size BIGINT
Largest message accepted; NULL when unlimited.
discard VARCHAR
'old' or 'new': what happens when a limit is hit.
duplicate_window_seconds DOUBLE
De-duplication window in seconds.
compression VARCHAR
'none' or 's2'.
allow_direct BOOLEAN
Whether direct-get is enabled.
sealed BOOLEAN
Whether the stream is sealed (read-only).
deny_delete BOOLEAN
Whether message deletion is denied.
deny_purge BOOLEAN
Whether purging is denied.
allow_rollup BOOLEAN
Whether rollup headers are allowed.
mirror VARCHAR
Name of the stream this one mirrors; NULL when not a mirror.
sources VARCHAR[]
Names of streams this one sources from.
created TIMESTAMP WITH TIME ZONE
When the stream was created.
messages BIGINT
Messages in the stream.
bytes BIGINT
Bytes in the stream.
first_seq BIGINT
Sequence of the oldest message.
first_ts TIMESTAMP WITH TIME ZONE
Timestamp of the oldest message; NULL when empty.
last_seq BIGINT
Sequence of the newest message.
last_ts TIMESTAMP WITH TIME ZONE
Timestamp of the newest message; NULL when empty.
num_subjects BIGINT
Distinct subjects holding messages.
num_deleted BIGINT
Interior deleted messages.
consumer_count BIGINT
Consumers on the stream.
cluster VARCHAR
Cluster the stream is placed in; NULL when not clustered.
leader VARCHAR
Server leading the stream; NULL when not clustered.
metadata MAP(VARCHAR, VARCHAR)
User metadata on the stream config.
config VARCHAR
The complete stream configuration as JSON.
Examples (2)

Streams by size, without the KV and object-store backing streams

SELECT stream, subjects, messages, bytes, consumer_count
FROM nats.main.streams()
WHERE kind = 'stream'
ORDER BY bytes DESC;

Streams that have gone longest without a new message

SELECT stream, last_ts, now() - last_ts AS idle
FROM nats.main.streams()
ORDER BY idle DESC
LIMIT 5;
Link
subscription_stats (secret_name := VARCHAR) 2 examples

Subscription interest-graph and match-cache statistics per server (/subsz)

Named arguments
secret_name := VARCHAR
Name of the nats secret to use when several exist (default: the nats secret whose scope matches).
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
num_subscriptions BIGINT
Subscriptions in the interest graph.
num_cache BIGINT
Entries in the subject match cache.
num_inserts BIGINT
Subscriptions inserted since start.
num_removes BIGINT
Subscriptions removed since start.
num_matches BIGINT
Subject match operations since start.
cache_hit_rate DOUBLE
Fraction of matches served from the cache.
max_fanout BIGINT
Largest number of subscribers one message matched.
avg_fanout DOUBLE
Average number of subscribers per message.
Examples (2)

Interest-graph size and match-cache efficiency per server

SELECT server_name, num_subscriptions, round(cache_hit_rate, 3) AS hit_rate,
  max_fanout
FROM nats.main.subscription_stats()
ORDER BY server_name;

Total subscriptions across the cluster

SELECT sum(num_subscriptions) AS subs FROM nats.main.subscription_stats();
Link
subscriptions (account := VARCHAR, test_subject := VARCHAR, secret_name := VARCHAR) 2 examples

Subscriptions with account and server-side 'who receives this subject' matching (/subsz)

Named arguments
account := VARCHAR
Only subscriptions in this account.
test_subject := VARCHAR
Only subscriptions that would receive a message published on this literal subject (server-side match).
secret_name := VARCHAR
Name of the nats secret to use when several exist.
Returns columns
server_id VARCHAR
Server ID (the server's public NKey).
server_name VARCHAR
Server name (server_name in its config).
account VARCHAR
Account the subscription belongs to.
subject VARCHAR
Subscribed subject, possibly with * and > wildcards.
queue_group VARCHAR
Queue group; NULL for a plain subscription.
sid VARCHAR
Subscription id on its connection.
msgs BIGINT
Messages delivered to the subscription.
max BIGINT
Auto-unsubscribe limit; NULL when none.
cid BIGINT
Connection id owning the subscription.
Examples (2)

Who receives a message published on orders.eu.created

SELECT account, subject, queue_group, msgs
FROM nats.main.subscriptions(test_subject := 'orders.eu.created')
ORDER BY account, subject;

Subscriptions per account

SELECT account, count(*) AS subs
FROM nats.main.subscriptions()
GROUP BY account
ORDER BY subs DESC;
Link

Credentials

The secret type nats declares, as reported by the worker itself.

nats

How to get these credentials

Connection to a NATS server or cluster: server URLs, one authentication method (token, user/password, NKey seed or a .creds file's contents), optional TLS, and the HTTP monitoring URL.

secret.sql
CREATE SECRET nats (
    TYPE nats,
    servers          '<servers>',
    token            '<NATS_TOKEN>',  -- secret
    user             '<user>',
    password         '<NATS_PASSWORD>',  -- secret
    nkey_seed        '<NATS_NKEY_SEED>',  -- secret
    creds            '<NATS_CREDS>',  -- secret
    tls_ca           '<tls_ca>',
    tls_cert         '<tls_cert>',
    tls_key          '<TLS_KEY>',  -- secret
    monitoring_url   '<monitoring_url>',
    jetstream_domain '<jetstream_domain>'
);
Key Type Required Description
servers VARCHAR — Comma-separated server URLs, e.g. 'nats://n1:4222,nats://n2:4222' (tls:// for TLS). Default nats://127.0.0.1:4222.
token secret VARCHAR — Authentication token.
user VARCHAR — User name for user/password authentication.
password secret VARCHAR — Password for user/password authentication.
nkey_seed secret VARCHAR — NKey user seed (starts with SU), for NKey authentication.
creds secret VARCHAR — Contents of a decentralized-auth .creds file (user JWT plus NKey seed).
tls_ca VARCHAR — PEM CA certificate(s) used to verify the server.
tls_cert VARCHAR — PEM client certificate for mutual TLS.
tls_key secret VARCHAR — PEM private key of the client certificate.
monitoring_url VARCHAR — Comma-separated HTTP monitoring base URLs (port 8222), one per server, e.g. 'http://n1:8222'. Without it, monitoring functions use the $SYS request API, which needs system-account credentials.
jetstream_domain VARCHAR — JetStream domain to address (leaf-node and multi-domain deployments).

The worker doesn't mark which keys are required.

Needed by account_infoaccount_statsaccountsconnectionsconsumersgatewayshealthjetstream_serversjsz_consumersjsz_streamskv_bucketskv_entries and 10 more functions

Create the secret in the same session, after attaching nats — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

The 20 connections that published the most messages

SELECT name, account, ip, in_msgs, out_msgs
FROM nats.main.connections(sort := 'msgs_from', max_rows := 20)
ORDER BY in_msgs DESC

Uses connections

Cluster routes by round-trip time

SELECT server_name, remote_name, rtt_seconds * 1000 AS rtt_ms, pending_bytes
FROM nats.main.routes()
ORDER BY rtt_ms DESC

Uses routes

Super-cluster gateway connections of every server

SELECT server_name, direction, remote_gateway, rtt_seconds
FROM nats.main.gateways()
ORDER BY server_name, direction, remote_gateway

Uses gateways

Leaf-node connections and their accounts

SELECT server_name, name, account, rtt_seconds
FROM nats.main.leafnodes()
ORDER BY server_name, name

Uses leafnodes

Who receives a message published on orders.eu.created

SELECT account, subject, queue_group, msgs
FROM nats.main.subscriptions(test_subject := 'orders.eu.created')
ORDER BY account, subject

Uses subscriptions

Interest-graph size and match-cache efficiency per server

SELECT server_name, num_subscriptions, round(cache_hit_rate, 3) AS hit_rate,
  max_fanout
FROM nats.main.subscription_stats()
ORDER BY server_name

Uses subscription_stats

41 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Which JetStream streams (not KV or object stores) hold the most messages? List stream and message count, largest first.
  • Which consumers on the ORDERS stream are behind, and by how many messages?
  • List the sequence numbers and subjects of the European (orders.eu.*) messages in the ORDERS stream, oldest first.
  • How many ORDERS messages carry the header X-Tenant = 'globex'?
  • How many messages does each subject in the ORDERS stream hold?
  • What is the current value of the key app.color in the config KV bucket?

NATS is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.